All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm,vmscan: don't pretend forward progress upon shrinker_rwsem contention
@ 2018-02-09 13:55 Tetsuo Handa
  2018-02-13 10:13 ` Michal Hocko
  0 siblings, 1 reply; 3+ messages in thread
From: Tetsuo Handa @ 2018-02-09 13:55 UTC (permalink / raw)
  To: linux-mm; +Cc: Tetsuo Handa, Dave Chinner, Glauber Costa, Mel Gorman

Since we no longer use return value of shrink_slab() for normal reclaim,
the comment is no longer true. If some do_shrink_slab() call takes
unexpectedly long (root cause of stall is currently unknown) when
register_shrinker()/unregister_shrinker() is pending, trying to drop
caches via /proc/sys/vm/drop_caches could become infinite cond_resched()
loop if many mem_cgroup are defined. For safety, let's not pretend forward
progress.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Glauber Costa <glommer@parallels.com>
Cc: Mel Gorman <mgorman@suse.de>
---
 mm/vmscan.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 4447496..17da5a5 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -442,16 +442,8 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
 	if (memcg && (!memcg_kmem_enabled() || !mem_cgroup_online(memcg)))
 		return 0;
 
-	if (!down_read_trylock(&shrinker_rwsem)) {
-		/*
-		 * If we would return 0, our callers would understand that we
-		 * have nothing else to shrink and give up trying. By returning
-		 * 1 we keep it going and assume we'll be able to shrink next
-		 * time.
-		 */
-		freed = 1;
+	if (!down_read_trylock(&shrinker_rwsem))
 		goto out;
-	}
 
 	list_for_each_entry(shrinker, &shrinker_list, list) {
 		struct shrink_control sc = {
-- 
1.8.3.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm,vmscan: don't pretend forward progress upon shrinker_rwsem contention
  2018-02-09 13:55 [PATCH] mm,vmscan: don't pretend forward progress upon shrinker_rwsem contention Tetsuo Handa
@ 2018-02-13 10:13 ` Michal Hocko
  2018-02-20 13:29   ` Tetsuo Handa
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Hocko @ 2018-02-13 10:13 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: linux-mm, Dave Chinner, Mel Gorman, Glauber Costa

[Fix Glauber's email]

On Fri 09-02-18 22:55:44, Tetsuo Handa wrote:
> Since we no longer use return value of shrink_slab() for normal reclaim,
> the comment is no longer true. If some do_shrink_slab() call takes
> unexpectedly long (root cause of stall is currently unknown) when
> register_shrinker()/unregister_shrinker() is pending, trying to drop
> caches via /proc/sys/vm/drop_caches could become infinite cond_resched()
> loop if many mem_cgroup are defined. For safety, let's not pretend forward
> progress.
> 
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Cc: Dave Chinner <dchinner@redhat.com>
> Cc: Glauber Costa <glommer@parallels.com>
> Cc: Mel Gorman <mgorman@suse.de>

Yes, this makes sense to me. The whole "let's pretend we made some
progress" was an ugly hack IMHO.

Acked-by: Michal Hocko <mhocko@suse.ccom>

> ---
>  mm/vmscan.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 4447496..17da5a5 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -442,16 +442,8 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>  	if (memcg && (!memcg_kmem_enabled() || !mem_cgroup_online(memcg)))
>  		return 0;
>  
> -	if (!down_read_trylock(&shrinker_rwsem)) {
> -		/*
> -		 * If we would return 0, our callers would understand that we
> -		 * have nothing else to shrink and give up trying. By returning
> -		 * 1 we keep it going and assume we'll be able to shrink next
> -		 * time.
> -		 */
> -		freed = 1;
> +	if (!down_read_trylock(&shrinker_rwsem))
>  		goto out;
> -	}
>  
>  	list_for_each_entry(shrinker, &shrinker_list, list) {
>  		struct shrink_control sc = {
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH] mm,vmscan: don't pretend forward progress upon shrinker_rwsem contention
  2018-02-13 10:13 ` Michal Hocko
@ 2018-02-20 13:29   ` Tetsuo Handa
  0 siblings, 0 replies; 3+ messages in thread
From: Tetsuo Handa @ 2018-02-20 13:29 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, mhocko, dchinner, mgorman, glommer

Since we no longer use return value of shrink_slab() for normal reclaim,
the comment is no longer true. If some do_shrink_slab() call takes
unexpectedly long (root cause of stall is currently unknown) when
register_shrinker()/unregister_shrinker() is pending, trying to drop
caches via /proc/sys/vm/drop_caches could become infinite cond_resched()
loop if many mem_cgroup are defined. For safety, let's not pretend forward
progress.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: Michal Hocko <mhocko@suse.ccom>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Glauber Costa <glommer@gmail.com>
Cc: Mel Gorman <mgorman@suse.de>
---
 mm/vmscan.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 4447496..17da5a5 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -442,16 +442,8 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
 	if (memcg && (!memcg_kmem_enabled() || !mem_cgroup_online(memcg)))
 		return 0;
 
-	if (!down_read_trylock(&shrinker_rwsem)) {
-		/*
-		 * If we would return 0, our callers would understand that we
-		 * have nothing else to shrink and give up trying. By returning
-		 * 1 we keep it going and assume we'll be able to shrink next
-		 * time.
-		 */
-		freed = 1;
+	if (!down_read_trylock(&shrinker_rwsem))
 		goto out;
-	}
 
 	list_for_each_entry(shrinker, &shrinker_list, list) {
 		struct shrink_control sc = {
-- 
1.8.3.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2018-02-20 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-09 13:55 [PATCH] mm,vmscan: don't pretend forward progress upon shrinker_rwsem contention Tetsuo Handa
2018-02-13 10:13 ` Michal Hocko
2018-02-20 13:29   ` Tetsuo Handa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.