mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 21:33:52 +00:00
mm/workingset.c: avoid unnecessary max_nodes estimation in count_shadow_nodes()
If list_lru_shrink_count is 0, we always return SHRINK_EMPTY regardless of the value of max_nodes. So we can return early if nodes == 0 to save some cpu cycles of approximating a reasonable limit for the nodes. Link: https://lkml.kernel.org/r/20210123073825.46709-1-linmiaohe@huawei.com Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
c2135f7c57
commit
725cac1c7e
1 changed files with 2 additions and 3 deletions
|
@ -461,6 +461,8 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,
|
||||||
unsigned long pages;
|
unsigned long pages;
|
||||||
|
|
||||||
nodes = list_lru_shrink_count(&shadow_nodes, sc);
|
nodes = list_lru_shrink_count(&shadow_nodes, sc);
|
||||||
|
if (!nodes)
|
||||||
|
return SHRINK_EMPTY;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Approximate a reasonable limit for the nodes
|
* Approximate a reasonable limit for the nodes
|
||||||
|
@ -503,9 +505,6 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,
|
||||||
|
|
||||||
max_nodes = pages >> (XA_CHUNK_SHIFT - 3);
|
max_nodes = pages >> (XA_CHUNK_SHIFT - 3);
|
||||||
|
|
||||||
if (!nodes)
|
|
||||||
return SHRINK_EMPTY;
|
|
||||||
|
|
||||||
if (nodes <= max_nodes)
|
if (nodes <= max_nodes)
|
||||||
return 0;
|
return 0;
|
||||||
return nodes - max_nodes;
|
return nodes - max_nodes;
|
||||||
|
|
Loading…
Reference in a new issue