Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2882169rwo; Mon, 24 Jul 2023 02:50:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlGjZEhb9QOVLGnxMbuHphq9jiUD6BhKOrcRMnpsS9yalhDdxmmr1jzS3UTKIVIfLmHcXh6B X-Received: by 2002:a17:906:224c:b0:993:e752:1a70 with SMTP id 12-20020a170906224c00b00993e7521a70mr10301442ejr.19.1690192253665; Mon, 24 Jul 2023 02:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690192253; cv=none; d=google.com; s=arc-20160816; b=XRiN8VLWOJ94aGQ6MsSrlLi/5nHvpQwzVki4t0k7huCDVcO7abexYQH7+qWvwf2mPX 7CTj3C8nDhVToYgbBkVHtQrphVUiAhX/MJVNSQhKZ98dtD0dsU8GmhrU8mtMD/RFRQ3K /1cXiQEPkA+qhOTIPV+nOT0JjwVf3zS5zkVOUgt+tBJ11VnlenAATTb5ZgK3UFYU4uC5 WgW2E79Kgnw+oZopaurmywmeTWMW3Bsqp6ekhlfrtzpYdI//SinCRfagDVKdWrTCmnlu HSduHApqGhws91G3+7qqvxIOM0KSuSKuqWT1SFxb5sNPg4qEz7r8yxiCoImgO2PsKJgv SYMA== 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=TtWMuwNQICElQwN/uI+F3WL3CTikAs+Dtp5goHq/uX4=; fh=3lDHiAuENCYj3gWFb2bYij2cH/UC7c23rwbOpuSBNc8=; b=zDoP138Ols0nusmEaN84O0pejuiZPCCKK3aoHZHY0QxvOYqgE4Cf1LdNkRA86FvdaL uIic9GLrORS40RLZRTvlWsdGxJ5vxll27MfbVHl6dzwfHFNrRdNkFTUJGL7azYLUwoD1 h0YaWFCzV0mCkGO78BnChbeeg03Djoupx4V7krWvV4PISwOedxGdgApN/JxqdOCRjj+T l3TSGzqtJ5WN0S5bu79cEE6xluS1BhPwNhDSf47uPwmepkJDurm6JI0l+PBxBfNESkca WKTDSgZRP3ZL2AbMOvaFCdLEPKjdGuvJceZ/Bb7pU0C6g4tZ6yR3Iq3LoJaVRb4A/ElJ wEYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=I+UdRoo7; 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 t19-20020a1709060c5300b0099325564b77si6379833ejf.548.2023.07.24.02.50.29; Mon, 24 Jul 2023 02:50:53 -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=I+UdRoo7; 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 S229843AbjGXJsH (ORCPT + 99 others); Mon, 24 Jul 2023 05:48:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231844AbjGXJrm (ORCPT ); Mon, 24 Jul 2023 05:47:42 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1995D1FE4 for ; Mon, 24 Jul 2023 02:46:31 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1b8c364ad3bso8856875ad.1 for ; Mon, 24 Jul 2023 02:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690191990; x=1690796790; 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=TtWMuwNQICElQwN/uI+F3WL3CTikAs+Dtp5goHq/uX4=; b=I+UdRoo7PtFa/HFb9ptM84BLJk51Oz8G0P2vA9d94Wc/XjfftjzLyxRBwA01anb/sX 9mresCrzzrrBEvcw02T2JRUzwmE2N5g0vsbRd5C+EoXN25pNGYeZ6g16/FMxa3H5VNDH 6ji0rzPXwUbXzJbwXvPiq1FHNNE8ocU8HPGADHiXDhNHZabYES9ASLXofIUnLzuIXCW+ kwLOx4qHBhz6RtbAZxDD88fTSzK7LENJJOn1r+bRhOQmNpcKYfm1Yk1Egb7OAZu9liNf 8Q2C/an05GdrxKmh9WrMTyMLOPzFeZw3WZtFR0oz9alHcEF4Djwn7mAV20C2gc5TCLWm V2MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690191990; x=1690796790; 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=TtWMuwNQICElQwN/uI+F3WL3CTikAs+Dtp5goHq/uX4=; b=BnyyOnJ5JblSU4meciHtyK6u6tqbyWT1OuxkqG0atTM11Fh46T+RcVvv4uhp6c//sq QT4rfgBXwMCH7T/aLJPOAJbRJEva1FFKdv7kUPolTB87mPjgJ7wuO5uq74CIM3j7/kCY UTG9p1jSROfBv99dOGsnfEYRvM8JsylREYE0OlY2+lkeCQx8/MDFJIAzNeYYtORZkShO z+VHCpPZfSPME8ERZU7JsAIzKOWe2NJ3l5T+/4Nl680laxXi5pF+Z+oZxo8Fvu/hC3yl kEHvRvoY0cvRseKsXK/3C2lzQjF9A2A1dSlrJCc6ob5Ik6isMQYfkFCdIU4utPYwXlgH Dsyg== X-Gm-Message-State: ABy/qLbPpuYyU1eZA5wb0m4c0dbhByVUXCLGx0gmkl/T2tztG/WowxLe 3m1GU4Te/glXqG2FfEvjtpMYVA== X-Received: by 2002:a17:902:ecd2:b0:1b8:b4f6:1327 with SMTP id a18-20020a170902ecd200b001b8b4f61327mr12289687plh.6.1690191990533; Mon, 24 Jul 2023 02:46:30 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id d5-20020a170902c18500b001bb20380bf2sm8467233pld.13.2023.07.24.02.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 02:46:30 -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 Subject: [PATCH v2 07/47] xenbus/backend: dynamically allocate the xen-backend shrinker Date: Mon, 24 Jul 2023 17:43:14 +0800 Message-Id: <20230724094354.90817-8-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230724094354.90817-1-zhengqi.arch@bytedance.com> References: <20230724094354.90817-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_PASS,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-nfs@vger.kernel.org Use new APIs to dynamically allocate the xen-backend shrinker. Signed-off-by: Qi Zheng --- drivers/xen/xenbus/xenbus_probe_backend.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_probe_backend.c b/drivers/xen/xenbus/xenbus_probe_backend.c index da96c260e26b..b4c3cf27af30 100644 --- a/drivers/xen/xenbus/xenbus_probe_backend.c +++ b/drivers/xen/xenbus/xenbus_probe_backend.c @@ -284,10 +284,7 @@ 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 struct shrinker *backend_memory_shrinker; static int __init xenbus_probe_backend_init(void) { @@ -305,8 +302,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