Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2846868rwb; Mon, 7 Aug 2023 04:40:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEN4ZtQVVmKyltzocy808tn8KZe24/MZknpmgY1XModDgxl1pTZ9+IMdRUWorIu4+uyC9A7 X-Received: by 2002:a05:6a20:1455:b0:140:d536:d434 with SMTP id a21-20020a056a20145500b00140d536d434mr4352083pzi.10.1691408412898; Mon, 07 Aug 2023 04:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691408412; cv=none; d=google.com; s=arc-20160816; b=YSH+h0pF+aGh3f75QE1CWf+nR2YKELvUNZVjt6tsr61poMrVtcGbFoqDosYBmwVSZV g9iaLdCUQN2ZA2qU8GEZGeUXoUO6di7yR4MTy6FfXpGWJRAG0L3BGAyIlqZ5z+k68u+o 8nbYm8X0vEgWVqtQllOt7P/SYkkyJk45whMng95rMI/NIZQsfBtT5aXLb88x1CVJ1f0I 54ywmvsnyoQIF6gtqJomf1ohvwxRVM6bu1WAcNlZQEkwNr4HaSo+bqifpsmJilQLs9Fx sd5HN8UYQ0V1e2QfNNOcl+LAZeHwM8c1TpaG2X8s70EEyyEnigGWRBhax0yJ0BtF9HD6 2JOA== 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=bO4yc6b0222dRNj48HoFyPuU9QjRVolFKKVhhMGpLKw=; fh=JwrRg0ndXrpURY0vwDVMB2JxbP/kKK+/sa4yghEeBpo=; b=wDVJMTxHoJ+X+wdPkWWpv7o/2Bq8tPQs0gpZHMDF0CSvn+woSR5f+Kq6hoEGU8uivH iLkv4gPrZuObP9mvOIP0wGrxaesp4KFpNqZJANtUaAlVnRDK2NPIDx9C84iPmCtnUSNg 5NAn0DAx7R0jnKLz0FQ5ROxBV8gFljr7cQlb78Yi2ti2EAHYiWsrw1YcqgqHaLVDTP4M 5Jlg8tfH9QkIWk0YQDTMDLTRUottwYbSsIzXOLljLqMQ3wx0SoTzQpJ+8pyHsciJE2zv huP42VuO7yxHEQwHio5o05KxWF+Y07iIkOp5BEwJ+qG1scBsfm8Ce9tWDjchIIRzYNuy dyCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=V+0c3qPh; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 bt25-20020a056a00439900b00679a6ce03f6si5672330pfb.59.2023.08.07.04.39.59; Mon, 07 Aug 2023 04:40:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=V+0c3qPh; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 S231645AbjHGLNk (ORCPT + 99 others); Mon, 7 Aug 2023 07:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231865AbjHGLNO (ORCPT ); Mon, 7 Aug 2023 07:13:14 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47548213C for ; Mon, 7 Aug 2023 04:12:11 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-56462258cdeso525481a12.1 for ; Mon, 07 Aug 2023 04:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691406698; x=1692011498; 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=bO4yc6b0222dRNj48HoFyPuU9QjRVolFKKVhhMGpLKw=; b=V+0c3qPhJ3OvHdRK0zt0jjicV8eIk4mcEJBfZa3lpQkwu54lWNVPIEieS4PtRydxoC SOQosWaNmtA5ijvBvBTHzjmbD0d0j9BAeGMmaW/jH6uvD6Ej2n/njXM3uIqGlzrBkh1f 4pNHqPhVUKAnLp7tAzH1vcGObvmfuMOiL8NrO6wDjhRhzYUa1svLTbbXU3r4juxNC7M+ zvZ3SM7T/9w0Je9dQGJ4Z6qlkuAYn1bir+6JxlC1Qr6arztdDyFiMoqBolNxM3VBbd9i jsX4xXrnwmvTP/fkwCWNcOiK6G4rP96fjoeNSyiOnE04LmSKfInS+5dfsRm42DUoM8bY LffQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691406698; x=1692011498; 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=bO4yc6b0222dRNj48HoFyPuU9QjRVolFKKVhhMGpLKw=; b=NKiQv9tXfkX4uav8V7CG+fjS30AW7y5LGis23lar2Sgv59NEuQ7Z2wiNoSCBkqWEW/ G988Blg53yu2k/0wBA8YEH2jnuyaiVj3dDFkWf0T2dhIanbb3q2rdSwXdwvIhqhBXpuF J/ogk0lgvkpYfqqxO2nJJ8fMFJAtsI6RANvMjAIB9MvFebInCDWwFN55cm8NPg8bGjy6 D9WWqHG9rKfzEPFLoZlVDkEJ2rWPxlKQKtb/ZFrX1xrUojQxB4sw30dNjCcnlNVnURjF R5U35lHnlJiomfAtX+IRzqROIVthfaMNGE4ikRAoPRpgwHAUZBF920MhJUrPerpBmNf1 O1Zg== X-Gm-Message-State: ABy/qLaVLK3rMTsWLXkD2vG0s4eFUfiLm+GGrqmcM/b0td7RobOAgYn9 nG7PNN64hhuU3VS+gJ4pUcNWNA== X-Received: by 2002:a17:90a:1f83:b0:268:3dc6:f0c5 with SMTP id x3-20020a17090a1f8300b002683dc6f0c5mr25027705pja.0.1691406698603; Mon, 07 Aug 2023 04:11:38 -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.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:11:38 -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 08/48] xenbus/backend: dynamically allocate the xen-backend shrinker Date: Mon, 7 Aug 2023 19:08:56 +0800 Message-Id: <20230807110936.21819-9-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-ext4@vger.kernel.org Use new APIs to dynamically allocate the xen-backend shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song --- drivers/xen/xenbus/xenbus_probe_backend.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_probe_backend.c b/drivers/xen/xenbus/xenbus_probe_backend.c index da96c260e26b..929c41a5ccee 100644 --- a/drivers/xen/xenbus/xenbus_probe_backend.c +++ b/drivers/xen/xenbus/xenbus_probe_backend.c @@ -284,13 +284,9 @@ static unsigned long backend_shrink_memory_count(struct shrinker *shrinker, return 0; } -static struct shrinker backend_memory_shrinker = { - .count_objects = backend_shrink_memory_count, - .seeks = DEFAULT_SEEKS, -}; - static int __init xenbus_probe_backend_init(void) { + struct shrinker *backend_memory_shrinker; static struct notifier_block xenstore_notifier = { .notifier_call = backend_probe_and_watch }; @@ -305,8 +301,16 @@ static int __init xenbus_probe_backend_init(void) register_xenstore_notifier(&xenstore_notifier); - if (register_shrinker(&backend_memory_shrinker, "xen-backend")) - pr_warn("shrinker registration failed\n"); + backend_memory_shrinker = shrinker_alloc(0, "xen-backend"); + if (!backend_memory_shrinker) { + pr_warn("shrinker allocation failed\n"); + return 0; + } + + backend_memory_shrinker->count_objects = backend_shrink_memory_count; + backend_memory_shrinker->seeks = DEFAULT_SEEKS; + + shrinker_register(backend_memory_shrinker); return 0; } -- 2.30.2