From patchwork Thu Aug 24 03:42:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13363438 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 A4251C3DA6F for ; Thu, 24 Aug 2023 03:44:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44BA5280072; Wed, 23 Aug 2023 23:44:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FCAA8E0011; Wed, 23 Aug 2023 23:44:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C40D280072; Wed, 23 Aug 2023 23:44:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1D1188E0011 for ; Wed, 23 Aug 2023 23:44:34 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F41AA1C902C for ; Thu, 24 Aug 2023 03:44:33 +0000 (UTC) X-FDA: 81157606026.23.438BBFA Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf22.hostedemail.com (Postfix) with ESMTP id 3C7A6C0007 for ; Thu, 24 Aug 2023 03:44:32 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=bY9LD4tg; spf=pass (imf22.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.180 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=1692848672; 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=fL9UzNFH9xRc40ovijxQr7+deLFTeJc0QRJlNk7UAJE=; b=CdGUL/JkGww49LwI7uaMAF92jA2Eu3ADLqLVJphF5Nrds8IBUywV7LdDpjeXZrYOwcMMtu mAYOx73NojgT7keLEEK4GfNyLJ9BRNh0zmzyDLbaq+pRQwhbZ9HyzGdTXNAX18IoDc6dkB Xtmg/DB7+Lybe96CKBh0MgnTyL3E4Is= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692848672; a=rsa-sha256; cv=none; b=liWxE9b47KwjuOUPa3sNlPB0QaPRLKFkwjkOXbaAm0q2XlYZuMmAdBI1jeCFzuCN/oQrBn PKx5AhNpfea2+Ys2jX6vG2MmPXBVxOYO8iZClv3egDLo7IqSqt+kLvlxi/za7zQRDLpUlX QOOWjrfed0OcVUi2OT52Q/WQIum8dKc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=bY9LD4tg; spf=pass (imf22.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-68a56ed12c0so755737b3a.0 for ; Wed, 23 Aug 2023 20:44:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1692848671; x=1693453471; 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=fL9UzNFH9xRc40ovijxQr7+deLFTeJc0QRJlNk7UAJE=; b=bY9LD4tgkqWxkQKKd/RDOoX5W8qpuGAecHeEhLMfDjHuJUY0svZZBxoximm9J6Y19i IqrrH7xW9H7peP2arsnyh17grC5SQNfshLtri8kPslLmcIm+7WgUocRo8Yx/4Tfw2jXR c3uYDXcSM/kuK3tPVglakJG9pBHZK8VSYZiPXSkCgitJGmj1bNL4q/waTdyTfhOKwshR aTWnSB7OVezKYHSxHn7x3sc27R1ATOK+S6Og+iQUPKgoVWwop02aWHbGt7Gzi+eH1aCx GxgOchcaZoRBNIXtV5nUG7kDq0z3sxxuYYxZNhstl4e05qGO/BrwD9AQR8U5OepcAJBK FutQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692848671; x=1693453471; 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=fL9UzNFH9xRc40ovijxQr7+deLFTeJc0QRJlNk7UAJE=; b=AVr6RkaDcXtbk88QLErTVTIE2QfZoKAO77Hz2U0s9bwwM681GSWn9mbjaZrnACE+ox wHkQiirqSYIPgMeBfkTSi29CNE7ZKUTa1pkxdvWJUx/14sF3yV8smFZl6kge9UL+4Flu wgUG9Qtnlx8kFhA7ZwWhjlUiMjmFHBdqjwCOrlXbbH74o5DzXbAzVk+hMNkTHYTifvfV IcIfw23mZIfbPrGsS0cfLJGYwA/DdBJZu2NPy0ZW3yID02J/L9p6jZ43SqewqGzSAb4Q gyML+uGzLf61lq0yhDvkd0Lph9QtAIUkhXTw/gIYts3usfHzIbM3aqFbyiHXjglyd7gl B7RQ== X-Gm-Message-State: AOJu0YyYQnvGLFGdVp5VuVQw3DnWBBe3micQtaFPAIa0T4B8FyFH563v lUitrcaelcPpcU8LJl249THdfA== X-Google-Smtp-Source: AGHT+IF9XwmI1K/7s22ZAfh1q1VXcTL8c0ROJkv/uTQnOzzzUix0h5W4i5ROCPEGbt2KzyOxEQAr3A== X-Received: by 2002:a05:6a20:938d:b0:13c:bda3:79c3 with SMTP id x13-20020a056a20938d00b0013cbda379c3mr17551017pzh.4.1692848671217; Wed, 23 Aug 2023 20:44:31 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id t6-20020a63b246000000b005579f12a238sm10533157pgo.86.2023.08.23.20.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 20:44: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, linux-fsdevel@vger.kernel.org, Qi Zheng , Muchun Song , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , xen-devel@lists.xenproject.org Subject: [PATCH v5 05/45] xenbus/backend: dynamically allocate the xen-backend shrinker Date: Thu, 24 Aug 2023 11:42:24 +0800 Message-Id: <20230824034304.37411-6-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230824034304.37411-1-zhengqi.arch@bytedance.com> References: <20230824034304.37411-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3C7A6C0007 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: dnbaqqwqfmixpm7j5n4gp1mis358k4dp X-HE-Tag: 1692848672-443766 X-HE-Meta: U2FsdGVkX18assiMUz2MH48S4ouA0rWXDvtl2zvU4O1vmn+xL+Sv9ZHZ2RDymmUo5DmdjXg7JtNFkNh+ae7iHHNWCZkaQn0kl//RES143OZo/H3MUOvAX70iK6F6Jr/BD9E5G+xVQklcqBzrdt2SyK7O1jv1HCa+LtE3fN5G2qVWc4fZ65CpbsHN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jgYCnCtj1K8m7pKHX6NZKqYaHNyjNNeFaDl6FHviAZah4UPKvoVRfu4jFgmdM3whw2XjuIPJ3be1fzlsBFuQAaH4t6Gut2O/u7NfplEGQe5PaL3FcVXzzWQzXOeYOaNJepQMYnFPJwQ4xZOf4XnrXDY9BGd4rdVZcL2NRq2Aa62cL/g9uXnNPm7TC9UdfcnoSqY+nxvGqFnbYF/1KmZEXbgGwhgNv45I9FC1m14p8hzhlaKndpuZn91S3s5N9XCQNhJw2SZe3c0Ep1GixUd/VAO//JJWuDHYggy+kswfhtIJadvDQvil8mSUqM1TNd3igsQEykMdCAHSJyRkcBIrQ7wJWYL7ONRIlS3GLxlmopHw+x54TkBODwePonQWGWR3pSll9gR2PkSQnY+/Q== 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 CC: Juergen Gross CC: Stefano Stabellini CC: Oleksandr Tyshchenko CC: xen-devel@lists.xenproject.org Acked-by: Juergen Gross --- 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; }