From mboxrd@z Thu Jan 1 00:00:00 1970 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 53113CA0EC8 for ; Mon, 11 Sep 2023 22:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239659AbjIKWWy (ORCPT ); Mon, 11 Sep 2023 18:22:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244535AbjIKUkT (ORCPT ); Mon, 11 Sep 2023 16:40:19 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F489127 for ; Mon, 11 Sep 2023 13:40:14 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1003DC433C8; Mon, 11 Sep 2023 20:40:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1694464814; bh=OuibBkfb7o4FVexOCFORFLBFA7mwYEeMnR499zTdQSc=; h=Date:To:From:Subject:From; b=bWVVfKiDGUJ0VtDdyYepEA3y3l6uMA9Phbtek4VJ8080Zm1kOAYbBfyjliw8Xvjev JDbOVh1KeMBnnPzIjhKd1Kzp42RUCWBle2s4v94XPiVrXFQGUiqOTDO4Z1pG/7EWDq XW/266KJEMjNc34a2R/7si0hirsIqUykojau8DU0= Date: Mon, 11 Sep 2023 13:40:13 -0700 To: mm-commits@vger.kernel.org, xuanzhuo@linux.alibaba.com, viro@zeniv.linux.org.uk, vbabka@suse.cz, tytso@mit.edu, tvrtko.ursulin@linux.intel.com, trond.myklebust@hammerspace.com, tom@talpey.com, tomeu.vizoso@collabora.com, tkhai@ya.ru, tglx@linutronix.de, steven.price@arm.com, sstabellini@kernel.org, songmuchun@bytedance.com, song@kernel.org, snitzer@kernel.org, senozhatsky@chromium.org, sean@poorly.run, rpeterso@redhat.com, roman.gushchin@linux.dev, rodrigo.vivi@intel.com, robh@kernel.org, robdclark@gmail.com, richard@nod.at, ray.huang@amd.com, quic_abhinavk@quicinc.com, paulmck@kernel.org, oleksandr_tyshchenko@epam.com, neilb@suse.de, namit@vmware.com, muchun.song@linux.dev, mst@redhat.com, mingo@redhat.com, minchan@kernel.org, marijn.suijten@somainline.org, kolga@netapp.com, kent.overstreet@gmail.com, josef@toxicpanda.com, joonas.lahtinen@linux.intel.com, joel@joelfernandes.org, jlayton@kernel.org, jgross@suse.com, jefflexu@linux.alibaba.com, jasowang@redhat.com, jani.nikula@linux.intel.com, jaegeuk@kernel.org, jack@suse.cz, huyue2@coolpad.com, hsiangkao@linux.alibaba.com, gregkh@linuxfoundation.org, dsterba@suse.com, dmitry.baryshkov@linaro.org, djwong@kernel.org, david@redhat.com, david@fromorbit.com, dave.hansen@linux.intel.com, daniel.vetter@ffwll.ch, daniel@ffwll.ch, Dai.Ngo@oracle.com, colyli@suse.de, cmllamas@google.com, clm@fb.com, christian.koenig@amd.com, chao@kernel.org, chandan.babu@oracle.com, cel@kernel.org, brauner@kernel.org, bp@alien8.de, arnd@arndb.de, anna@kernel.org, alyssa.rosenzweig@collabora.com, airlied@gmail.com, agruenba@redhat.com, agk@redhat.com, adilger.kernel@dilger.ca, zhengqi.arch@bytedance.com, akpm@linux-foundation.org From: Andrew Morton Subject: + xfs-dynamically-allocate-the-xfs-qm-shrinker.patch added to mm-unstable branch Message-Id: <20230911204014.1003DC433C8@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: xfs: dynamically allocate the xfs-qm shrinker has been added to the -mm mm-unstable branch. Its filename is xfs-dynamically-allocate-the-xfs-qm-shrinker.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/xfs-dynamically-allocate-the-xfs-qm-shrinker.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Qi Zheng Subject: xfs: dynamically allocate the xfs-qm shrinker Date: Mon, 11 Sep 2023 17:44:35 +0800 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. Link: https://lkml.kernel.org/r/20230911094444.68966-37-zhengqi.arch@bytedance.com Signed-off-by: Qi Zheng Reviewed-by: Muchun Song Cc: Chandan Babu R Cc: "Darrick J. Wong" Cc: Abhinav Kumar Cc: Alasdair Kergon Cc: Alexander Viro Cc: Alyssa Rosenzweig Cc: Andreas Dilger Cc: Andreas Gruenbacher Cc: Anna Schumaker Cc: Arnd Bergmann Cc: Bob Peterson Cc: Borislav Petkov Cc: Carlos Llamas Cc: Chao Yu Cc: Chris Mason Cc: Christian Brauner Cc: Christian Koenig Cc: Chuck Lever Cc: Coly Li Cc: Dai Ngo Cc: Daniel Vetter Cc: Daniel Vetter Cc: Dave Chinner Cc: Dave Hansen Cc: David Airlie Cc: David Hildenbrand Cc: David Sterba Cc: Dmitry Baryshkov Cc: Gao Xiang Cc: Greg Kroah-Hartman Cc: Huang Rui Cc: Ingo Molnar Cc: Jaegeuk Kim Cc: Jani Nikula Cc: Jan Kara Cc: Jason Wang Cc: Jeff Layton Cc: Jeffle Xu Cc: Joel Fernandes (Google) Cc: Joonas Lahtinen Cc: Josef Bacik Cc: Juergen Gross Cc: Kent Overstreet Cc: Kirill Tkhai Cc: Marijn Suijten Cc: "Michael S. Tsirkin" Cc: Mike Snitzer Cc: Minchan Kim Cc: Muchun Song Cc: Nadav Amit Cc: Neil Brown Cc: Oleksandr Tyshchenko Cc: Olga Kornievskaia Cc: Paul E. McKenney Cc: Richard Weinberger Cc: Rob Clark Cc: Rob Herring Cc: Rodrigo Vivi Cc: Roman Gushchin Cc: Sean Paul Cc: Sergey Senozhatsky Cc: Song Liu Cc: Stefano Stabellini Cc: Steven Price Cc: "Theodore Ts'o" Cc: Thomas Gleixner Cc: Tomeu Vizoso Cc: Tom Talpey Cc: Trond Myklebust Cc: Tvrtko Ursulin Cc: Vlastimil Babka Cc: Xuan Zhuo Cc: Yue Hu Signed-off-by: Andrew Morton --- fs/xfs/xfs_qm.c | 27 ++++++++++++++------------- fs/xfs/xfs_qm.h | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) --- a/fs/xfs/xfs_qm.c~xfs-dynamically-allocate-the-xfs-qm-shrinker +++ a/fs/xfs/xfs_qm.c @@ -504,8 +504,7 @@ xfs_qm_shrink_scan( struct shrinker *shrink, struct shrink_control *sc) { - struct xfs_quotainfo *qi = container_of(shrink, - struct xfs_quotainfo, qi_shrinker); + struct xfs_quotainfo *qi = 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 = container_of(shrink, - struct xfs_quotainfo, qi_shrinker); + struct xfs_quotainfo *qi = shrink->private_data; 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); - qinf->qi_shrinker.count_objects = xfs_qm_shrink_count; - qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan; - qinf->qi_shrinker.seeks = DEFAULT_SEEKS; - qinf->qi_shrinker.flags = SHRINKER_NUMA_AWARE; - - error = register_shrinker(&qinf->qi_shrinker, "xfs-qm:%s", - mp->m_super->s_id); - if (error) + qinf->qi_shrinker = shrinker_alloc(SHRINKER_NUMA_AWARE, "xfs-qm:%s", + mp->m_super->s_id); + if (!qinf->qi_shrinker) { + error = -ENOMEM; goto out_free_inos; + } + + qinf->qi_shrinker->count_objects = xfs_qm_shrink_count; + qinf->qi_shrinker->scan_objects = xfs_qm_shrink_scan; + qinf->qi_shrinker->private_data = qinf; + + shrinker_register(qinf->qi_shrinker); return 0; @@ -718,7 +719,7 @@ xfs_qm_destroy_quotainfo( qi = mp->m_quotainfo; ASSERT(qi != NULL); - 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); --- a/fs/xfs/xfs_qm.h~xfs-dynamically-allocate-the-xfs-qm-shrinker +++ a/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; /* Minimum and maximum quota expiration timestamp values. */ time64_t qi_expiry_min; _ Patches currently in -mm which might be from zhengqi.arch@bytedance.com are mm-move-some-shrinker-related-function-declarations-to-mm-internalh.patch mm-vmscan-move-shrinker-related-code-into-a-separate-file.patch mm-shrinker-remove-redundant-shrinker_rwsem-in-debugfs-operations.patch drm-ttm-introduce-pool_shrink_rwsem.patch mm-shrinker-add-infrastructure-for-dynamically-allocating-shrinker.patch kvm-mmu-dynamically-allocate-the-x86-mmu-shrinker.patch binder-dynamically-allocate-the-android-binder-shrinker.patch drm-ttm-dynamically-allocate-the-drm-ttm_pool-shrinker.patch xenbus-backend-dynamically-allocate-the-xen-backend-shrinker.patch erofs-dynamically-allocate-the-erofs-shrinker.patch f2fs-dynamically-allocate-the-f2fs-shrinker.patch gfs2-dynamically-allocate-the-gfs2-glock-shrinker.patch gfs2-dynamically-allocate-the-gfs2-qd-shrinker.patch nfsv42-dynamically-allocate-the-nfs-xattr-shrinkers.patch nfs-dynamically-allocate-the-nfs-acl-shrinker.patch nfsd-dynamically-allocate-the-nfsd-filecache-shrinker.patch quota-dynamically-allocate-the-dquota-cache-shrinker.patch ubifs-dynamically-allocate-the-ubifs-slab-shrinker.patch rcu-dynamically-allocate-the-rcu-lazy-shrinker.patch rcu-dynamically-allocate-the-rcu-kfree-shrinker.patch mm-thp-dynamically-allocate-the-thp-related-shrinkers.patch sunrpc-dynamically-allocate-the-sunrpc_cred-shrinker.patch mm-workingset-dynamically-allocate-the-mm-shadow-shrinker.patch drm-i915-dynamically-allocate-the-i915_gem_mm-shrinker.patch drm-msm-dynamically-allocate-the-drm-msm_gem-shrinker.patch drm-panfrost-dynamically-allocate-the-drm-panfrost-shrinker.patch dm-dynamically-allocate-the-dm-bufio-shrinker.patch dm-zoned-dynamically-allocate-the-dm-zoned-meta-shrinker.patch md-raid5-dynamically-allocate-the-md-raid5-shrinker.patch bcache-dynamically-allocate-the-md-bcache-shrinker.patch vmw_balloon-dynamically-allocate-the-vmw-balloon-shrinker.patch virtio_balloon-dynamically-allocate-the-virtio-balloon-shrinker.patch mbcache-dynamically-allocate-the-mbcache-shrinker.patch ext4-dynamically-allocate-the-ext4-es-shrinker.patch jbd2ext4-dynamically-allocate-the-jbd2-journal-shrinker.patch nfsd-dynamically-allocate-the-nfsd-client-shrinker.patch nfsd-dynamically-allocate-the-nfsd-reply-shrinker.patch xfs-dynamically-allocate-the-xfs-buf-shrinker.patch xfs-dynamically-allocate-the-xfs-inodegc-shrinker.patch xfs-dynamically-allocate-the-xfs-qm-shrinker.patch zsmalloc-dynamically-allocate-the-mm-zspool-shrinker.patch fs-super-dynamically-allocate-the-s_shrink.patch mm-shrinker-remove-old-apis.patch mm-shrinker-add-a-secondary-array-for-shrinker_info-map-nr_deferred.patch mm-shrinker-rename-preallocunregister_memcg_shrinker-to-shrinker_memcg_allocremove.patch mm-shrinker-make-global-slab-shrink-lockless.patch mm-shrinker-make-memcg-slab-shrink-lockless.patch mm-shrinker-hold-write-lock-to-reparent-shrinker-nr_deferred.patch mm-shrinker-convert-shrinker_rwsem-to-mutex.patch