From patchwork Thu Aug 24 03:42:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13363446 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCC6CC71145 for ; Thu, 24 Aug 2023 03:45:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6964A280085; Wed, 23 Aug 2023 23:45:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6471F8E0011; Wed, 23 Aug 2023 23:45:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50F19280085; Wed, 23 Aug 2023 23:45:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 407A38E0011 for ; Wed, 23 Aug 2023 23:45:46 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 19191A01AB for ; Thu, 24 Aug 2023 03:45:46 +0000 (UTC) X-FDA: 81157609092.25.47C7973 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf10.hostedemail.com (Postfix) with ESMTP id 434C6C0006 for ; Thu, 24 Aug 2023 03:45:44 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=LgRdO1Fr; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692848744; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jemklUFFCXuSkFimtib823G6Ct+c21vKLbvuJ2OztTU=; b=v2Ayt7B9Jd7X3KYSvzxBOKr/uVC9HDHmtx5DkcAXJS75LzbmW3pT7hMZJ7zxCkciKU+AO0 6lS5+nHjrtbIzcn1CWgSwL8Xv6Q6DIIta9hYS0AAO4SnvZZJKbhqFfzH4p83eBYOioUHqf QegvoD6q2qJ4iIGlYeb5xup4cLza0mA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=LgRdO1Fr; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692848744; a=rsa-sha256; cv=none; b=CuLKR+85FGko8mElfK0lWEPaKXwDayKgi2yGMO3Mde/ADGlkap/1AR80r7l/72SXi69oLz FlCvJKGe8UEGaUo4SDtOn93MUcMEgCGzgxFxTpOfpvtVTPXjZ6Zfy8JbauCjvEl483n9Om Lll4QNVQDRTqp4hOjD2DF8vUidDJAr8= Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-68824a0e747so1237998b3a.1 for ; Wed, 23 Aug 2023 20:45:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1692848743; x=1693453543; 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=jemklUFFCXuSkFimtib823G6Ct+c21vKLbvuJ2OztTU=; b=LgRdO1FrpQYjfdqKgY7kw9rvoqVC5S1JSj2Ky2tibLl0UkGXBa01sM6tJJtw+HUSpw vVOTPvHxNt/AqID6/gQaE/EJ2lmfNE/O2FmAZf55yMpKB3nOPksaDOXPjXEx/JrJ/a0H 7gzGX2I8Vak7oBpce2JEArh1Aby2I+koavv0vi78GW6RbE0dsrPp96+DvKW7HORmZPSO 5Q5/QNviG9nWkifZ6ozu08jFzQCHMGjACqD/YSaShhiFDDnoKbe9ZymHxmhZSz5LBYKL CQ08NNQGQGVLqg6/kIhSxdlHIrjFXLf/hUuCrGaitNQv+hunrwi58eG4NHlJ6VOTyQNH ZNLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692848743; x=1693453543; 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=jemklUFFCXuSkFimtib823G6Ct+c21vKLbvuJ2OztTU=; b=IsHcuO6cpanUi9D0hG7Fqtt+qdZof6+bcSyN4zmIjxM8Ms2E1rd5BbYjxMUSLzLKlK SzLvxDWPS9GH4RIZbiBV6I5bHOknGYyqfHFffrMZVgHqdEq0m/KBGF8Av1HsfqXQn/Ot NHBLvzXedTAAj59vjIYfltS+tBQ3caMfNiBXyavwdfrAWWfud5Vibkc4vraImuId9vjo 8XR67mnwJRmctDUREEqgYuvdKErdc4A5VRsWNsE8SBHTuUfsBWoQqTjigW48Cu34u3Gx d7F1pT2kPDiZwUy3IwQr/onbIya3KSqqDqHpfr01J2pQAMWF+F+1rOdw9Zef4VWjZWwO jO4Q== X-Gm-Message-State: AOJu0YydXWjJsPG0/12jAI7fNRD8a6+erOI/K1uCSTw+uRynsVjtAUCI nEZoJGDi0EXM7LvqZynMH9hsSA== X-Google-Smtp-Source: AGHT+IH5OwQqnaWM1iDwEtDztgpiT/vGMc3PO1GrsFb4dQKDl+nnRio//nIXOrYlRi+zRRJZJd2wxA== X-Received: by 2002:a05:6a20:a10c:b0:13e:1d49:7249 with SMTP id q12-20020a056a20a10c00b0013e1d497249mr15190972pzk.2.1692848743163; Wed, 23 Aug 2023 20:45:43 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id t6-20020a63b246000000b005579f12a238sm10533157pgo.86.2023.08.23.20.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 20:45:42 -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 , Jan Kara Subject: [PATCH v5 13/45] quota: dynamically allocate the dquota-cache shrinker Date: Thu, 24 Aug 2023 11:42:32 +0800 Message-Id: <20230824034304.37411-14-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230824034304.37411-1-zhengqi.arch@bytedance.com> References: <20230824034304.37411-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: wbrzspb1xkwo7ruhfgsm1qbi5fmtssid X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 434C6C0006 X-HE-Tag: 1692848744-180219 X-HE-Meta: U2FsdGVkX1/+UrR57xdMsufFA/q3yD6Pos+hQ8MJKp+YKuYGqhR+LHGXnfS8cBW0twOmWcfGM3lNziYGJWMHlivYPlkqNUlb57ambas8ODgcSHTNwzkK1qa/GRstvEAGKb8maDY7c0lMDvkQhJDnLVVX/3I2bXoC8vXIvrO8b3gWdbZbY8H+3AQprmknI9g03e4TBqaIayUlie/gFEVuRnjp6fhGZV7dHd6D6I0te5kX/54oh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NqwZeqT/OspIAWvwvnUm+bXCJs10cMTr1G78dLiWKSuIcGJe/34d0l2HGUm6ml/qutja8QAcdd53JdNc+6pPZLAeT4uTIItrki8ZkPbyV76tJuZoUSo6Q/OaB64FSkBd1XMfMFAXZVo1uyJ+AhZyIS291fUjQ38k2gi X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use new APIs to dynamically allocate the dquota-cache shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song CC: Jan Kara Acked-by: Jan Kara --- fs/quota/dquot.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 9e72bfe8bbad..c303cffdf433 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -791,12 +791,6 @@ dqcache_shrink_count(struct shrinker *shrink, struct shrink_control *sc) percpu_counter_read_positive(&dqstats.counter[DQST_FREE_DQUOTS])); } -static struct shrinker dqcache_shrinker = { - .count_objects = dqcache_shrink_count, - .scan_objects = dqcache_shrink_scan, - .seeks = DEFAULT_SEEKS, -}; - /* * Safely release dquot and put reference to dquot. */ @@ -2956,6 +2950,7 @@ static int __init dquot_init(void) { int i, ret; unsigned long nr_hash, order; + struct shrinker *dqcache_shrinker; printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__); @@ -2990,8 +2985,15 @@ static int __init dquot_init(void) pr_info("VFS: Dquot-cache hash table entries: %ld (order %ld," " %ld bytes)\n", nr_hash, order, (PAGE_SIZE << order)); - if (register_shrinker(&dqcache_shrinker, "dquota-cache")) - panic("Cannot register dquot shrinker"); + dqcache_shrinker = shrinker_alloc(0, "dquota-cache"); + if (!dqcache_shrinker) + panic("Cannot allocate dquot shrinker"); + + dqcache_shrinker->count_objects = dqcache_shrink_count; + dqcache_shrinker->scan_objects = dqcache_shrink_scan; + dqcache_shrinker->seeks = DEFAULT_SEEKS; + + shrinker_register(dqcache_shrinker); return 0; }