Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10596679rwd; Thu, 22 Jun 2023 02:03:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6x4rkd5jyEep8AjJhR2HhjM/i2UhTuUmBzqRlZBz1ss3PuDszMRD5sg+IsEHwAnQdC4vw2 X-Received: by 2002:a05:6a20:12d1:b0:10c:6b27:6415 with SMTP id v17-20020a056a2012d100b0010c6b276415mr8501433pzg.8.1687424583318; Thu, 22 Jun 2023 02:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687424583; cv=none; d=google.com; s=arc-20160816; b=von1+0LShB4NU1Wp3AWT6vF5Wtph4frMKPqN1iZ/CuMJ13oNrwQUGC+iSCRXq6GrtX LNKIQgzIgqvweS+KUbKjysYmrdqlIamB+lndcgLMocTRfKyfeiFlhVDye9a9s5mJMErc yMLOQZdknBpRnd5SuQEtOEDJVxJQFOjs1dhWy5vbP6TpobAMulo8nqE+QaaYkAVLsoJ8 9jFe7Z4Ig+bjrgxfPX5o7cXcHaEmjH907hlZkSMcOtEd7ADhY/b/xpAdJqVTnSuKwgfx ETaRP9qhr83uRmqn8PX59WOKTuAPLAGtYGdEcK3zrLmQsAxpqQFcXmqn6+LZEYdNfSKQ F0pQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tuTRU39Llc4f1pG+4j4EE0WoT0ftJSPXyoG6lJxyplk=; b=ojdgo7DhGCNcfkVi7U/xzZJtezmgahsRI7DwslmLRc0BVGPfUhNb0Sk2hC2EPOJ8RH wAW1bSqcI7H29fOJcZIQZE2JjMbL2rootYYc6JesPVloqXvJ6T3mEnjQCpD7D/8SBQep q7dRPR1m2uFlFtUTaoCoQ8G6+veBztUhu5YSTdEJMwRl6IFlQSTy0RtV92fH8numZN1g lj4zvWidJJnbcdpJmFY1N5KnsCQ6/cmgFqxi6+UNhkf0FJr3fbv/RcHQnIP4QbYCxCEY 3q4gKs9ygd04uFMDo1fBv1XTXxM2KLMLniiiHaio2GGbjIoM3Aukfw/FqWlKnlQp5Drq T3DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="Ekn/zV8B"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 y4-20020a63ad44000000b0053fb85dd81asi6171853pgo.325.2023.06.22.02.02.49; Thu, 22 Jun 2023 02:03:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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="Ekn/zV8B"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 S231855AbjFVJCa (ORCPT + 99 others); Thu, 22 Jun 2023 05:02:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231678AbjFVJBi (ORCPT ); Thu, 22 Jun 2023 05:01:38 -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 72868420A for ; Thu, 22 Jun 2023 01:57:03 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-51f64817809so680152a12.1 for ; Thu, 22 Jun 2023 01:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687424196; x=1690016196; 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=tuTRU39Llc4f1pG+4j4EE0WoT0ftJSPXyoG6lJxyplk=; b=Ekn/zV8B3Pykd2GrPoTdVnpJwk5evd2tyUP0vKsA0sao3e0fC5CJiY4BTrhaxMXIHV uTPkEPgehKIEn13/c91Rf6hAUh1pL4moe2PR0AHRF6Kdv1EoYZyskenz8RKeyckC9Itb y+HACd1zVUdu9ru2Mkg+skG1k3PTY0I37XiwGKuN4fZctDPgzdbV+AVCjywsN0HsaZ69 Cuv8lvpq3tEmZe+xhsg7ur6ivxEYcTfKMKXUZmg3vRSFd562H9J1GbGm5bH6oFZpkxLe LAGfy+lFWFcKu0xxXlVXi22gjm4qtT4oNXfdGZLZ8KWmVvCWym8e4Apiabz+y3j9a60o NyUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687424196; x=1690016196; 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=tuTRU39Llc4f1pG+4j4EE0WoT0ftJSPXyoG6lJxyplk=; b=hRIZozWeyUeXbLXbUVWVZ+G5imVzi77kDFbR5xf3yMbrIczvhavVcDkQFDr+yUlLJ2 PBtyrDqcUEGqQezm7SmKcorr5PNAnh4hVvwNg4/NQHVZtEjithC1FjsPeSVMwN06Dp3/ DUU98YD6AnT6tJ1PdZD+Eei/QNVzZ72nvraoUIaXQgmOwhbVQit5EV+5hHOxq5b9dB1C yCA9Yr19+HmHng4w3Quef2ZOD0NT9Ut5YCVyB0zs9moOyH/yM97o/WQQBqgclG5k6QI1 tCC/3htO5HI5W7kw8HNhL3U/uqXWqu4PRb0e7qhICN7MwSyg78AmNuF4uD9NNSWz4bnP bJ/w== X-Gm-Message-State: AC+VfDwKECFSOOoCiBRy+q9rMDa0lY3BCX85COvVu88rTwN9BrDCYRZI fPSEdXdfnsLKdeIdWN3Fop3KOAvYnM8BwNmwQI8= X-Received: by 2002:a17:902:ecc6:b0:1ae:1364:6086 with SMTP id a6-20020a170902ecc600b001ae13646086mr21603647plh.2.1687424195747; Thu, 22 Jun 2023 01:56:35 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id h2-20020a170902f7c200b001b549fce345sm4806971plw.230.2023.06.22.01.56.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 01:56:35 -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 Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, intel-gfx@lists.freedesktop.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-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, Qi Zheng Subject: [PATCH 19/29] xfs: dynamically allocate the xfs-qm shrinker Date: Thu, 22 Jun 2023 16:53:25 +0800 Message-Id: <20230622085335.77010-20-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230622085335.77010-1-zhengqi.arch@bytedance.com> References: <20230622085335.77010-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 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,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-ext4@vger.kernel.org In preparation for implementing lockless slab shrink, we need 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 --- fs/xfs/xfs_qm.c | 24 +++++++++++++----------- fs/xfs/xfs_qm.h | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 6abcc34fafd8..b15320d469cc 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,18 +678,22 @@ 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; + qinf->qi_shrinker = shrinker_alloc_and_init(xfs_qm_shrink_count, + xfs_qm_shrink_scan, + 0, DEFAULT_SEEKS, + SHRINKER_NUMA_AWARE, qinf); + if (!qinf->qi_shrinker) + goto out_free_inos; - error = register_shrinker(&qinf->qi_shrinker, "xfs-qm:%s", + error = register_shrinker(qinf->qi_shrinker, "xfs-qm:%s", mp->m_super->s_id); if (error) - goto out_free_inos; + goto out_shrinker; return 0; +out_shrinker: + shrinker_free(qinf->qi_shrinker); out_free_inos: mutex_destroy(&qinf->qi_quotaofflock); mutex_destroy(&qinf->qi_tree_lock); @@ -718,7 +720,7 @@ xfs_qm_destroy_quotainfo( qi = mp->m_quotainfo; ASSERT(qi != NULL); - unregister_shrinker(&qi->qi_shrinker); + unregister_and_free_shrinker(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; -- 2.30.2