Message ID | 20230807110936.21819-16-zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 EDF8DC04A6A for <linux-mm@archiver.kernel.org>; Mon, 7 Aug 2023 11:13:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 800156B0078; Mon, 7 Aug 2023 07:13:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B06C6B007B; Mon, 7 Aug 2023 07:13:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6509C8D0002; Mon, 7 Aug 2023 07:13:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5862D6B0078 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 07:13:14 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2B0851A0413 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 11:13:14 +0000 (UTC) X-FDA: 81097047108.19.05081E8 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf05.hostedemail.com (Postfix) with ESMTP id 3DCCE10000C for <linux-mm@kvack.org>; Mon, 7 Aug 2023 11:13:12 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=gvEcin7S; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.169 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=1691406792; 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=urGrhHBCGKwKuhIkQmOHRuysXuy1mToQA+AaHWoY6PY=; b=a7gJ3l2ZuYJrmRR92Zf2jUPMlKtnuNRYqBC4oKRkeGAo2N6sMaQ6POSzKD1LJexb2jp/0w /XTXtXJY5zl3lNXEatMNy6zikc1a5znF5CikHdM4F069MMYENCr4lKpco9TS0MA3ehITTu exaK33tnc9k4FDUn9MeZzAXjLG8KB/8= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=gvEcin7S; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691406792; a=rsa-sha256; cv=none; b=BV9racnRYeS+H3LFl5Qt/s85bkgLP7H81mCBlrc/9cfvzTjVjcGL2FLRfwpbz63Cht1Qzm jqi2jIlO/HWH2L/eE5UsGRuIZ8TbV8J8n9BCYSrj4NA7eaCpips+VHvrn6weRqu7NRX2I+ lgLKo/VUL7xfbu9PJgoHni+l4HmSfWc= Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-55b5a37acb6so362093a12.0 for <linux-mm@kvack.org>; Mon, 07 Aug 2023 04:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691406791; x=1692011591; 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=urGrhHBCGKwKuhIkQmOHRuysXuy1mToQA+AaHWoY6PY=; b=gvEcin7S0wJ5rW0wtj9WnWp/4gO3FOqyEc5Qy3KVjjCOMIdl063r7goatTKMU5K63u IABDDkTZbyMiPq/rwoG72XrgfLWlV6/YJwymkZtRfBVcrDOzJOk+V88T6EEEXGW6nfh0 le0xVwnZY7As0nXjZy+hSjIWRCXvYGRHiEKZrDZnQb7QflVpjM7uq/81aSxj3traKDGt VXa/baYLLxxBhWBawSSBHT4dMsZ/NRoyUnn0XTD8JWz4/O0ULe9Suh4wohOUxiotc5cA +kJEwQbIJfS1Vrk1T3/Loi8TKjO+pow/TrGBcBE2xp4OSLxBFU0bCUPycoGAdA8SsoOk yeOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691406791; x=1692011591; 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=urGrhHBCGKwKuhIkQmOHRuysXuy1mToQA+AaHWoY6PY=; b=KFhz0xp/0s2zr70+3Xxs82aJoqJfWo5uSo8YWy5E1BHYoDce+o/N1n58Y4HcLD104J Tv8R2zl8D3WXD7BNAybhDkw063y723BQs5UisDXG45U4wTslbwmvI82OmyeQ7YrFDO+J Ym8XRGOJvoUZlPAkeHUQQpu7bLJ8UOzcXIfYJsyBR4qy6F6/iV0tDMirW+BgTj9rTzND JnMLIPk4OfwYUYEhu8+RzabJpUgNL+SxMlpSxo3S0K6imzlmT6HTBTKTZ5lpgPUwE5zs 0gh0SV8vvassqJPJyYa4tHDZFM+nbX3DlpNM0xEH+t/wrkdnL5E6ZwyKysLGviDvU6yy Qsxw== X-Gm-Message-State: ABy/qLahF2ISOFbLv0fZHFyMEvQKukX5YMlueY8F68pQnSkhSDXRz3Iu Ovz5eRm4WJo4KoYI5YoBEZSNoQ== X-Google-Smtp-Source: APBJJlGG9fl/KZM7Wu/aB3nA3qPBXzAgCls0ii/X4UboFM2rQSd7zbDq190u8vBbdPOZ8QFUsdy1lw== X-Received: by 2002:a17:90a:faf:b0:268:abc:83d5 with SMTP id 44-20020a17090a0faf00b002680abc83d5mr23478200pjz.4.1691406791204; Mon, 07 Aug 2023 04:13:11 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id y13-20020a17090aca8d00b0025be7b69d73sm5861191pjt.12.2023.08.07.04.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:13:10 -0700 (PDT) From: Qi Zheng <zhengqi.arch@bytedance.com> 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, simon.horman@corigine.com, dlemoal@kernel.org 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, Qi Zheng <zhengqi.arch@bytedance.com>, Muchun Song <songmuchun@bytedance.com> Subject: [PATCH v4 15/48] nfsd: dynamically allocate the nfsd-filecache shrinker Date: Mon, 7 Aug 2023 19:09:03 +0800 Message-Id: <20230807110936.21819-16-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230807110936.21819-1-zhengqi.arch@bytedance.com> References: <20230807110936.21819-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 3DCCE10000C X-Stat-Signature: 54kxj69d7w9xcq7wmm1mqxnnao5ufsma X-Rspam-User: X-HE-Tag: 1691406792-997951 X-HE-Meta: U2FsdGVkX1+JSSheyg83TssjFMtiH/snGjpinj1uR40Sho9Dv/HL9WX1v2VuIOnMX0uLIOYuOMy20CkWS2G5KD7fiI/7kFw5UugFzM3tZaBvPGTkSif7o00Ps2t0KYdvrd0N+nBaTcLFAbljsW6RTDjKu8fwgENbvt8KznIR58oN4HeUKRoy2EkgbdseA4X3Rk6hDsoK3pN3qc9XFQAOVgagZrPlErco7SncvQNYtFNzc46KruujuUbwIDzxsFjVa1qOm1LHhhb8qQEWzHFbZ9S9ro2RCOglAYzbdayY7XDBk7Tz2pjmSufh9auVd/C9X8UkzcvnOEaZI8Z2qh5lLH7ePP41R7Lu+LUppKMkBwcpy28lBWVJLbpSSEF0ab/oI7SJM8xTDvSAU3r3thKT6a6wC4iuIQdRqEBvKQz2xH7DGuSH38kQBVmJ/8FYY7JjbDpuR0a2c8FL9pmmkHRYv0uoX+dFcJ7ddqdOrTaw2h09Xbuncox7Ke1dWgVzQtO/5yxNwd22dFgKXXYOtYGVMeSxtRuZZiexI6AmDbB5nOu7DNnl/jA+B8n47VWKJiFx9UBEsBNGW28YQpIQUgMt9bgg/rf/xQRRTrvjlbxmusa36boN4rmtXDEfidI4zdASvzOtqNoSyj4iS1ZT6B5W8x/QQ0Zud62qGEGYLqI1V3vkELWVITChbtu20ZFCwBQqhtYHAobsUAafnxCJ1ZjnNpozJX3de+fV5MZw/xQLw2TzYsdYss7NpPoDpJM1Oy234NHM2oRm9RF+YnM7CCR4FuEey1JebLrZpxiKTlwJXb+LxgztNyyKBc9rZV3CjxEmbvA2rCdLflbNZAMXOaadOqrX1cK1BYhS/TQpYZcSW4Fa1yQ3afnn9GOMyW5hfwTS//ODT+Va74Lcu7X0FcuLb9RVndCXG9xAozmhj7b8iIwcmKPCa9myQDC9lqKsemehyuKOkmEPR3iz6eaLGXx 8RKkAHrN Y9xEaKYWj20BqYg9WWQfO9DldAuiwdxN1+IhKwquMWq97+WdKKpBaW2FZVH83P8ILTV/MWzFKbVYlzKMFMZ5XxEs0Tp+od6O5GUhsRpN0DSYved4LWI95G5TEDJPvoBd2TAMhrXtkzEexjvIyUWbrglgx1o0WEjyhzT9f/g/TlT8PHBRy3QDXv2xVTF3o+bvPKCPeI7AtTjTSWqoWeCRjEKXMamnqmUnFUkvcBtM9im9/G0M+9GonYQUmOJvHI4V9UiD0W6m4ox1C1h/98DDYqNxsI9V5esk6dYdKpI8v/js82AdrezlkKRurJRjf5JJ9W6GRyjYV0u+xn2yKMtkIVnky/r/IZE2VUMWkMVVJvzveFZc17sGhSyTIxkNesyrJrcJhxy9figHmBcNbZPEPdzg1x+4lYLnB7KXU 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: <linux-mm.kvack.org> |
Series |
use refcount+RCU method to implement lockless slab shrink
|
expand
|
diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index ee9c923192e0..9c62b4502539 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -521,11 +521,7 @@ nfsd_file_lru_scan(struct shrinker *s, struct shrink_control *sc) return ret; } -static struct shrinker nfsd_file_shrinker = { - .scan_objects = nfsd_file_lru_scan, - .count_objects = nfsd_file_lru_count, - .seeks = 1, -}; +static struct shrinker *nfsd_file_shrinker; /** * nfsd_file_cond_queue - conditionally unhash and queue a nfsd_file @@ -746,12 +742,19 @@ nfsd_file_cache_init(void) goto out_err; } - ret = register_shrinker(&nfsd_file_shrinker, "nfsd-filecache"); - if (ret) { - pr_err("nfsd: failed to register nfsd_file_shrinker: %d\n", ret); + nfsd_file_shrinker = shrinker_alloc(0, "nfsd-filecache"); + if (!nfsd_file_shrinker) { + ret = -ENOMEM; + pr_err("nfsd: failed to allocate nfsd_file_shrinker\n"); goto out_lru; } + nfsd_file_shrinker->count_objects = nfsd_file_lru_count; + nfsd_file_shrinker->scan_objects = nfsd_file_lru_scan; + nfsd_file_shrinker->seeks = 1; + + shrinker_register(nfsd_file_shrinker); + ret = lease_register_notifier(&nfsd_file_lease_notifier); if (ret) { pr_err("nfsd: unable to register lease notifier: %d\n", ret); @@ -774,7 +777,7 @@ nfsd_file_cache_init(void) out_notifier: lease_unregister_notifier(&nfsd_file_lease_notifier); out_shrinker: - unregister_shrinker(&nfsd_file_shrinker); + shrinker_free(nfsd_file_shrinker); out_lru: list_lru_destroy(&nfsd_file_lru); out_err: @@ -891,7 +894,7 @@ nfsd_file_cache_shutdown(void) return; lease_unregister_notifier(&nfsd_file_lease_notifier); - unregister_shrinker(&nfsd_file_shrinker); + shrinker_free(nfsd_file_shrinker); /* * make sure all callers of nfsd_file_lru_cb are done before * calling nfsd_file_cache_purge