Received: by 2002:ac8:45c5:0:b0:405:464a:c27a with SMTP id e5csp996901qto; Thu, 27 Jul 2023 01:21:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlEvxCkQggJ7wa2RhsdM3HSVgzwnmysjLEeNAFf4yhh8LB82KoLqtA6LvEFKPLkfhkJnxJLE X-Received: by 2002:a05:6a00:c95:b0:679:bc89:e45 with SMTP id a21-20020a056a000c9500b00679bc890e45mr4724150pfv.6.1690446118408; Thu, 27 Jul 2023 01:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690446118; cv=none; d=google.com; s=arc-20160816; b=DkAdgWaqG1LgSjNaVOIkzIzuuiMGInwpPJXkDUwv3CGGDIVUvldsH3J33HVH9pIX1M bkyw05E8DsIZcbDs+rUB8NR9HOupnPYkiIth0c1fdT10jO1tnKmZ5ghz3BH0/3m6RJ0f +mVSbYaxwhAYpU/FxVKlFpBUJLOMrwOPhckjtcn+99uTn90e8Xh6pl+gfd2LT0sYTkG2 KoP2zDA33+fvcMc2pUy8RK+NmXTaLDkfj5C0cLF63StNyg9Wvvo3frm8DWXgZdThEeA3 /UGNVgbKlYvzUqXllVl3s8ALKaLsZfZuMqHac60dwRrbTtsYS0okWOT/2q+5BYA7axr2 qrEg== 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=NxkGAd430gburLVd9IjvP+jLcLBa8IzZa5IqPWgCN1g=; b=BYwmMmrmSljV5dmenyEYMrPmihdnaiQ5Hix2h6SNKjhbTxikzlmzMwRMKOpLQFMzKm 8tcY8ZkpYHgEwtjSdRHTz/SLQk0OcAtA7HUeKhIsbV7CxlWvqpRHjL2CAxilf0uFg1vW JBgA72hbtTbgoVe31dMPsJNax80/8OM9a8FPdbOkvGdvaM1RQRB4zyElbspiQmkrDOjY wrxPSSInhUon/myPD4sG+KKkuBw6rSrRsUWKiGZZ3bUxCjZHu6u/g2brN65mWynhbCyc A6G1BSAnvQDfJjxUVSCG+/V2VQDkIeRbjfwEA1Rl8ClV8JiTdrcu47LnwdgerdQZbzPB /tuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=bsOGFEHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 ck8-20020a056a00328800b0067c47ceb886si1011110pfb.391.2023.07.27.01.21.45; Thu, 27 Jul 2023 01:21:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=bsOGFEHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S233087AbjG0IOu (ORCPT + 99 others); Thu, 27 Jul 2023 04:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234319AbjG0INz (ORCPT ); Thu, 27 Jul 2023 04:13:55 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E68C54C2C for ; Thu, 27 Jul 2023 01:08:50 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-682ae5d4184so170624b3a.1 for ; Thu, 27 Jul 2023 01:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445259; x=1691050059; 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=bsOGFEHMBlylId/BUUU6j2E7pnjQ9uMa3Dv7D6LoIY48uPLQavKrpj689NrNUpNLTl Aanz7sKMrDaOTTGh4q0MwHTWAvihn1jLx/NBWz0K9CQrFU5rnVI5CzfKG4yO6ADEleGk +0iHBjbO0i9m2+usUNEX9xFmZ3EhQv1mJHg4H05ocCDdgDOngyKPTxLLXx+aCRh/qeWu DaVggQ15a1Fk3lZ/quyODiCtb+FgmREKB0V2Ac2I9AcArTAe8N9Pb2STGieOdKv9GKuP YDdg42gSOnr6HuMRpDchso7LM2qcKeKJNp+Y2dbUP8m4urT1oK6m0eJU2zmqUir1DcF2 Lspg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445259; x=1691050059; 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=NDOSr7t8iksqKrzAJO3eRYBs/WzQXdMcZ+hzZKcA/Gy3p2fi/UL6Bh0LnMVi9Bjndd U/8gRofZ2blIVkn8Pd1cWa63l/IL97Yt8PJzivliLkCSHz2jRlIZf2JQq0mjRVUpFB7M lzLK6jKU3POr/Ausu8bTzO0Uy0S5HaJh1ENJXlrvx6+sR0Int8ClIxZV0aIuH8IZnR/O dFkDFYy1dv2a7x42lyM/2MYRAWBYwBY/skUWHzTMfaDYO++s4Ddn6BQPNdGYCsW/u20i ne4Uk25tgx6EsQ3aStKOSsrATw7w3mvtFOSZvXZDcsr7xTNTSYBJQ4i16EQu+cPNmIFo eHbA== X-Gm-Message-State: ABy/qLbbU9VmMcvbjqkd+ttxGR8XlOyvnaG85QNPJkohyZrKTxnQ1M6o bLyKuWAXfNd/MbxR1l+zjCgiwQ== X-Received: by 2002:a05:6a20:9381:b0:137:8f19:1de7 with SMTP id x1-20020a056a20938100b001378f191de7mr6160325pzh.0.1690445259706; Thu, 27 Jul 2023 01:07:39 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id j8-20020aa78d08000000b006828e49c04csm885872pfe.75.2023.07.27.01.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:07:39 -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, 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 v3 09/49] xenbus/backend: dynamically allocate the xen-backend shrinker Date: Thu, 27 Jul 2023 16:04:22 +0800 Message-Id: <20230727080502.77895-10-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230727080502.77895-1-zhengqi.arch@bytedance.com> References: <20230727080502.77895-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_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-kernel@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