Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1193091pxu; Fri, 16 Oct 2020 06:18:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFJoJNxfX/Gu0tnh9BUGyiDn11istGPreR84PDL2NKxyRIuRG69KEvJKK0/I9kPNf3ajqm X-Received: by 2002:a17:906:4d03:: with SMTP id r3mr3484319eju.364.1602854305614; Fri, 16 Oct 2020 06:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602854305; cv=none; d=google.com; s=arc-20160816; b=1I2A+5yiGznWBjPN7DBqxWJOrtUWGSu08vTFNOjCtiVlVfEO6feCU2AknIN2H4WUHP nXMtJN0Y8KtlPIB2fT5g+zwD66KmqS4vRmJAyFXZOIG3eqfqxkHSOshaixiT6NUuoHMb EdK+dKeUg53l8hPonIEBhK5M8poM8+XaPVFOIh3yg6kKmhMxjbarpBJKXqGFSSXZijxg jV4OeItGYdlp4P1pKAKheN5yyEJRFr7iaMXLk4h8Th+3lvg5co0HwjPptcZV1A+dmLFU OYPMyM3+6v4a9WLlgfhu5Hciwp8kPQRPEd5fuLML/yqt1cuji3KedCty4PVGXVkIfwMw /hgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nGU+TiofL4Z7acFZTrz/FX0B5HKwXBlKH6gf2iGwsNU=; b=SApIqrmeUAHnhzrJUkx4S+mq9o65V3uz7NLK1qFGW5+EGP2MdQQOClpB+Ls4KMRDGp P/p2/RtHe1QRzAW6UAsOaeggSdRV032giWy5QkfkxmN5In+1KInwJpnv+Fqzd/f3vwey kFkkPALH7krkp2vqHtXGoBp1CwCDBizl8fMSBLvZS1Y/wQ0UDnWIZ1LuKLCesiMkQZGx RjOC2Fcw3ayWDfTbf6Y+A3RkjNZVDrFHWb5cv3K3ScVgh6KnuM/G2V55Y1bEpmDDWYBv Ov1oryx9QdruB7FUPk8AM2ht7ltYpfwIsH8X85iCIPXrEJIrC5FngWUGLl0pmNUDRE6B OIVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="aPkBWMe/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p60si1617545edd.331.2020.10.16.06.18.03; Fri, 16 Oct 2020 06:18:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="aPkBWMe/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407999AbgJPNCL (ORCPT + 99 others); Fri, 16 Oct 2020 09:02:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:56490 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407883AbgJPNCK (ORCPT ); Fri, 16 Oct 2020 09:02:10 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1602853329; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nGU+TiofL4Z7acFZTrz/FX0B5HKwXBlKH6gf2iGwsNU=; b=aPkBWMe/Mj0XautSxavMJ72BaVq/i6YfnnmycBdFQgPbeb5UoWZSsXjBJC7wuSazIkxpVz tHgtPiwkq+rtUgvRxXdAXXc1Jr6tdUlTM/aAuGRL4XPI1y1WIckpMsVhgIb0n1rLkVEUZa olrZr95ofMtI2Mq2RCWfGkZAjsnZiRk= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DCAB8B11D; Fri, 16 Oct 2020 13:02:08 +0000 (UTC) Date: Fri, 16 Oct 2020 15:02:08 +0200 From: Michal Hocko To: Tianxianting 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() Message-ID: <20201016130208.GI22589@dhcp22.suse.cz> References: <20201016033952.1924-1-tian.xianting@h3c.com> <20201016120749.GG22589@dhcp22.suse.cz> <9a2b772b13f84bdd9517b17d8d72aa89@h3c.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9a2b772b13f84bdd9517b17d8d72aa89@h3c.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 16-10-20 12:48:23, Tianxianting wrote: > 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? You are almost right. But consider situation when the lock is taken for quite some time. do_shrink_slab cannot make any forward progress and effectivelly busy loop. Unless the caller does cond_resched it might cause soft lockups. Anyway let me try to ask again. Why does would this be any problem that deserves a fix? > > -----Original Message----- > From: Michal Hocko [mailto:mhocko@suse.com] > Sent: Friday, October 16, 2020 8:08 PM > To: tianxianting (RD) > 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 > > --- > > 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 -- Michal Hocko SUSE Labs