Message ID | 20230727080502.77895-7-zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 B2051C0015E for <linux-mm@archiver.kernel.org>; Thu, 27 Jul 2023 08:07:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 523B96B0075; Thu, 27 Jul 2023 04:07:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D4228D0001; Thu, 27 Jul 2023 04:07:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3745B6B0083; Thu, 27 Jul 2023 04:07:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 291B76B0075 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 04:07:10 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4C972B2AA4 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 08:07:05 +0000 (UTC) X-FDA: 81056661210.09.D4C866B Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf25.hostedemail.com (Postfix) with ESMTP id 64437A001B for <linux-mm@kvack.org>; Thu, 27 Jul 2023 08:07:03 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=AioCATUl; spf=pass (imf25.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690445223; a=rsa-sha256; cv=none; b=siGTxdll3FwghwG4Qc3IjoTd95HLFJVLZ6UJl6vsrBEJLA+Mp16ObuTMLlUxlSQtFChQMj SZsVWAJCziyinR2gZf00ViqXGG6DVVunuehyHXG5YCl8jpJnViiAf7mpXz9sk4lRg5aY4H ZdPKcvB3giYwImdpvR2r/0oN8Ujo6TE= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=AioCATUl; spf=pass (imf25.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.176 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=1690445223; 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=hJ9OcOwqZEZhIoLNGrov7as0vMS5t1dTfm2Sm9qefJI=; b=NfFdCEFaqt18eteMcC/N/zg6eImeud87k3qGJBEgCVdPQ+R4HkmAOVJ420M5eDE+QVmE5D smKft89hSWLXZKqfHY4XkkQ1g4uVfdpzceK0yQcaB77vrp2ywTcf0JU9ySwaJk3ivoyrJ6 W/sJQFv9FyBaPc6x11TfIb57nFPMLpM= Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6862d4a1376so188381b3a.0 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 01:07:03 -0700 (PDT) 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=M+UynH9GzAqcReX6ysuJ95bWedHu2pAkHEkEvJw5OxIwib1goKvQZb2X1wzhDzYU0b QTuL9K0/xUBlM0nJHlewU4qRgTfcQcWyfDD083URInO3veK/LDgK4SYIK+Q2IuY/KeKi gbuES7kOjajQOb3BZKd/YJWH8YJ+qRsL7BV7W/xc8/LzshXSsB0uR7cfByNgGBGKa/2L ZG06px27y9HVC8BJgudTazHUBoW7UsEjkb8PTESP1kXPxZAScTi4IBNJPFpt8W8VrUn/ XbmXCG7uw2W8RjfTi/13plmo/Y+kFgXvlSqYffMpP70YcYU+mCkiHrc6ega5UlEE/KXA zlyw== X-Gm-Message-State: ABy/qLbIhhd7fYBXkwILqtfTww3M147y3/Na4cQQhkY1EwaNq7xJTOIQ 7tG4SAuYKGOw/bDIPGbPXr2yXQ== 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) 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) From: Qi Zheng <zhengqi.arch@bytedance.com> 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 <zhengqi.arch@bytedance.com>, Muchun Song <songmuchun@bytedance.com> 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: 8bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 64437A001B X-Stat-Signature: mg9xdnwx8egpn63u5y8iidcs7444xmpq X-Rspam-User: X-HE-Tag: 1690445223-878960 X-HE-Meta: U2FsdGVkX1+07CTRvMAI5vxvkQTrrxsn8wroBBRiMm443eMm4nLs/6PMUy29Xb0sr7ozYp3FYJCbZqcK3uOttHEsFNyE410qgeI1nBd5rBDXRvcKZgMEccVyp429GoqwpZPEWBBD4geKRoh8R8WDw6wshkydfaLTBj8JVr76JiLFfSf8arKPoz/A139ebynxdbgddRbB6q52sbL0+NHB2s4//2TyHbijGU7VZQcjmMkcHe9O8lTGRkPzhHrGM/xfY9WZfF7fOv7iKyMilxR56ppO+fjf/n0VYXZoNCeVq7331N6CIIZWhz1+e8oVzy5Wru9W0k0wLXwJa21RgTYyllTGFIShRjajcCNpQJEP/gKPxDsr4ld8fYaredLnf8GCjvLuS34nQiBFftL29Vgki6wbXaP6ed/sgBa5/Y6lpRmoM1tFp8y1W6GnyBU2O9a+rOoylikvM3Xpirk8r/Bg/bbajhbmWNdnST4dBpZUKJ46VoTtS7uRp5KvQKxNK9ahZ14hH+PfybiZDfNuD+2gDVJeCpR8T+8RUQwtjDjmrVnM/n2X5rc0yS8KeC/s4Sb41Sys3nf0zHoOigbDIjL7g5sWul6Q5kkGW6/F6siErRVTZSQvmrNgXT0cMnaicpT1unn9cphhCACFW4UImqQr8xGYkKEomr2qr8zqUxKFH7SsNIC/biJtX386bIOxV7l5RCl+n3toXnGTXmpHEHJfn+6xDO7XMytJg5m3YYPCymHZXP0NAP/79nBI9+dV46hUwAhBeLz8jITDipK6sN4vjAzk1g6UEc7Q1k+SH9yrLa3dpMdyyp3g6BZIFeUPDbG8A9FOMoOUs++NaaVRN3ahBznb/+CRuyNGO8QOTdI+7Fjdlb7vzlhW+QCXwFxwwu1tqoYhCDrM9IB/Vs9pJVKDTAxo4maTdh/t2+l7hg7D1EpJ/sQXJf7cgM4pfUyMqD9/Ys5/HcRBdryZonuclTj 2tBWhxl7 t5L2rxYBdz7vUpFOFPBLDSMudH5uWnzg5/RM6fNIVLGLc4rSKbb3VuBE5FPttuZp60a79o7Joo3BO7WiDVpR07y6dl2QVscPWcanNc3BJ4sSkb8kpPlJsU8dhKY1j5pqNH8rmz1Sg+5/TMUSOHe/V2E++E5HOsOh9I7FGQTz8hyZ84WgSTQdu3jS6r3cX5rHGsYnhg88EzC62OhNsmm+Ot6WUCiWHu1+w12iKr9FrXFhNvkX078vCrpmgxSdb1A5aAH4+JgXZH4OEK3U3p3EzaUWj5HGoEwbHiG9aZ1fNdux0/IgOaPxo5Y19IYXSB+V53psIIP0+l3+vVSu8NMooEqpPQvlohODXtO53m+SqnXrwTBjAWAEANJQlw7VPAGZxbjcOT9D4LWh+bjt+M4cKeGsNIuI9WbKo/msD 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: <linux-mm.kvack.org> |
Series |
use refcount+RCU method to implement lockless slab shrink
|
expand
|
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 shrinker *shrink, return percpu_counter_read_positive(&kvm_total_used_mmu_pages); } -static struct shrinker mmu_shrinker = { - .count_objects = mmu_shrink_count, - .scan_objects = mmu_shrink_scan, - .seeks = DEFAULT_SEEKS * 10, -}; +static struct shrinker *mmu_shrinker; 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; - ret = register_shrinker(&mmu_shrinker, "x86-mmu"); - if (ret) + mmu_shrinker = shrinker_alloc(0, "x86-mmu"); + if (!mmu_shrinker) goto out_shrinker; + mmu_shrinker->count_objects = mmu_shrink_count; + mmu_shrinker->scan_objects = mmu_shrink_scan; + mmu_shrinker->seeks = DEFAULT_SEEKS * 10; + + shrinker_register(mmu_shrinker); + return 0; 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); } /*