From patchwork Mon Aug 7 11:08:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13343346 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 54C66EB64DD for ; Mon, 7 Aug 2023 11:11:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8DF26B0074; Mon, 7 Aug 2023 07:11:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E3DFC6B0075; Mon, 7 Aug 2023 07:11:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D065F8D0002; Mon, 7 Aug 2023 07:11:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C0C1C6B0074 for ; Mon, 7 Aug 2023 07:11:41 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8FEBA40960 for ; Mon, 7 Aug 2023 11:11:41 +0000 (UTC) X-FDA: 81097043202.18.2BC8CC0 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf20.hostedemail.com (Postfix) with ESMTP id A83E81C001A for ; Mon, 7 Aug 2023 11:11:39 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=V+0c3qPh; spf=pass (imf20.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691406699; 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=bO4yc6b0222dRNj48HoFyPuU9QjRVolFKKVhhMGpLKw=; b=WSr2CD1Sk5h9S8zd2z1VVrRX8pw0chIHMCiKD5GV9mzPtajf/qNcO6F9MTAWQjG5Nef1q9 w1Dkx5txns+le1KJZ3p53jc9ImKP0Kznl/XC9gBXbpAp9kUGIvCQteARYwhY43KD48CJmk XyrSkjLJk1Y0WjwYc+8OFiuaFE5LoAE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691406699; a=rsa-sha256; cv=none; b=hKjbxlff7MWxelK40L4OonwDdPU2eA51AXNnDLs2NG+2t2gywSpjB9yK1x7f+IlvfYiAdZ ZYwmRt11Z0h8MH4kd+r7Im9bg40HzdYi7FPBrbNmAsO398jBZFfqZaxBg4og5ZyjjcTL0T /SaPNUM2HVfdJU1WZG4SZ1FW8+tDHlI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=V+0c3qPh; spf=pass (imf20.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-5643140aa5fso525264a12.0 for ; Mon, 07 Aug 2023 04:11:39 -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=L7j8e5knhzXMuVI0FFVjl6FjVOOkYNfmYw+laSqBOemkxVA+qokLdfx6y/dYVSeRBw ayXByyo0OI8f3q2aUhleZieAcp+2fPtqY+4ygSRNq6q1HtLlTgaNHMbSgLzoqu1BuT8y 3atUSRGGoOO641B6/Js4hScAllBRvUe9GWVWk5s97u/t/nXCXV5kmoXx2smXlWAqTKM9 Si4SIAiI5d/KWUMX8optFaeh92r4I5AIzUXy5Cn6L90821nrcLU+Pfr4NSN2kkrT41wG bNk9kXFFkky2KLjTZ4Gbm8AWdmaepv6W7k9sumetKfRN+rYQuEuhHjgaaj/LMTBLab9k v3JQ== X-Gm-Message-State: ABy/qLZn4CffHRrwLwg5ykCUxxrgv/CryRvYgeosY/u/lA7+u05OPrK9 7ly7YpbHS3rlCDZNdcLqRF7NOQ== X-Google-Smtp-Source: APBJJlHTPEiI4d70NxX2nHst3XkAfiDRggXx1NmGRpA10Zf8iDezZWW8ih32EzxQIqpHPiYHvUOM5w== 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 X-Stat-Signature: hn4fe6j3o5knc1x8tfdyjza91npidbw8 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: A83E81C001A X-Rspam-User: X-HE-Tag: 1691406699-147981 X-HE-Meta: U2FsdGVkX19pIJh5Q5GulrBb4VnHu43v5qLoDL7UTzxESh/FWEN98hRFJCl49MN5DajrHt7cwaEcYpRzLL9bzGEMuoLghOnprUVSg3q2zEQVZkFmQuM9I5e8enzE3mwGnURaUmC0j97X3s0Wn4eRBbd4A74zbPEtigbIEswOmzi4ruWRdI+CHwsk8tiOK1L28YH4mgtAN2Em0npaQQBPWx5kVlNzqX0La4w+itG3rFi46gq+mXPJeo1tmTqhMHE2cToJ4iXYPsn4k9fzK+JUADq1MoJS/hxZsY9iRt4p8ERX7Mt8zBPTb+pEzuEIvKE0T4Y3oly6DtCeGuFDGZtCKF6x6ibgR61U0gAspYSKcl/zIVizSFf7dcC7e6pDGAf12A74sKu/PVnCBANVrgP0QOVspNsjYRNcA3ANzD5IAYFiBbLDA37qjrAbUsF2NYbGUbbanjwSMESFVcwyovfHUsrE0fvGxpNXRjBipxrgesquu4oPX5cbnr9QJFgecDmBGB1l5Yk8zDw4so3y872mhcgd/wmulqRxlPjauEZRGQryZeFRzMrmVXcbaMmOxszQ32hME5Cp0yq2VdKocgGKuVzwMWn5Li+J0OcSdSltUQsxBrWHaVrjFZXNKHwu/zhb/CVj6HBzMOPhXGxDURTZiixNJ1rymh67tfmS2oMnS0jToRv0z8EeQDUYXKF2Yb0+aetrvwZQdiVY5cl/0rD6ZvHOQI6HlJOMpVn5avKdx7F19TOrs/m3+QjFL+A448dDCdED5FtweeyxZQBJzGE3lHRj0lRpY0awPrs7hJ2IqlLCMylan7XEUOKLLMW6Ji50yS+aOJa9owRRSB71XMfWl4RvKpkN1ly3KQiSdBwDtwwiFxUT/DKkBy7ZhVEdF6y8s5Es/zelNeaMonil3BWxlDkC3tJM/0uIC75aLO/R2NT3dvIgojgrwzEmxAUbV1UOeyeXzcccmdBVrhBbvYn EBUuyxjg eZDOqAjIPUOJTRAYtm4FcIV4YdqYs3dGnwERkmDnunjz8BGS4yORmxuCoLtX7gmG7mvBJJX9xq79Z+DolOp1QlMBETqK1okG5KUVCQYp+ss2/dggDUjmIxQ3e1TaCpAnQxrIknFy0t1dDH3olAI1pLQg0vgtVTrnGEWlozHp2JUmXgVFCz+euhZ6/w5AnR0D4YlV48+FqFdtEdtP2xXSRhCg1vP9lAOz08X4434y44h6Kvs3/K6nQmyh802QlZNky8hbtnhiX3va3vXFXYyMKpKSYyfdUPnflO2+rGbDxtCnjiXJ04ST4yAaaUW9jt3LoVp0oOCaUUuBcCHphqnh4ZyLPCsyEqg2R4M+EHBjs3TBxzxM/lmxM+1vjszXAXs8en2BRh4IVpx1MTEPuG/3IvyUk4+wviMERKcn4 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 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; }