Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2145909rwb; Thu, 27 Jul 2023 02:51:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlHMa3+T9Tn9tSIV4X/FsFYCcE2udoMpdQRneA8zqw2jDqyGa/2QYdvJm2h4T5egoGL4U6EL X-Received: by 2002:a17:902:e885:b0:1af:e302:123 with SMTP id w5-20020a170902e88500b001afe3020123mr3157621plg.3.1690451487495; Thu, 27 Jul 2023 02:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690451487; cv=none; d=google.com; s=arc-20160816; b=IKdB6UYF8NtaQr36G1ATxJikqqCFiqSU1sECEu7h0vSu/3oYw4H7ghp1QRsQmROaX1 MiiPYw8+oZST3kZJSrzAA6JVtwx7t+qE2YZmVwy8YzIs2FvRR4fahI8FnbplAKcpCBcg Ibh2yd/W63arDK3hnb2GEbn3hOqj5j87OaS4aZ2qOVifz3MnFunh63jfpf0lrdZNmEKp AmQjd6aa4pn3VqEq7LYHZjNQ9msnySFWnQVX22s/PvI4AQwkBEJIA74tgZIAV204FFZg 9982/1cgd+7FL1ZEqHiARlmRqNK0/1wL5lhIoZW0ZgdInh5ge3Qb1UZzIcGurZZ6siqe j6zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=cb79b5va6gFfSJneJi5lY4rGeRwgOukMupryAUVW6kI=; fh=3ryUVD/wlJuVq1XsjP/SOwrzgei3ER5jfZpUBIrL6r4=; b=aUR3pGaTFKqia7lTl6bk/AUoFup1YcICL9DydKLaQdOXElwCRSJvsYMhPhPmW4uhmC Yvitw8qpMBbxdqu4uDfjUb0qvmcCpBhJ8fsoAYKnK9KtDrTnnJfJlYe4O/uqo3BgFmXR rVkMHR9AvWQzGxBc1iXPxtlpIdKkqgq6MDjpfVxa6l2JOc9zvU6jvRROJpmM74n4/Iek /NCfIKKcPDHJUQGDGCpYawOXwIhiyTIOQFWQF5XzKGM0/dlhcMAiK2Tk62Ifm3rL11GL sMmyhTlBSvzGy7ZsfSgcODHfah/F1A7lMvQhzv/1SlXcurMuAWYZMl7rFbdIIUveQ8HL i4eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=YCWSTu9U; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l17-20020a170902f69100b001b9d926ccdesi1112271plg.576.2023.07.27.02.51.14; Thu, 27 Jul 2023 02:51:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@bytedance.com header.s=google header.b=YCWSTu9U; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234471AbjG0JaP (ORCPT + 99 others); Thu, 27 Jul 2023 05:30:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234094AbjG0J3t (ORCPT ); Thu, 27 Jul 2023 05:29:49 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32B759A9E for ; Thu, 27 Jul 2023 02:20:05 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-55c79b62f3aso52625a12.1 for ; Thu, 27 Jul 2023 02:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690449603; x=1691054403; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=cb79b5va6gFfSJneJi5lY4rGeRwgOukMupryAUVW6kI=; b=YCWSTu9U7oWMIxlz666y2QG523oA3QX5qQv7ZytrRVu6fJw8dRHyUfgDIT1gU69FG8 THUguZfsi1KeJApNPmw0jxmv7f8KFlV4UTxlH9XbeulHxoa/ldWA269gxLsqPd7fsDUL 3wrs7fjkTjLEvVIuFKVgIWoEr+OE7ZGV4f2QptD03saCT0x1g+4lQFRHQ9ruqft2Rhft lQsKff8YPeqYMpcr6auHVhvyZ4A0b6O2v3t87pxn8FkR9lCy8v/ntqGuUNKm9Zf3rtD1 Pt/WGCyBPHzJX+fw7G8Ac9jWyGkR4LQhg8QoLvoZwbFMr8CqGaDCh/cUGTEJkXif0gLU NqYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690449603; x=1691054403; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cb79b5va6gFfSJneJi5lY4rGeRwgOukMupryAUVW6kI=; b=MwVWZNr+myPiojUiQFSQ1l07Q/c/+W490nGHpmD4vFs2n0dARJR0fgTVubTpttKEsk y4tNxBweOjQ4rTqPCWhHmM8dSH59HbMBqn77rtIm9BkZnDYrwW9LUI/GSz5gk5eP8nqB MOK0X4bkRWDbz93TWtEABUHWdW1bF/HP6nt7RTwqgBTIQ93I8bBq8sqCU6ao1h5XfrRf kb21qYKI/EjUi144qsqEgYjQU1NnWDCoREEZt8vl/q82HZxFEkk04d28HbdI2gW6HEwq wTWNPajYcUSDnRl1FbXpO6WV9siaA598nxCzMMGdjE5arRg5z0dW3J5/n6qalaoPx8hA psMA== X-Gm-Message-State: ABy/qLY+UkVOnF4Ke5lzzLHOWDnZ2RS9S9djd01M2xyQdVlrv67LzZka GlWTfAddWN/EZZ85O8qiSyn8kA== X-Received: by 2002:a17:902:da82:b0:1b8:811:b079 with SMTP id j2-20020a170902da8200b001b80811b079mr5785873plx.0.1690449602958; Thu, 27 Jul 2023 02:20:02 -0700 (PDT) Received: from [10.70.252.135] ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id 5-20020a170902c24500b001bbb7d8fff2sm1109046plg.116.2023.07.27.02.19.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Jul 2023 02:20:02 -0700 (PDT) Message-ID: <5f1b85b8-3655-1700-4d16-fa056b31ceeb@bytedance.com> Date: Thu, 27 Jul 2023 17:19:49 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v3 40/49] xfs: dynamically allocate the xfs-qm shrinker Content-Language: en-US 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, x86@kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, linux-erofs@lists.ozlabs.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nfs@vger.kernel.org, linux-mtd@lists.infradead.org, rcu@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org, linux-bcache@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, Muchun Song References: <20230727080502.77895-1-zhengqi.arch@bytedance.com> <20230727080502.77895-41-zhengqi.arch@bytedance.com> From: Qi Zheng In-Reply-To: <20230727080502.77895-41-zhengqi.arch@bytedance.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-nfs@vger.kernel.org On 2023/7/27 16:04, Qi Zheng wrote: > In preparation for implementing lockless slab shrink, use new APIs to > dynamically allocate the xfs-qm shrinker, so that it can be freed > asynchronously using kfree_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 > --- > fs/xfs/xfs_qm.c | 26 +++++++++++++------------- > fs/xfs/xfs_qm.h | 2 +- > 2 files changed, 14 insertions(+), 14 deletions(-) > > diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c > index 6abcc34fafd8..032f0a208bd2 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 = 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,16 +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) Here should set error to -ENOMEM, will fix. > 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->seeks = DEFAULT_SEEKS; > + qinf->qi_shrinker->private_data = qinf; > + > + shrinker_register(qinf->qi_shrinker); > + > return 0; > > out_free_inos: > @@ -718,7 +718,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); > 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; > > /* Minimum and maximum quota expiration timestamp values. */ > time64_t qi_expiry_min;