From patchwork Thu Aug 24 03:42:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13363441 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 3B4AFC71145 for ; Thu, 24 Aug 2023 03:45:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D259328007E; Wed, 23 Aug 2023 23:45:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD62F8E0011; Wed, 23 Aug 2023 23:45:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9EB228007E; Wed, 23 Aug 2023 23:45:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A8A838E0011 for ; Wed, 23 Aug 2023 23:45:01 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7B17812011A for ; Thu, 24 Aug 2023 03:45:01 +0000 (UTC) X-FDA: 81157607202.27.2D68BD3 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf19.hostedemail.com (Postfix) with ESMTP id B000C1A0006 for ; Thu, 24 Aug 2023 03:44:59 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=dip4qEmJ; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf19.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692848699; a=rsa-sha256; cv=none; b=rw+tUrCoDF/MrbARoO6mEtjCJDruOielIXfLgEL5KQmNSGsfgfbpmEN1Umnn5C4pTmGu71 qs8KMLOGcKMPmFAlCW6F75fJcRLXMXgdZ5mwdHBSLolo7Z6rMoixa1xZ0CIYo9ZmJ/d/im MtFA5K73lOoTc7u0L4mHxfkm6SgieeY= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=dip4qEmJ; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf19.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.172 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=1692848699; 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=B+a4BSDzIy5bpWMN+1YxNCRarQu4di8i3ZJob6D5Dd8=; b=e2mw1bV2VztJ+kdkFKo6vKrLKrgiZzcn5hDCCDcZou0jtZhaRXCU7F+Rx+Kxd/C2C2OMFj m44f7yfLlMZRYAoUs/uheXUU1OrjtO3GV+ODGq2ioFHnJBxzpOIb9yxHNOtNH/u0XG2OZ6 8/17tOJVLbi32Vo7FZRihWMmdk3bCGY= Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-68a56ed12c0so755816b3a.0 for ; Wed, 23 Aug 2023 20:44:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1692848698; x=1693453498; 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=B+a4BSDzIy5bpWMN+1YxNCRarQu4di8i3ZJob6D5Dd8=; b=dip4qEmJiV1YNzGzxlEI74Wryfunkc8c3rSYglaB3JIKEkT5lZ/foyX7YEMfkNEKng HkgCgh4ht64H1EmOCjuIJTFBRAsb5UPGfDPvHtEFoWm7IryKNuuIyQz573mu4imLgEgA aFipiNvgqdW+K2LFlZceFlek6WrMXBYl6UIjo1y2zHTRkONxxfYLHLcu7IEd1W2Qv/On OeO1Efs6M3t8mkmnGIM2HduzmF5Xd1srOyi16pQbX/gdcxkk4XFZqGf05Tj9UAofohDb p/FHyqijf69R6qxp9cnyWtD8AgdVX5kMyPGP2MC/1Hoaixy4uFYdTFI6vmbCaIqCJVfQ UAdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692848698; x=1693453498; 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=B+a4BSDzIy5bpWMN+1YxNCRarQu4di8i3ZJob6D5Dd8=; b=Efm+GKYCKTMZU8xRO5Z7PqCzoijnRdxkwoPt5yL2hy9MWwl0iBUDBgOtG64okVYcNh NBvl4ofG1JX07u6zSJdzafMEi8Aa6uJs8fu9Z+HZspfuSYKcL9SFQ6fkLyMv24uZDCEX 59bPOeXQ7gLbC1St42+zdu0zXJI0e/MuNpukuE1Kjhc8US+mWbVc3FqLsWyHOT/5+Yfa uji8wSnnLJWCSCGz/ceqIV0g7FxO+RdJlvR4o95LNMM1GPNxED9F9FGeVT6Dm3r9YL0X +tBYyyUmcLi3ea9sDVxVuih7hHo1KAnwuN7/LRTw4UR18OuFmI0Zi746vDdscPAs29Mw X67w== X-Gm-Message-State: AOJu0YxdHU414aW/41NPfFl2PKX5R8UHS+MtJ1hTM2peVdV37yIC+Y83 jzLRCX1ZuZVgAWl1cwxcmyYm4A== X-Google-Smtp-Source: AGHT+IEW17bvrtndnX5u4ZO2vRUQ/qIdWra1p6sHngI8edmpBrVuX9kD1hLdFF/eUVbriCdR0TGMjA== X-Received: by 2002:a05:6a20:3941:b0:137:4fd0:e2e6 with SMTP id r1-20020a056a20394100b001374fd0e2e6mr17388012pzg.6.1692848698719; Wed, 23 Aug 2023 20:44:58 -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.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 20:44:58 -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 , Bob Peterson , Andreas Gruenbacher , cluster-devel@redhat.com Subject: [PATCH v5 08/45] gfs2: dynamically allocate the gfs2-glock shrinker Date: Thu, 24 Aug 2023 11:42:27 +0800 Message-Id: <20230824034304.37411-9-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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B000C1A0006 X-Stat-Signature: qp8tosfo4mjhkczyj1zbas88tp76pbk7 X-HE-Tag: 1692848699-472778 X-HE-Meta: U2FsdGVkX1/cuU78lpQTpt3jGkkD8EPp+T/04ukom/xOr2Zh/8P7mNw6JCnXwuQp6r/BPonYYa4oqVSQk8etfCJxcuifwN/D8UFPTwLfGgkaOPkESg3ZRxsaoTuJ8clb6P2blklvLHR3+eaXyCP44g7jMKfDekZ9zRsF2r3HVgApKgqko6Fi0f+b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I6hJZxtHQMz/u3M1eHKQumCEddAk7BZ9AEbunlrpYJoYvuea1WKFVIbpNXGm2J265dISv5/Vdq1mEJW3dJ3H3XlSw0Oew8tagKjFhYyC8iWuqRBVfHQR3/HiUPvUY+Jcg2qOMlBpJrmas4MsXfhRHIbVA== 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 gfs2-glock shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song CC: Bob Peterson CC: Andreas Gruenbacher CC: cluster-devel@redhat.com --- fs/gfs2/glock.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 675bfec77706..fd3eba1856a5 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -2039,11 +2039,7 @@ static unsigned long gfs2_glock_shrink_count(struct shrinker *shrink, return vfs_pressure_ratio(atomic_read(&lru_count)); } -static struct shrinker glock_shrinker = { - .seeks = DEFAULT_SEEKS, - .count_objects = gfs2_glock_shrink_count, - .scan_objects = gfs2_glock_shrink_scan, -}; +static struct shrinker *glock_shrinker; /** * glock_hash_walk - Call a function for glock in a hash bucket @@ -2463,13 +2459,19 @@ int __init gfs2_glock_init(void) return -ENOMEM; } - ret = register_shrinker(&glock_shrinker, "gfs2-glock"); - if (ret) { + glock_shrinker = shrinker_alloc(0, "gfs2-glock"); + if (!glock_shrinker) { destroy_workqueue(glock_workqueue); rhashtable_destroy(&gl_hash_table); - return ret; + return -ENOMEM; } + glock_shrinker->count_objects = gfs2_glock_shrink_count; + glock_shrinker->scan_objects = gfs2_glock_shrink_scan; + glock_shrinker->seeks = DEFAULT_SEEKS; + + shrinker_register(glock_shrinker); + for (i = 0; i < GLOCK_WAIT_TABLE_SIZE; i++) init_waitqueue_head(glock_wait_table + i); @@ -2478,7 +2480,7 @@ int __init gfs2_glock_init(void) void gfs2_glock_exit(void) { - unregister_shrinker(&glock_shrinker); + shrinker_free(glock_shrinker); rhashtable_destroy(&gl_hash_table); destroy_workqueue(glock_workqueue); }