linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tianxianting <tian.xianting@h3c.com>
To: Michal Hocko <mhocko@suse.com>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] mm: vmscan: avoid a unnecessary reschedule in shrink_slab()
Date: Fri, 16 Oct 2020 12:48:23 +0000	[thread overview]
Message-ID: <9a2b772b13f84bdd9517b17d8d72aa89@h3c.com> (raw)
In-Reply-To: <20201016120749.GG22589@dhcp22.suse.cz>

Thanks, my understanding is,
In shrink_slab(), do_shrink_slab() will do the real reclaim work, which will occupy current cpu and consume more cpu time, so we need to trigger a reschedule after reclaim.
But if it jumps to 'out' label, that means we don't do the reclaim work at this time, it won't cause other thread getting starvation, so we don't need to call cond_resched() in this case.
Is it right?

-----Original Message-----
From: Michal Hocko [mailto:mhocko@suse.com] 
Sent: Friday, October 16, 2020 8:08 PM
To: tianxianting (RD) <tian.xianting@h3c.com>
Cc: akpm@linux-foundation.org; linux-mm@kvack.org; linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: vmscan: avoid a unnecessary reschedule in shrink_slab()

On Fri 16-10-20 11:39:52, Xianting Tian wrote:
> In shrink_slab(), it directly goes to 'out' label only when it can't 
> get the lock of shrinker_rwsew. In this case, it doesn't do the real 
> work of shrinking slab, so we don't need trigger a reschedule by 
> cond_resched().

Your changelog doesn't explain why this is not needed or undesirable. Do you see any actual problem?

The point of this code is to provide a deterministic scheduling point regardless of the shrinker_rwsew.

> 
> Signed-off-by: Xianting Tian <tian.xianting@h3c.com>
> ---
>  mm/vmscan.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c index 466fc3144..676e97b28 
> 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -687,8 +687,9 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>  	}
>  
>  	up_read(&shrinker_rwsem);
> -out:
> +
>  	cond_resched();
> +out:
>  	return freed;
>  }
>  
> --
> 2.17.1
> 

-- 
Michal Hocko
SUSE Labs


  reply	other threads:[~2020-10-16 12:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16  3:39 Xianting Tian
2020-10-16 12:07 ` Michal Hocko
2020-10-16 12:48   ` Tianxianting [this message]
2020-10-16 13:02     ` Michal Hocko
2020-10-16 13:20       ` Tianxianting
2020-10-16 13:44         ` Michal Hocko
2020-10-16 14:33           ` Tianxianting

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a2b772b13f84bdd9517b17d8d72aa89@h3c.com \
    --to=tian.xianting@h3c.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox