From patchwork Thu Sep 26 01:35:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13812691 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 AB199CCF9EB for ; Thu, 26 Sep 2024 01:36:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1598D6B00C8; Wed, 25 Sep 2024 21:35:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 108A66B00C9; Wed, 25 Sep 2024 21:35:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC62E6B00CA; Wed, 25 Sep 2024 21:35:37 -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 CCD516B00C8 for ; Wed, 25 Sep 2024 21:35:37 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 85188160755 for ; Thu, 26 Sep 2024 01:35:37 +0000 (UTC) X-FDA: 82605172314.02.C8FB53B Received: from mail-ua1-f74.google.com (mail-ua1-f74.google.com [209.85.222.74]) by imf22.hostedemail.com (Postfix) with ESMTP id C7CDEC000B for ; Thu, 26 Sep 2024 01:35:35 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HwLo5Sf1; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3Zrr0ZgoKCOsWgUbhTUgbaTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--jthoughton.bounces.google.com designates 209.85.222.74 as permitted sender) smtp.mailfrom=3Zrr0ZgoKCOsWgUbhTUgbaTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--jthoughton.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727314437; a=rsa-sha256; cv=none; b=azZcDCRFhsK3IagSaC7QlJduYi0QO5TNskfKmGISid7laIrNpVfJEpbPGX9NGUisU3P1a1 Nxe2oq4w0Mjy3gJHWbJQWqgThdROBLurtAltUCUsS73K5ouQJrcTal44Br93is9vw/1zJE j0lpxZxIJPXX4V78aANwR4DdFuhO5Do= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HwLo5Sf1; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3Zrr0ZgoKCOsWgUbhTUgbaTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--jthoughton.bounces.google.com designates 209.85.222.74 as permitted sender) smtp.mailfrom=3Zrr0ZgoKCOsWgUbhTUgbaTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--jthoughton.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727314437; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mEOlPh0OL8PB5uPzly3STECymuKs02gkKhKmsw1ZgQM=; b=mizhozegVlsrMXeiRfTRHdqCAGd0fB5Y3ImqSA80Rim1V6OWnQqAwf2EmHYMDoeQIw4FQl SviuapBUlBh986+GTP724LJOszUNur5jz61UHjy9b60C8dpyziPAC7Pj6FW8+Pn7cVnelC wklE1mpr5zDZ1wPwTn/sYWVw2RqsTP0= Received: by mail-ua1-f74.google.com with SMTP id a1e0cc1a2514c-848ab182357so373678241.0 for ; Wed, 25 Sep 2024 18:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727314535; x=1727919335; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=mEOlPh0OL8PB5uPzly3STECymuKs02gkKhKmsw1ZgQM=; b=HwLo5Sf12e+W6Ac0mo36vjz46oNQzz/Usqw6Ru/7CUGbFDQEnKkoFi0bIp+flZYVfU KXVFm6qHiDn+1NIV06RIm3wX+m9FZuRCEMnxm2H8d23KqmVID8Dq8ajJOWd1xZg2kTIK 8LfgvixrjgmR/eB4KA8us6/H058XC5E5Vym3GOzJjOgQBxm5Z4EqfMXyGzgWNqIOJExG q9CHszToqZy7sd/tMioOM9jkCeLGTCwON7SNkUvAiycIPQ9i8nDDjGeibMTXd2l9O52u FXubw+l8FKxnodjD79tVR7KE6PEx3lfA1qS9HU4syOkG3hGOkOBOMUdFfbreT+11ZF8x go/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727314535; x=1727919335; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mEOlPh0OL8PB5uPzly3STECymuKs02gkKhKmsw1ZgQM=; b=ZDWshzARPpRxc2+EcN6v2iM8m73hMcbvY6+iuP0VH+VON9OwyQkxZMQsWnRUkH9p7D gCmFTsQaDLn5+bKyIhavQF7GEQ591C6BJ67WJgn6t/TabLnxGxl+GLxxZFp6WwF71eY8 gKDpKE2rHru4E4HjxOyGSZNRjBFuwrjYxzRSNGajP2xVrZQtsfSJ9Tz0V/yeZl/DGI5K Xt+d7SZTrcMyc9wUQpQNV/wlzEuq+vhzNf5el1q9DXVxoNxHwlCPCrezMoAbOWBI0z5o 9WeTIIoLj+rZURJAfczHT/CsakyYxmxrFTnc0Z8RgUx0kcir+2dbujz/87/FUtkj1tZ8 idzg== X-Forwarded-Encrypted: i=1; AJvYcCXGD9IIB41waVpMhGAcZ+yQBt0CZuDAdOgF5t6Th+2mnWHxRey+Iyrt8o4vS+ltTdHw9a2yhn60tA==@kvack.org X-Gm-Message-State: AOJu0YyvhJpNs8f7PaNVw9M55UKe5zZxt1FM8uyz6zl+jo7xi7Wp6Lyj 3W+RHgJWsdSYNeYnzReURFfyn0dqtkRtoit5kEYgfUV024ZceNTtJwdqnQsIy96zfMn1XRtl6/v tmq/BRx8K1BmjWsWqDw== X-Google-Smtp-Source: AGHT+IEMx7yb7oZJxjUcxiV+ubu09F3MgF2iO9wA9qRkGH/snKIzoGYYivc2BPhRyOg04he4NRTTUUTncXdmo6QX X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:13d:fb22:ac12:a84b]) (user=jthoughton job=sendgmr) by 2002:ab0:71d3:0:b0:84e:89c5:3bdf with SMTP id a1e0cc1a2514c-84e9940fb1bmr4272241.0.1727314534796; Wed, 25 Sep 2024 18:35:34 -0700 (PDT) Date: Thu, 26 Sep 2024 01:35:04 +0000 In-Reply-To: <20240926013506.860253-1-jthoughton@google.com> Mime-Version: 1.0 References: <20240926013506.860253-1-jthoughton@google.com> X-Mailer: git-send-email 2.46.0.792.g87dc391469-goog Message-ID: <20240926013506.860253-17-jthoughton@google.com> Subject: [PATCH v7 16/18] KVM: x86/mmu: Enable has_fast_aging From: James Houghton To: Sean Christopherson , Paolo Bonzini Cc: Andrew Morton , David Matlack , David Rientjes , James Houghton , Jason Gunthorpe , Jonathan Corbet , Marc Zyngier , Oliver Upton , Wei Xu , Yu Zhao , Axel Rasmussen , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C7CDEC000B X-Stat-Signature: 13h5k46xxcsp5nccfanjmkb1mh3sqib4 X-Rspam-User: X-HE-Tag: 1727314535-303356 X-HE-Meta: U2FsdGVkX1/kcIFQHA2rh08kChgDYUAd1r8PcbAAgQ/pUXY/7UCF6Dra9BqQjlVVZnlBJ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yW4KmVaOggE41B7Nr4utQE+8OINGoJtRwcFuKasQc4wh3kl8ytzez/RgavawqQ2DV0N5EhxMo3HptNVpPMaovu5FrmO6A1efenqBgRYNVcXxLy6cl2m1fJpHsi+D0ht6v+YvORKPjX9PsQj49WTxDqjQzlj7heJpB7P72Otsg/vp4Vy+Xhi3+0PhiIGbf1ps8aAEz0OVHDMJpj3YEkbqotn8eMDxvs4iUbUI6+M9Gw+q15Cek0s+65YWdla4N4Q1m6VpVghayZEtdAP5RQtmPJBgm9xKvhITGTI295B6GoGMVBiOTzwagnj3uXSGgtuw1PFehzYcBbPBKDK7teJbHQS2xxbVS/e0n4iiRU2b09wPFIaScy5EQmwnrfhoY3NMmtMyzpL36coknPF/EpugCr09iYBBida/VEPpjkqL0wWeCJR/MBRkSh5DXPH7G4vcNR17zw/O1pAYGt1A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Because the x86 MMU locklessly implements fast_only versions of kvm_test_age_gfn and kvm_age_gfn, we can advertise support for has_fast_aging to allow MGLRU to quickly find better eviction candidates. There is one case where the MMU is not 100% accurate: for the shadow MMU, when A/D bits are not in use, young sptes will never be aged with the fast_only kvm_age_gfn. In this case, such pages will consistently appear young, so they will be the least likely eviction candidates. Signed-off-by: James Houghton --- arch/x86/kvm/mmu/mmu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index f47bd88b55e3..1798e3853d27 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -7708,6 +7708,8 @@ int kvm_mmu_post_init_vm(struct kvm *kvm) { int err; + kvm->mmu_notifier.has_fast_aging = true; + if (nx_hugepage_mitigation_hard_disabled) return 0;