linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/workingset.c: avoid unnecessary max_nodes estimation in count_shadow_nodes()
@ 2021-01-23  7:38 Miaohe Lin
  2021-01-26 16:24 ` Vlastimil Babka
  0 siblings, 1 reply; 2+ messages in thread
From: Miaohe Lin @ 2021-01-23  7:38 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, linmiaohe

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.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/workingset.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/workingset.c b/mm/workingset.c
index 10e96de945b3..7db8f3dad13c 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;
-- 
2.19.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/workingset.c: avoid unnecessary max_nodes estimation in count_shadow_nodes()
  2021-01-23  7:38 [PATCH] mm/workingset.c: avoid unnecessary max_nodes estimation in count_shadow_nodes() Miaohe Lin
@ 2021-01-26 16:24 ` Vlastimil Babka
  0 siblings, 0 replies; 2+ messages in thread
From: Vlastimil Babka @ 2021-01-26 16:24 UTC (permalink / raw)
  To: Miaohe Lin, akpm; +Cc: linux-mm, linux-kernel

On 1/23/21 8:38 AM, Miaohe Lin wrote:
> 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.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  mm/workingset.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/workingset.c b/mm/workingset.c
> index 10e96de945b3..7db8f3dad13c 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;
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-26 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-23  7:38 [PATCH] mm/workingset.c: avoid unnecessary max_nodes estimation in count_shadow_nodes() Miaohe Lin
2021-01-26 16:24 ` Vlastimil Babka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).