Message ID | 20230824034304.37411-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 7AC7FC71145 for <linux-mm@archiver.kernel.org>; Thu, 24 Aug 2023 03:44:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18D7228006F; Wed, 23 Aug 2023 23:44:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13D058E0011; Wed, 23 Aug 2023 23:44:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 004DA28006F; Wed, 23 Aug 2023 23:44:07 -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 E53658E0011 for <linux-mm@kvack.org>; Wed, 23 Aug 2023 23:44:07 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8ED9BA0195 for <linux-mm@kvack.org>; Thu, 24 Aug 2023 03:44:07 +0000 (UTC) X-FDA: 81157604934.07.D1D3EDF Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) by imf01.hostedemail.com (Postfix) with ESMTP id CD79D4000F for <linux-mm@kvack.org>; Thu, 24 Aug 2023 03:44:04 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=OsYjiPgR; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf01.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.167.176 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692848644; 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=5bZcZFXaHuChrX7nBw9iDgTdYuFksNGnDce9dNrUq+rXKDJaGYkYRC0IKQmiSCMEOEARaB 8tiQYz8rkWEPVlXVy9WDdZBlK7taFpFhAIZAumnwwgxYgPv4EMEHqY5EFlsa2ZtShdbwiu 6L0V7G+cOH14MkbmKkfiXjcp/pnkvcA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=OsYjiPgR; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf01.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.167.176 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692848644; a=rsa-sha256; cv=none; b=qgQcNLSZrTTzxKtfNuDrs/ouOu1/IRxm6CaYGHb4LzGd1afK0h7JzgZQFPkriI2ZOp0uYk sWG6bJ06Cu9wTGlNPboPLDzEP/svXHHmYY4swubKopad7M1zYyY2O09QEytgCUuyhI7LCO pbepXVKgq8omS0zSiUByPtS1GpwxMr0= Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3a707bc2397so848016b6e.0 for <linux-mm@kvack.org>; Wed, 23 Aug 2023 20:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1692848644; x=1693453444; 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=OsYjiPgRzrTeETdk6GAchasY+z5fr/eZhmMBlkdIascYBtVVr8yTfuT5MPzgyaDuTX GP27vx5e3ZRKiWmF8godLPx25zsGkXM7WpgRAlINmRy7OtyQBZMd0woJ7eRBd8ABjz0B gg0KXTzJI21aCRCVIqH7SIRY1+q2UC1Eevp1gZIrFwnGhfMs71V461lgE1bLRRacaMrl VvaxQGpwJpwk7Ore7I/VQ0LQeEZ8Yda/FdaKJLsSrCojTzfm74tjEvkxxRIsttzCumIH JYDNB092mTWiwSCXEE9fsozeBAYzex4vsPbHJSxRaP6Kzq97D+z6ONh9Db9HAMNes38c GNwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692848644; x=1693453444; 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=C03DASX5Fci0DP366tM3r2Utw702FDdBpZ6nPR2xstFvZ0QhIC+3LFStn64yICcjK9 7RuIe0xVttoxRlCJ4+bgMv13e4uKZzE+DAXk5l/XVW2ydA+FSHilKKXD9t6ZxFjCMro2 Vs1fh/1S3iz9xm8meQuLbYtXo3FVtBBdNhgyLEBFu/PJILDiFWd4QZ/R284ypRZoy53N dGNNTpzpkK1qpuhv+nOTHZ+6Pjx8/OOI5tOtksFzasGXVK2wjxUT++UC1X2h621IWjFE Y9lbFF0JzAAu6scwz6xwqLwFH2AvhFaHsTVcp4SQakw9j69OY5YIXcU2xDtyWLY2iKSW +cpQ== X-Gm-Message-State: AOJu0YzrO1IqHeY6Av3wv/OzB5Rs4ibHevvTINDkXfInl/nGr8SmtCix 7wgcTShklX7tfIg95PWMVCgWVA== X-Google-Smtp-Source: AGHT+IEujkxb/oLvenG0xAi0WFnbnLyYwhJyu7dzjt01VW0xqm24WtRNYpeYKjaTV28dKNThLBHLgg== X-Received: by 2002:a05:6808:152a:b0:3a7:72e2:3262 with SMTP id u42-20020a056808152a00b003a772e23262mr17143493oiw.5.1692848644029; Wed, 23 Aug 2023 20:44:04 -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.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 20:44:03 -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 v5 02/45] kvm: mmu: dynamically allocate the x86-mmu shrinker Date: Thu, 24 Aug 2023 11:42:21 +0800 Message-Id: <20230824034304.37411-3-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 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CD79D4000F X-Stat-Signature: najunmd464ctjcxty459xgujqs34ujjx X-HE-Tag: 1692848644-647573 X-HE-Meta: U2FsdGVkX1+Wv/HFgXFS61R198ZPFAOmM+kXzXrB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Bjdf5QOeXYdbKez63gn6EsqSNlliny8YF9aSpgDEXPpKhJcLpLeHq9QMpuWTXlKGPIWqzL5uvW42cKBdbrmpBm7V7K9/3MytA5M40s9Mwy8PHc5h4HOEtJes2nUQ+1CviNgIwYOCk4tcNIz3kQw8hsPxGm4CumlrFh4LJe8UEo8P1RxzQCZmU7fedE+bcZpfXbD2bxSYYbB2Wb2hO1dRW52Xc84XJQ25HR39JqdKsDINMPJDWpPiGw3MoGGuJ60aot04hkt1rwgY+b9LO1cXd3+ml2llez8q7Vq0GeXvLKUQIg85SrGwVrgy9bwGeehljFEh3ijNrzZS/uPKxxV6QrAC4WpODtDzGtbo9IoF9lDDSHlfY/+RzcemnagBPIDSKuTdNBo4ZImAE= 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); } /*