From nobody Wed Nov 27 21:28:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1690445242; cv=none; d=zohomail.com; s=zohoarc; b=KwNemzRq6nAMWJVuXYCU55IeQuC3uoyAdlu/oPHGHDOE/eJZdWPw3gZ/2s4nYq6FOVbMkWPzuHh3zu1uhu7Z2TpUf9WDDCXXs43bnawoyxUXWvzarHmkeBuGSLZ6lpZXJ7r9+U1OtYQOADWToXC7w8RphwfT0Ya9Qb2L4m/VbwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690445242; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hJ9OcOwqZEZhIoLNGrov7as0vMS5t1dTfm2Sm9qefJI=; b=DNlMsGMC7h7ckf8zgJIiDUwMUG9ibdhK77AvynCjL9JS0zxRkLloOwEHTATq9OmJklF83xIIxVUYlfzhiR4ZHCK2qg1p44dW8cuowGRORHWz/PIPkPtjHY1wQnOW0fm1mWnNUtw5s6nImyvDFzKhMcU7+JL2TYb9w1hQNj+Ek8k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690445242915826.9665590646905; Thu, 27 Jul 2023 01:07:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570844.893119 (Exim 4.92) (envelope-from ) id 1qOw1Z-0003Kb-K7; Thu, 27 Jul 2023 08:07:05 +0000 Received: by outflank-mailman (output) from mailman id 570844.893119; Thu, 27 Jul 2023 08:07:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOw1Z-0003KP-HU; Thu, 27 Jul 2023 08:07:05 +0000 Received: by outflank-mailman (input) for mailman id 570844; Thu, 27 Jul 2023 08:07:04 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOw1Y-0001DS-4f for xen-devel@lists.xenproject.org; Thu, 27 Jul 2023 08:07:04 +0000 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [2607:f8b0:4864:20::435]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 91ab0368-2c54-11ee-b247-6b7b168915f2; Thu, 27 Jul 2023 10:07:03 +0200 (CEST) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6748a616e17so182441b3a.1 for ; Thu, 27 Jul 2023 01:07:03 -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.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:07:01 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 91ab0368-2c54-11ee-b247-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445222; x=1691050022; 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=hJ9OcOwqZEZhIoLNGrov7as0vMS5t1dTfm2Sm9qefJI=; b=AioCATUlkHfrdNMX26y5cMG8yiZzcrqJVPo4kMJoo0a/SPBGZMItYxbURGlfK0qQ3U pdquqHjvBnBibcfcPa96/7pchRYEBHxyNnf24E8fTswl7dwSe4DIa81z6/ovJRcM58gW OCn1XGDPuwokH00bwAsXcK1Gr5D3vpz/ZXjhjYJknWBgLZAbQPwFGeGyEdzXyVgOqH5z Y8WwL8gpftvasBEeZpl0cei4t7+d2ZCdr5qxpBrrzaVJwzr8lwB/25SUTyxKcTGn9xox E7xpcSMCUuenHibKLxGm6dPJne0R4y90eWbLKKoQI9m29dm8UqZ2/hC+L12FcXTeAlus bdTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445222; x=1691050022; 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=hJ9OcOwqZEZhIoLNGrov7as0vMS5t1dTfm2Sm9qefJI=; b=IlHdMEw+rgnFb/oOmqdzwjaGP0E+SruBA7w9Wr97O8ui3b1GZXncLmJU8ewdULS2cX twfWr3L8bv22+S9IdEOEeOlqFxkGXaRIrGX6ay/WcfWQht1O13xkMpoNiq2C4Ccn5jB/ QJj3xHwPqDh+TUagjPPuQ0q2KPyrHOoZDBbm34DKgIFdfbQRz7bGE88kPOFUjU1KLA7S 4D0UR2MK5PMN/elSrAIWidGpchVYJ21Aw1gTQcoIQCfdtits/qm23akWA6GlaquCEEgL ogxGCPJhaytrplmN4OX4yyjInr9vYa3buKHQ376181uBihZKa6C8/D7NIoVTelvATerf rf6A== X-Gm-Message-State: ABy/qLZLc+7Ln1t08SXHTE6uLu08Tzfy0LRckq+WURCaaFyqgFJ6FvWy D7/mhHZYWcGDz4KB/0XO7YqWYQ== X-Google-Smtp-Source: APBJJlEQjBlPfpR5V6JAfBPtQGnM4uH9f200On7b1qJi/VneGv5RiS5uPlFi7ClY0YXsCiY0kjcbBw== X-Received: by 2002:aa7:8615:0:b0:681:9fe0:b543 with SMTP id p21-20020aa78615000000b006819fe0b543mr4619538pfn.2.1690445222261; Thu, 27 Jul 2023 01:07:02 -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 06/49] kvm: mmu: dynamically allocate the x86-mmu shrinker Date: Thu, 27 Jul 2023 16:04:19 +0800 Message-Id: <20230727080502.77895-7-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: quoted-printable X-ZohoMail-DKIM: pass (identity @bytedance.com) X-ZM-MESSAGEID: 1690445243840100001 Content-Type: text/plain; charset="utf-8" Use new APIs to dynamically allocate the x86-mmu shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song --- arch/x86/kvm/mmu/mmu.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index ec169f5c7dce..15fc92a24a26 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -6847,11 +6847,7 @@ static unsigned long mmu_shrink_count(struct shrinke= r *shrink, return percpu_counter_read_positive(&kvm_total_used_mmu_pages); } =20 -static struct shrinker mmu_shrinker =3D { - .count_objects =3D mmu_shrink_count, - .scan_objects =3D mmu_shrink_scan, - .seeks =3D DEFAULT_SEEKS * 10, -}; +static struct shrinker *mmu_shrinker; =20 static void mmu_destroy_caches(void) { @@ -6984,10 +6980,16 @@ int kvm_mmu_vendor_module_init(void) if (percpu_counter_init(&kvm_total_used_mmu_pages, 0, GFP_KERNEL)) goto out; =20 - ret =3D register_shrinker(&mmu_shrinker, "x86-mmu"); - if (ret) + mmu_shrinker =3D shrinker_alloc(0, "x86-mmu"); + if (!mmu_shrinker) goto out_shrinker; =20 + mmu_shrinker->count_objects =3D mmu_shrink_count; + mmu_shrinker->scan_objects =3D mmu_shrink_scan; + mmu_shrinker->seeks =3D DEFAULT_SEEKS * 10; + + shrinker_register(mmu_shrinker); + return 0; =20 out_shrinker: @@ -7009,7 +7011,7 @@ void kvm_mmu_vendor_module_exit(void) { mmu_destroy_caches(); percpu_counter_destroy(&kvm_total_used_mmu_pages); - unregister_shrinker(&mmu_shrinker); + shrinker_free(mmu_shrinker); } =20 /* --=20 2.30.2