From nobody Mon Feb 9 19:26:17 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 582C2C77B73 for ; Mon, 5 Jun 2023 19:03:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234087AbjFETDv (ORCPT ); Mon, 5 Jun 2023 15:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234301AbjFETDh (ORCPT ); Mon, 5 Jun 2023 15:03:37 -0400 Received: from forward102b.mail.yandex.net (forward102b.mail.yandex.net [178.154.239.149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1435110B for ; Mon, 5 Jun 2023 12:03:34 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-33.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-33.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:7c8d:0:640:daf4:0]) by forward102b.mail.yandex.net (Yandex) with ESMTP id 7088560037; Mon, 5 Jun 2023 22:03:31 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-33.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id P3Y5PY6DbSw0-D03FsbaO; Mon, 05 Jun 2023 22:03:30 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ya.ru; s=mail; t=1685991810; bh=MEigQzDY74Nvn1JaDAKnEZHd5i4CDwKJ3Ad6AHXfzeY=; h=In-Reply-To:Message-Id:References:Date:Subject:To:From; b=nku73zf1DQChaO49JXDE6MZ6i2mQGvLbi+bBUqJu+M4OnrmerRoH+8GLIIlD2BtYk Lf0Cl3rp5rYLS6m/8g/rhZOY/fpBJI5utQRJhIvdaUPH+qQyix5BtbHC8GP3T/LS+r K4Gj7k0LH642cC+bqZ6rQWO6ULwPjnkJd/QHfnAw= Authentication-Results: mail-nwsmtp-smtp-production-main-33.iva.yp-c.yandex.net; dkim=pass header.i=@ya.ru From: Kirill Tkhai To: akpm@linux-foundation.org, tkhai@ya.ru, roman.gushchin@linux.dev, 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: [PATCH v2 3/3] fs: Use delayed shrinker unregistration Date: Mon, 5 Jun 2023 22:03:25 +0300 Message-Id: <168599180526.70911.14606767590861123431.stgit@pro.pro> X-Mailer: git-send-email 2.40.1 In-Reply-To: <168599103578.70911.9402374667983518835.stgit@pro.pro> References: <168599103578.70911.9402374667983518835.stgit@pro.pro> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; =20 + unregister_shrinker_delayed_finalize(&s->s_shrink); for (i =3D 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 =3D s->s_type; if (atomic_dec_and_test(&s->s_active)) { - unregister_shrinker(&s->s_shrink); + unregister_shrinker_delayed_initiate(&s->s_shrink); fs->kill_sb(s); =20 /*