Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6409363rwd; Mon, 5 Jun 2023 18:20:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6vf7JRStwcFjrBpE5mcI/l/19hZtcjaGdFlqRvICzPnt8WsQpj+HX2Nsx3tsrTAph/fj/r X-Received: by 2002:a17:902:f550:b0:1ac:b449:3528 with SMTP id h16-20020a170902f55000b001acb4493528mr569575plf.46.1686014412292; Mon, 05 Jun 2023 18:20:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686014412; cv=none; d=google.com; s=arc-20160816; b=03fcqaR5rfiKjfoI6+h42BtkcqZHvT7dd5o9f43nepObMdaDsfZHdz5bIDlhZ8yoCf 2p/wFs03Uy9bG4zZGLOUlkQzjLS1yK8ZXHfcgwnitLmOF8BS0pyMw89ShvZRa4pZzmip Wpcq05CPhqRFsE9XqgMImH7RUulNxtvLdgYE8mPmdjqSEpKKk7W8YYpRtPOKz0WpORZw 3xgF9l7dhIQ0vHU0aMEXrGjhH6I1qzoJrBkfwX+Pv1mqpBFOIvrsTT9gMBes7x6KLNEf 5BxzJFGJGtEVVh1XCmzAvv0rfYbno4W26osopBoBolO6ZDFkz4JP/4hUKNC8xfExiW69 d9nw== 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:dkim-signature:date; bh=1Xi6jsYM9ZciceNFvAe5rQ/vkIA6YXglfKKPWJ53Rcs=; b=qUCAe/5iAAdaMkEdckcPTwhyRNrUmqKxt4Z93p+lz9E29lT1WUWR+HTQ7RcZ4Q74Ry +oI/UgWm2HFLNtYMha2nCjkDz6SoRJ7pDpRX8OpPZ2Y9IFnHRRN3e96ag8rE/ih7T8k5 LvRbkuZzkotaEaGQYmKOFbTOMCMxzyUQNAqsBVMPiapYS67HzxzPP9xpTIKqxh3qK1gV c7B0ZIDR52nqt8Wud86MOI+AdVDVWYpDBqsrB7Gic0uLJYqpGGsE8up4do0RoK6hGwhO SM8qBy+OCM2xlorQGNn2npZpWwhunjT1sxDdWvWwFZDAbMOMmwVqVZTHZOBVfxu7Eyco QQvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=VPOYBWQp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c10-20020a170903234a00b001a814f7db5fsi6308122plh.632.2023.06.05.18.19.58; Mon, 05 Jun 2023 18:20:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=VPOYBWQp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233491AbjFFAif (ORCPT + 99 others); Mon, 5 Jun 2023 20:38:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230399AbjFFAie (ORCPT ); Mon, 5 Jun 2023 20:38:34 -0400 Received: from out-35.mta0.migadu.com (out-35.mta0.migadu.com [IPv6:2001:41d0:1004:224b::23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE675EA for ; Mon, 5 Jun 2023 17:38:33 -0700 (PDT) Date: Mon, 5 Jun 2023 17:38:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1686011912; 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=1Xi6jsYM9ZciceNFvAe5rQ/vkIA6YXglfKKPWJ53Rcs=; b=VPOYBWQpwtuyh3+GVgcQm9QECvPCcs07jSDc2pPEuISsH2r70ERXuO5x53OEK/80nVzsSN FSmDit1vPnaSLvzCVTcm+5vS7WBxkVdMIW1l0j7Sa8DI/kJoYLGoEfmZLk93rPaGcuKAD7 mGYJufXyPbDEfJ8uVPhbXAqenfdGVMQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Kirill Tkhai Cc: akpm@linux-foundation.org, vbabka@suse.cz, viro@zeniv.linux.org.uk, brauner@kernel.org, djwong@kernel.org, hughd@google.com, paulmck@kernel.org, muchun.song@linux.dev, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, zhengqi.arch@bytedance.com, david@fromorbit.com Subject: Re: [PATCH v2 3/3] fs: Use delayed shrinker unregistration Message-ID: References: <168599103578.70911.9402374667983518835.stgit@pro.pro> <168599180526.70911.14606767590861123431.stgit@pro.pro> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <168599180526.70911.14606767590861123431.stgit@pro.pro> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 05, 2023 at 10:03:25PM +0300, Kirill Tkhai wrote: > Kernel test robot reports -88.8% regression in stress-ng.ramfs.ops_per_sec > test case caused by commit: f95bdb700bc6 ("mm: vmscan: make global slab > shrink lockless"). Qi Zheng investigated that the reason is in long SRCU's > synchronize_srcu() occuring in unregister_shrinker(). > > This patch fixes the problem by using new unregistration interfaces, > which split unregister_shrinker() in two parts. First part actually only > notifies shrinker subsystem about the fact of unregistration and it prevents > future shrinker methods calls. The second part completes the unregistration > and it insures, that struct shrinker is not used during shrinker chain > iteration anymore, so shrinker memory may be freed. Since the long second > part is called from delayed work asynchronously, it hides synchronize_srcu() > delay from a user. > > Signed-off-by: Kirill Tkhai > --- > fs/super.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/super.c b/fs/super.c > index 8d8d68799b34..f3e4f205ec79 100644 > --- a/fs/super.c > +++ b/fs/super.c > @@ -159,6 +159,7 @@ static void destroy_super_work(struct work_struct *work) > destroy_work); > int i; > > + unregister_shrinker_delayed_finalize(&s->s_shrink); > for (i = 0; i < SB_FREEZE_LEVELS; i++) > percpu_free_rwsem(&s->s_writers.rw_sem[i]); > kfree(s); > @@ -327,7 +328,7 @@ void deactivate_locked_super(struct super_block *s) > { > struct file_system_type *fs = s->s_type; > if (atomic_dec_and_test(&s->s_active)) { > - unregister_shrinker(&s->s_shrink); > + unregister_shrinker_delayed_initiate(&s->s_shrink); Hm, it makes the API more complex and easier to mess with. Like what will happen if the second part is never called? Or it's called without the first part being called first? Isn't it possible to hide it from a user and call the second part from a work context automatically? Thanks!