From patchwork Mon Sep 11 09:44:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13379067 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 F1B1BEEB57E for ; Mon, 11 Sep 2023 09:47:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 938B66B01F1; Mon, 11 Sep 2023 05:47:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E8576B01F2; Mon, 11 Sep 2023 05:47:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B0A86B01F3; Mon, 11 Sep 2023 05:47:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6BF246B01F1 for ; Mon, 11 Sep 2023 05:47:08 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2D20A40908 for ; Mon, 11 Sep 2023 09:47:08 +0000 (UTC) X-FDA: 81223838136.30.DE333AF Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf14.hostedemail.com (Postfix) with ESMTP id 5462F100018 for ; Mon, 11 Sep 2023 09:47:06 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=W+mw1LUM; spf=pass (imf14.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694425626; 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=X/NLyvMhlfztd4qbZrL/omLXYwwIYQMNFU1MSKt3KHU=; b=LgeSOjP12JazEyEvv20w4rdhEnfMt5Fiz0JklYA+Yu9IpCYFXOpI1iv8bm4qKyWr6CIWN6 KORmuEkGyKFG71/wBLiUJVFSgF9u/lsjwyxEWD8Wblxysy/+HktxAWQljeh8Tha6n4XL/q VfSQjtufumyMIekwM4XNjDOAptWDeG4= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=W+mw1LUM; spf=pass (imf14.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694425626; a=rsa-sha256; cv=none; b=r6D8wthJ7N9frhYJFdLG229Zp7yfanwdb7IeR0EsENd8uDBmEUvBaNbKvopx21tFMnZOfO tDnJ4lyVWBZs9T4FRGrO3zPEOVbVQs+Yl4R+y2EocRt7nEDSPu1Sq+xNzkQ4nNHSIo2Zox H8rK0/tcQHNGdgG3Uc5qckHBavD+XEw= Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-5657ca46a56so444985a12.0 for ; Mon, 11 Sep 2023 02:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1694425625; x=1695030425; darn=kvack.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=X/NLyvMhlfztd4qbZrL/omLXYwwIYQMNFU1MSKt3KHU=; b=W+mw1LUMgDy1qWf2QfRA10of6d1C+9RgSnkVlEfhUDvHKgLc72hZD2jW3oSnXNnWIR AV39WPCdjRQwZMDfJYf0cGQzNSiL8t5CEJANZUt8nPjlJ7Q+cwiH03CJWnJ0k8KL3egY OK/+RAkuyG4WCQBzTql7vBtG+LDDQAsLQIWgWsYNDICtBbTe2S9cbwbm4kQzl5KhIamw XjFi96u/FRnDcKQSSsThl92r58xp7URoNvMNd9eTYbUuRDSxCv3Y8EfffielBQ27KAWG AbKVCzMlGrUUChHXGVxTExEGmjDd2gTVfvznjB/J7+UK1iYxGXBCNn1qypTYIHHxgxo9 599Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694425625; x=1695030425; 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=X/NLyvMhlfztd4qbZrL/omLXYwwIYQMNFU1MSKt3KHU=; b=FxnTxbB37YqEElinaKNOu1TxYOYZkU5RH6V953Neuh6ZZz+NnUq9X79A0zbGd3bR7h 7GuH8CbY4SeD01YTftfT0cgm1VCT+9FXizeM7sY+o/rPcK4ynTy/tOH9YYddZqtj0cW5 QE5Z0ki96a8AtIfcio2gLZw9GrvAcstyZgtpc8coPQFrt8pMQr27g8FgJOnfpaRmVIjb t+6TNQEIoi7tafQi5wcBKzvdml0LdgkJnZX6Bc8Ay3fvzuIvlnUTcthNF7dGw9Xe4d4X zqKqmUf8jaHSNjR47pnJIDTlNroG9QTF+3JCzLQ2mkQySczRNx1+KxdG3pvwKy+yAcHN JOYg== X-Gm-Message-State: AOJu0YzeIdGcqYfq/zgM4sJCxprmS+Uwq9BTLSGPXuY2oNyzO+SAPf6f qOEosDKr8s+2oi2hgQgIGIPB2A== X-Google-Smtp-Source: AGHT+IGDEIcfsclwcXdbuDvH8sZ7NfMus7y6m3aPNdiNFM1+TgiFCKX9tglqgiD/ZZx6tB1zl6Vfxw== X-Received: by 2002:a05:6a21:a587:b0:123:3ec2:360d with SMTP id gd7-20020a056a21a58700b001233ec2360dmr13693947pzc.5.1694425625285; Mon, 11 Sep 2023 02:47:05 -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.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 02:47:04 -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 v6 13/45] quota: dynamically allocate the dquota-cache shrinker Date: Mon, 11 Sep 2023 17:44:12 +0800 Message-Id: <20230911094444.68966-14-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 X-Rspamd-Queue-Id: 5462F100018 X-Rspam-User: X-Stat-Signature: 9pppb1qxf193q9rc4ptbsdn35pke3pf6 X-Rspamd-Server: rspam01 X-HE-Tag: 1694425626-415521 X-HE-Meta: U2FsdGVkX182FgkSFhZcF5vCp91RHp8n9kWGM0bbTlgD1xxDt14zHddr8obGIA0p6ZN+BjiBFZ5uSH5U16LeOYNiMIxqNkmwausfXlFfQb2xFrnVr8MPnoeEmJzhnx7RAGjxRmSeQIYKl0NBIacWmyKWJq2y0iFfXrty8EmuDGYHU+QMQ5J/piOR8y3V4Q9EKkXsf8uh6qQA477ra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G2w6CEH4B71E8dARZl7huNlgnpqMK3yTGquYloHE5w3oFBhfvwf2Rd01G565+gimHmCEA1vVjEFrSPDVVfT47tEyMOt6+f/erBAVwTIxGdvbhoSMTkJ 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 Acked-by: Jan Kara --- fs/quota/dquot.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 9e72bfe8bbad..15030b0cd1c8 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,14 @@ 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; + + shrinker_register(dqcache_shrinker); return 0; }