Skip to content

Commit

Permalink
mm/workingset.c: avoid unnecessary max_nodes estimation in count_shad…
Browse files Browse the repository at this point in the history
…ow_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/[email protected]
Signed-off-by: Miaohe Lin <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Acked-by: Vlastimil Babka <[email protected]>
Cc: Johannes Weiner <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
MiaoheLin authored and torvalds committed Feb 24, 2021
1 parent c2135f7 commit 725cac1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mm/workingset.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,
unsigned long pages;

nodes = list_lru_shrink_count(&shadow_nodes, sc);
if (!nodes)
return SHRINK_EMPTY;

/*
* Approximate a reasonable limit for the nodes
Expand Down Expand Up @@ -503,9 +505,6 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,

max_nodes = pages >> (XA_CHUNK_SHIFT - 3);

if (!nodes)
return SHRINK_EMPTY;

if (nodes <= max_nodes)
return 0;
return nodes - max_nodes;
Expand Down

0 comments on commit 725cac1

Please sign in to comment.