From: Miaohe Lin Date: Wed, 24 Feb 2021 20:08:06 +0000 (-0800) Subject: mm/workingset.c: avoid unnecessary max_nodes estimation in count_shadow_nodes() X-Git-Tag: accepted/tizen/unified/20230118.172025~7741^2~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=725cac1c7e345c2e35a2de2db57233af279b851f;p=platform%2Fkernel%2Flinux-rpi.git 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 Reviewed-by: Andrew Morton Acked-by: Vlastimil Babka Cc: Johannes Weiner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/workingset.c b/mm/workingset.c index 10e96de..7db8f3d 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -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 @@ -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;