Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2891563rwb; Mon, 7 Aug 2023 05:20:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9dwd8ljAiOQL7wg3tPzCrKT8aFLsfTSMCuiICRae8kX21W7S+1eyTc49WGqClrwz+ExnN X-Received: by 2002:a05:6a20:f395:b0:13c:ca8b:7e29 with SMTP id qr21-20020a056a20f39500b0013cca8b7e29mr9418743pzb.12.1691410812616; Mon, 07 Aug 2023 05:20:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691410812; cv=none; d=google.com; s=arc-20160816; b=sN4ZxkmxeWgP//ELUWoVLwHhR6zt03uNiE2PiLvYPM8BILNWec4gT2e6rzblAohSfZ V/wvqHekbpj4F8dDg087daQGD47/3932SPMvDIa4S6BsPDkqOweTrK8HmWXFZ+h9b3j6 XVyKJG4H8AP9HhiqVWUTFcraE7eCCxngBHRFfD5WJxbBYlDNjetZRpFLSdLV0cXlfPYQ cvG1yoVZbFOrrLgkHFvsHH6dm1rVZvZD5XH9yktVzHLaodoJwWlLaCJGZ3xfU0y4FwCF 7bOXfXYyBcRJY5v/ioDNwo8QjcCszy3ZUpj0aKx2XYAdqWeAHOkfZc75O3/3C3jv6re0 5ErQ== 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=XAY9+N2BbVQBjCT3MmFWkPxUR/2vf6o4m+CtMBoAzag=; fh=JwrRg0ndXrpURY0vwDVMB2JxbP/kKK+/sa4yghEeBpo=; b=GmTIWIL6YOAMgns85ry24Lr3Ue/RGwYTmIUAC0ojC7MjBKFyY8mmXWm7HzDqjjyDQJ pr/BTX05c3oGZTW/WhvCBox+JURgITAzFRntUoglt5bqkbfK7+x3/sxcKjO55o8FOlbU /NqoZKUzQll17kAMlSHLM8HDGgsTPBGcAf1HcsGpW+ju/zP1XYjFgJVPbK0gForC00Ij 6KM6GUcMTWTODGU/4mDueTT3xEH2h41Fy8V2UqizkDZDwnwtl2ljmenAhBK7hQtBk00+ XKrYN5J+tZsiiQMmnEmmSdLOn9fVWf90kj3eGlr8iuhPiEKCXdO42yyO5crhduhHtQPm i82w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Owhbp+vj; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 y25-20020a056a00181900b006872b7b1b69si5687891pfa.353.2023.08.07.05.20.00; Mon, 07 Aug 2023 05:20:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=Owhbp+vj; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 S232068AbjHGLOO (ORCPT + 99 others); Mon, 7 Aug 2023 07:14:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjHGLNy (ORCPT ); Mon, 7 Aug 2023 07:13:54 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFF7B1BEA for ; Mon, 7 Aug 2023 04:12:57 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-55b5a37acb6so362001a12.0 for ; Mon, 07 Aug 2023 04:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691406737; x=1692011537; 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=XAY9+N2BbVQBjCT3MmFWkPxUR/2vf6o4m+CtMBoAzag=; b=Owhbp+vjTX9LgSb8kQ7MIhVXGKwDLhR+Ce+1Ax0621Bs9MrN8XWMe5+Ejw9lnwM3Ap IYUW911/vhmnbFJp/stmhIc489u8MPAzdlnhNeoJi8rBqpYOKUrjixaEdD0XprSya4Vj PDunDNjaDu16T3tMnzjFT3t7h/oKuuaUvjmMy7sBXTr5KsxElViOqZ7/5M9dmikw8+EO wMQGbexE8DINXXSrzaCt4DliIlnjdofAsiKIz1t/gb0CaZI+4t4MLa+CBQGQ2Bhdx8d2 /xQiP0jkFYD6YIUPc+4v26SX8VshwmbMbumt9peptq8jkLOVQze1kYBLFAMAnfkePzJe dicw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691406737; x=1692011537; 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=XAY9+N2BbVQBjCT3MmFWkPxUR/2vf6o4m+CtMBoAzag=; b=gxguLk7+BkQExjCsZboV1NymjmwAYdU9My8jLD1jyYSRcO7j++9ZhRlGZKrcas3epy KJ23Uu/3ZiuF7ipMqH5jtTBQhv492daY8XNlyliRPRjIN6233Tuw711j4MUGU5/QoaOS Y4c4HtFlg0+2V9Aqt1OVC13N8wlDvQ017MRdYjQYWrRfkVFtNNMw4eRRUIb/69RqhCsG Y8rkqjKcJrhOvSNCMwVAItz1Ainghp4T25SplZ/12DgABs7k5yK0cZ299l+NmM4MDWTu JXMY88st2z3hQbyibxDn+R4s/unJfIuhRF8qdhxkB7Ev2W56nhMJAts9JKldSraBTd1G hljQ== X-Gm-Message-State: ABy/qLaUUmsNqZVUxn3fZWx55kW3dwKk4DB2Y42DwRUyqeqXihVrZOON YPHKB4r3jk47PxTaBzAafVzGsQ== X-Received: by 2002:a17:90a:faf:b0:268:abc:83d5 with SMTP id 44-20020a17090a0faf00b002680abc83d5mr23476433pjz.4.1691406737630; Mon, 07 Aug 2023 04:12:17 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:12:17 -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, 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 , Muchun Song Subject: [PATCH v4 11/48] gfs2: dynamically allocate the gfs2-glock shrinker Date: Mon, 7 Aug 2023 19:08:59 +0800 Message-Id: <20230807110936.21819-12-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-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_BLOCKED, SPF_HELO_NONE,SPF_NONE 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-nfs@vger.kernel.org Use new APIs to dynamically allocate the gfs2-glock shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song --- 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 1438e7465e30..8d582ba7514f 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -2046,11 +2046,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 @@ -2472,13 +2468,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); @@ -2487,7 +2489,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); } -- 2.30.2