From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932825AbdKPEuj (ORCPT ); Wed, 15 Nov 2017 23:50:39 -0500 Received: from LGEAMRELO12.lge.com ([156.147.23.52]:38972 "EHLO lgeamrelo12.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750750AbdKPEua (ORCPT ); Wed, 15 Nov 2017 23:50:30 -0500 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: minchan@kernel.org X-Original-SENDERIP: 10.177.220.163 X-Original-MAILFROM: minchan@kernel.org Date: Thu, 16 Nov 2017 13:50:27 +0900 From: Minchan Kim To: Shakeel Butt Cc: Tetsuo Handa , Huang Ying , Mel Gorman , Vladimir Davydov , Michal Hocko , Johannes Weiner , Andrew Morton , Greg Thelen , Linux MM , LKML Subject: Re: [PATCH 1/2] mm,vmscan: Kill global shrinker lock. Message-ID: <20171116045027.GA13101@bbox> References: <1510609063-3327-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> <20171115005602.GB23810@bbox> <20171116004614.GB12222@bbox> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 15, 2017 at 05:41:41PM -0800, Shakeel Butt wrote: > On Wed, Nov 15, 2017 at 4:46 PM, Minchan Kim wrote: > > On Tue, Nov 14, 2017 at 10:28:10PM -0800, Shakeel Butt wrote: > >> On Tue, Nov 14, 2017 at 4:56 PM, Minchan Kim wrote: > >> > On Tue, Nov 14, 2017 at 06:37:42AM +0900, Tetsuo Handa wrote: > >> >> When shrinker_rwsem was introduced, it was assumed that > >> >> register_shrinker()/unregister_shrinker() are really unlikely paths > >> >> which are called during initialization and tear down. But nowadays, > >> >> register_shrinker()/unregister_shrinker() might be called regularly. > >> >> This patch prepares for allowing parallel registration/unregistration > >> >> of shrinkers. > >> >> > >> >> Since do_shrink_slab() can reschedule, we cannot protect shrinker_list > >> >> using one RCU section. But using atomic_inc()/atomic_dec() for each > >> >> do_shrink_slab() call will not impact so much. > >> >> > >> >> This patch uses polling loop with short sleep for unregister_shrinker() > >> >> rather than wait_on_atomic_t(), for we can save reader's cost (plain > >> >> atomic_dec() compared to atomic_dec_and_test()), we can expect that > >> >> do_shrink_slab() of unregistering shrinker likely returns shortly, and > >> >> we can avoid khungtaskd warnings when do_shrink_slab() of unregistering > >> >> shrinker unexpectedly took so long. > >> >> > >> >> Signed-off-by: Tetsuo Handa > >> > > >> > Before reviewing this patch, can't we solve the problem with more > >> > simple way? Like this. > >> > > >> > Shakeel, What do you think? > >> > > >> > >> Seems simple enough. I will run my test (running fork bomb in one > >> memcg and separately time a mount operation) and update if numbers > >> differ significantly. > > > > Thanks. > > > >> > >> > diff --git a/mm/vmscan.c b/mm/vmscan.c > >> > index 13d711dd8776..cbb624cb9baa 100644 > >> > --- a/mm/vmscan.c > >> > +++ b/mm/vmscan.c > >> > @@ -498,6 +498,14 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, > >> > sc.nid = 0; > >> > > >> > freed += do_shrink_slab(&sc, shrinker, nr_scanned, nr_eligible); > >> > + /* > >> > + * bail out if someone want to register a new shrinker to prevent > >> > + * long time stall by parallel ongoing shrinking. > >> > + */ > >> > + if (rwsem_is_contended(&shrinker_rwsem)) { > >> > + freed = 1; > >> > >> freed = freed ?: 1; > > > > Yub. > > Thanks Minchan, you can add > > Reviewed-and-tested-by: Shakeel Butt Thanks for the testing, Shakeel. I will send formal patch to Andrew after closing merge window.