Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6042160rwd; Mon, 5 Jun 2023 12:05:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4GfzXq3fYBUH2t5KmVKS9AUrKI4MI9l4/h5tfO5/lQFnIQcfOo0qFBplA87tlxcd9ldyl9 X-Received: by 2002:a05:620a:4c89:b0:75e:b9e3:600 with SMTP id to9-20020a05620a4c8900b0075eb9e30600mr672579qkn.6.1685991915329; Mon, 05 Jun 2023 12:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685991915; cv=none; d=google.com; s=arc-20160816; b=DfF/I9bkSziq/wKSp3FXTqggt3Eki3assm0njRHl1L8J4Hasynj543/MPGTAE9Trcs 4WNyqztJuccMtJhbkmQC387VXugOPNKUFuqEuXgRWaHoyEcoD2a9ZM0zS2WcEO+HHRCv s5egRY8RTnDk/ClX9t8UklVW33e0DqnbFZbPUS/LkdWxpyoKp9t4107IwavgKXJSOoBs Ycig350EN8x3yCS6HHymg0CByAM0xMfzfQVur7x709rJWqc5lSTnoIoj/ze0aZSO6TCZ pQdOEG8rwesrVd2c7g/nWHm2GUrFjKt9LeG8mAWyiS3+mNRwumUfQlKBgobOhBBc7tDm gHpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=MEigQzDY74Nvn1JaDAKnEZHd5i4CDwKJ3Ad6AHXfzeY=; b=kc06wApw462HXClEAD7ZLSOXF5Yb0Jvnx0XucILLkS6SHiO856omZ3ZdKYwm49syZ4 TwR+ZoSi9wX7KPYAYfTJ8e/pA7hF9vTK6Ln4//U0ocplLNzYETLHEflGkluD02y4uVYt zN9+quCFkkFDE+Zjaddmz5EP/FzU6VUPOM+SJih2z+dJnYC/M2ET18GbwkLQHZk7oc8u pUuPPw6LE7y/1HLuzeyVa6zxCrz24umlK61JD0yDEQtzYC2aUMocJOtQh/DS4iG5p7Pv WBZkffHfriDRupKWB1clqzsUoKTNsLMB+7KJY+MoUPsxijnUQxGWc462swho3/uFMgno /4BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ya.ru header.s=mail header.b=nku73zf1; 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=ya.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y23-20020a37e317000000b0075b1c871b8bsi4922200qki.284.2023.06.05.12.04.42; Mon, 05 Jun 2023 12:05:15 -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=@ya.ru header.s=mail header.b=nku73zf1; 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=ya.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233775AbjFETDt (ORCPT + 99 others); Mon, 5 Jun 2023 15:03:49 -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: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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); fs->kill_sb(s); /*