From nobody Thu Sep 11 22:30:54 2025 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 136B8CA0EC8 for ; Mon, 11 Sep 2023 22:35:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377483AbjIKW0f (ORCPT ); Mon, 11 Sep 2023 18:26:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236112AbjIKJvE (ORCPT ); Mon, 11 Sep 2023 05:51:04 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7599116 for ; Mon, 11 Sep 2023 02:50:39 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1befe39630bso9370135ad.0 for ; Mon, 11 Sep 2023 02:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1694425839; x=1695030639; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aAoYQHmeR0aUipRnti9MSoo1QhYW8B305NLCegCj2mc=; b=fYk8n2ptg0Wx/+gpfRqceuJRmPy8mShZYDOSwno63oFF19RCniY4YaZfgJPoRB25iH OUsYIURU035J1A4dSFr7qhi0yMhSs7acetZSXSDdCbaU1U7cTwt1GP3XP7nehU0HoF7a V18H46a1GpD6ST1judHIZNNhslbnDTdZaTWYEIBQo0RsMlqV3U5V82eappmxZVkjJVL2 Dv5Jd9O7q6/qg26GrxcTa0qvNQuxws2Pj+sXnkJm6SAyDMiMDLZr+tktgZ7m+mlE5gGi DfviBqjSDUmc8keyC9h+JqSfjuA2onmjNjic0z2zTBSSqArCJfWDkAnc0FThKJHpl5Lj bocg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694425839; x=1695030639; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aAoYQHmeR0aUipRnti9MSoo1QhYW8B305NLCegCj2mc=; b=dYw9C6BX2Dl/ugI/LL3glRxOEaRqc4i+ktms6EfDINrQt7WVfndkdH6LYUsBF73v+R vcEoO4RYc/UCrh94WI6OfxGcnNBJnQCuGAzzx3bekHRGUB/EEjt7z5BDRRmM2Oe/SlTO NksEC+IcRMnCfuY9h40XO1YcI+7l3z1VNMje+ZJSDuxW+5ErCBN2VYRkcFZRiQqHhqdw vlRHZHOYK/RnU2Mw9HTX/M6G+NWkCHVmjpGfnOCQ8eroynleWgZ6fZ4pMvQh6NSvJd36 DOG23cVunlxiLnknza7VdsldIucgx3CL0GaZ0bRStTIPL6usbm4dsQymK3VaaU+mJWQJ bLgQ== X-Gm-Message-State: AOJu0Yy/+qSP1hvnakSSg5KjWK5Nt87cBabNYidGT/JirkwfAnHBaaHG KgprYAZxExxE+wdLnOFn3LQ5BQ== X-Google-Smtp-Source: AGHT+IFT+86I6bu5GOdEzWlfUK8qBkCzz3enuPKZPjEpOf5YfG0XONb6VNSqG6hacK72QD8znouzTg== X-Received: by 2002:a17:903:2843:b0:1c3:a4f2:7cc1 with SMTP id kq3-20020a170903284300b001c3a4f27cc1mr5320660plb.5.1694425839278; Mon, 11 Sep 2023 02:50:39 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id az7-20020a170902a58700b001bdc2fdcf7esm5988188plb.129.2023.09.11.02.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 02:50:38 -0700 (PDT) From: Qi Zheng To: akpm@linux-foundation.org, david@fromorbit.com, tkhai@ya.ru, vbabka@suse.cz, roman.gushchin@linux.dev, djwong@kernel.org, brauner@kernel.org, paulmck@kernel.org, tytso@mit.edu, steven.price@arm.com, cel@kernel.org, senozhatsky@chromium.org, yujie.liu@intel.com, gregkh@linuxfoundation.org, muchun.song@linux.dev Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Qi Zheng , Muchun Song , Chandan Babu R , linux-xfs@vger.kernel.org Subject: [PATCH v6 36/45] xfs: dynamically allocate the xfs-qm shrinker Date: Mon, 11 Sep 2023 17:44:35 +0800 Message-Id: <20230911094444.68966-37-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230911094444.68966-1-zhengqi.arch@bytedance.com> References: <20230911094444.68966-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In preparation for implementing lockless slab shrink, use new APIs to dynamically allocate the xfs-qm shrinker, so that it can be freed asynchronously via RCU. Then it doesn't need to wait for RCU read-side critical section when releasing the struct xfs_quotainfo. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song CC: Chandan Babu R CC: "Darrick J. Wong" CC: linux-xfs@vger.kernel.org --- fs/xfs/xfs_qm.c | 27 ++++++++++++++------------- fs/xfs/xfs_qm.h | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 6abcc34fafd8..f45de01013ba 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -504,8 +504,7 @@ xfs_qm_shrink_scan( struct shrinker *shrink, struct shrink_control *sc) { - struct xfs_quotainfo *qi =3D container_of(shrink, - struct xfs_quotainfo, qi_shrinker); + struct xfs_quotainfo *qi =3D shrink->private_data; struct xfs_qm_isolate isol; unsigned long freed; int error; @@ -539,8 +538,7 @@ xfs_qm_shrink_count( struct shrinker *shrink, struct shrink_control *sc) { - struct xfs_quotainfo *qi =3D container_of(shrink, - struct xfs_quotainfo, qi_shrinker); + struct xfs_quotainfo *qi =3D shrink->private_data; =20 return list_lru_shrink_count(&qi->qi_lru, sc); } @@ -680,15 +678,18 @@ xfs_qm_init_quotainfo( if (XFS_IS_PQUOTA_ON(mp)) xfs_qm_set_defquota(mp, XFS_DQTYPE_PROJ, qinf); =20 - qinf->qi_shrinker.count_objects =3D xfs_qm_shrink_count; - qinf->qi_shrinker.scan_objects =3D xfs_qm_shrink_scan; - qinf->qi_shrinker.seeks =3D DEFAULT_SEEKS; - qinf->qi_shrinker.flags =3D SHRINKER_NUMA_AWARE; - - error =3D register_shrinker(&qinf->qi_shrinker, "xfs-qm:%s", - mp->m_super->s_id); - if (error) + qinf->qi_shrinker =3D shrinker_alloc(SHRINKER_NUMA_AWARE, "xfs-qm:%s", + mp->m_super->s_id); + if (!qinf->qi_shrinker) { + error =3D -ENOMEM; goto out_free_inos; + } + + qinf->qi_shrinker->count_objects =3D xfs_qm_shrink_count; + qinf->qi_shrinker->scan_objects =3D xfs_qm_shrink_scan; + qinf->qi_shrinker->private_data =3D qinf; + + shrinker_register(qinf->qi_shrinker); =20 return 0; =20 @@ -718,7 +719,7 @@ xfs_qm_destroy_quotainfo( qi =3D mp->m_quotainfo; ASSERT(qi !=3D NULL); =20 - unregister_shrinker(&qi->qi_shrinker); + shrinker_free(qi->qi_shrinker); list_lru_destroy(&qi->qi_lru); xfs_qm_destroy_quotainos(qi); mutex_destroy(&qi->qi_tree_lock); diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h index 9683f0457d19..d5c9fc4ba591 100644 --- a/fs/xfs/xfs_qm.h +++ b/fs/xfs/xfs_qm.h @@ -63,7 +63,7 @@ struct xfs_quotainfo { struct xfs_def_quota qi_usr_default; struct xfs_def_quota qi_grp_default; struct xfs_def_quota qi_prj_default; - struct shrinker qi_shrinker; + struct shrinker *qi_shrinker; =20 /* Minimum and maximum quota expiration timestamp values. */ time64_t qi_expiry_min; --=20 2.30.2