Message ID | 20230911094444.68966-3-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 0E0EFEE7FF4 for <linux-mm@archiver.kernel.org>; Mon, 11 Sep 2023 09:45:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A6F606B019A; Mon, 11 Sep 2023 05:45:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1F4F6B019B; Mon, 11 Sep 2023 05:45:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9108B6B019C; Mon, 11 Sep 2023 05:45:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 805306B019A for <linux-mm@kvack.org>; Mon, 11 Sep 2023 05:45:27 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 534B340908 for <linux-mm@kvack.org>; Mon, 11 Sep 2023 09:45:27 +0000 (UTC) X-FDA: 81223833894.28.AB00839 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf10.hostedemail.com (Postfix) with ESMTP id 7E0DBC0008 for <linux-mm@kvack.org>; Mon, 11 Sep 2023 09:45:25 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=LPxQp7qZ; spf=pass (imf10.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.181 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=1694425525; a=rsa-sha256; cv=none; b=wrIteeUz1wF/YC+B7FynYZy/06mBfdZKYZ9FKKNO5YX1XVKA+CqELYjskwxezruyZ2J79M oPuQMnwjJKgLoPs9GSIFaivkI1sXtEW/kWibYR6d1wXcMry7iZCsPMQJDSdTKzBnVqB1SB pt/P7mSM/cma3oDWyj2Yj+2zqmoA3AQ= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=LPxQp7qZ; spf=pass (imf10.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.181 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=1694425525; 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=igTSDR/vKXgPwxt8Nsf/dMSfVCUUURBFbV4iu+jj8kI=; b=jX6rimxGFqdY4HieC19FSYv+Nwhtm+/znkDWljE/kXgeherKEI/DHZGDI6z9ATqDI5Yg6O Mhp3RarYAa8Ygzn9hdOnRetkfRCSjx1pb4gHzTdtQcAGYUBIOQW/xYOunwKeSlFz7bdmEk oDZW2X73ms82z9IdERySVzXv/yUeV8Y= Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1bf1876ef69so11137135ad.1 for <linux-mm@kvack.org>; Mon, 11 Sep 2023 02:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1694425524; x=1695030324; darn=kvack.org; 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=igTSDR/vKXgPwxt8Nsf/dMSfVCUUURBFbV4iu+jj8kI=; b=LPxQp7qZ35iqC2pFP2+qB4poYnKjIU0iZ6Qez0JPK9IWwZUfQJwc09mrGSUS8vu23g IRJrJhhPlqKA0KxuPkoyTd/TiWbpe6RiXKVY/JtHTNSBCO3wca2CylBjBt4dFaARYj7f oiHjoPxfz0mlUpO2hR3xKZxIbZ7lPjgpFGeB2qpXeIQorFdL+bXs6bUgrsGX0bWorMVF 9USaKHnpffsaEZVUl45CGYftK7XRRREkcv+e8uhKbWrRdbv6hKUBBVHBQjTTZwjQ+bqH HhfA0DLpJLCOgsRsh117sEC5eI4gRQhHRYXD310xFx3fBKPN/XfeYFZMKQC873fKAhSG pL+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694425524; x=1695030324; 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=igTSDR/vKXgPwxt8Nsf/dMSfVCUUURBFbV4iu+jj8kI=; b=iJCLBjreYAvqkF+0423ERHdTRTfpfwL+fek54iRAjojrUNtNw5/36kAtnN6vBfd75f uZwdwBLSr2Jfx8zqNssD8K2Rj6Ji8eDSvEZ7fHFetCxCpaav+7ElSVaq8233Jlc3Uy5R Ci312GQk9ytFbIjdW+chTE1+0dBJTTWmHg0Moj+B/AZEij1Ucm1FIlsEQ4vXOp4S01jP JBCOMEfDRQRbMFwfqd8xRQGmjubO1ign4mOAsEg6+oDxdMQsDUOjCKWB2spQZX+qZVry BC2IWUlghIQPIPJnMroiBankApYQaIAooDS6NStBqGpjDYyeSqOog6tVEgalDiPfdtZv t9Kw== X-Gm-Message-State: AOJu0YwKIx0KdCWw9G/2amH7rw3KaWwOo56TCJR9JUcM83AnC2GyJLvd Ozco24AXmiy08tY1OLlGxIQlUA== X-Google-Smtp-Source: AGHT+IGwCbRmnmWBiffPOJTl07r9rRbQgpxezDjUTflYdm1L6Q4G0DETGg6o4mxqN/MXYenR4q9s6g== X-Received: by 2002:a17:902:e5c7:b0:1c1:fc5c:b34a with SMTP id u7-20020a170902e5c700b001c1fc5cb34amr10655164plf.3.1694425524206; Mon, 11 Sep 2023 02:45:24 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id az7-20020a170902a58700b001bdc2fdcf7esm5988188plb.129.2023.09.11.02.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 02:45:23 -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, linux-fsdevel@vger.kernel.org, Qi Zheng <zhengqi.arch@bytedance.com>, Muchun Song <songmuchun@bytedance.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, kvm@vger.kernel.org, x86@kernel.org Subject: [PATCH v6 02/45] kvm: mmu: dynamically allocate the x86-mmu shrinker Date: Mon, 11 Sep 2023 17:44:01 +0800 Message-Id: <20230911094444.68966-3-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230911094444.68966-1-zhengqi.arch@bytedance.com> References: <20230911094444.68966-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 7E0DBC0008 X-Stat-Signature: wm6c3mb9urcuom8a4w6m3hdqymc5xhuw X-Rspam-User: X-HE-Tag: 1694425525-516701 X-HE-Meta: U2Fs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MD9kjz69e5jNnI8NtCmLLlJAxBLn1NjnzQGBQNX1d3CAVY8pDKfLcJmQShzws0Ux8QA9qQNIMdA0Vr9Rn7zFqWg+4Ss8HuS2X07xg8aidvBalnxssDUvnt1ZMApZ94W8BwlJTDWUj0cF44s8MznEASNE5EHByJcayXM4vL+ATLzimioBm3BYbYYWVFZrB49+LXbKbGzU4zPoV7LGBSwMODKwHbvdVkgj54Nqu31EvQxhLF3KihFtAFUmfbsuybuXRoMXPqwhbkqIAh/Lr9ooc+IEOQn0mtMJptrxoFW8fuY4ixKDchr7AfwvbLNdRHClSkfbLmCyZUD1QdVzfcaBSRNlVdM6WJjsbCVuU68D40PHZqRjqK6aWBrXRrOCVKmOrbFwyhdGOCrhvTPuDhX8Pplku6FrsrfDiNUsUkOdSVbJlVzru0oI4niolsqqPrLeO8H/TnXv8= 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 e1d011c67cc6..9252f2e7afbc 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -6796,11 +6796,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) { @@ -6933,10 +6929,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: @@ -6958,7 +6960,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); } /*