From mboxrd@z Thu Jan 1 00:00:00 1970 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 E2873C2BD09 for ; Fri, 12 Jul 2024 15:06:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3656F6B0089; Fri, 12 Jul 2024 11:06:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3153C6B008A; Fri, 12 Jul 2024 11:06:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 203FB6B008C; Fri, 12 Jul 2024 11:06:48 -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 0244F6B0089 for ; Fri, 12 Jul 2024 11:06:47 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A4162C0BE2 for ; Fri, 12 Jul 2024 15:06:47 +0000 (UTC) X-FDA: 82331427654.09.E974431 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf19.hostedemail.com (Postfix) with ESMTP id CC7C31A0033 for ; Fri, 12 Jul 2024 15:06:45 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=0OPeG3oL; spf=pass (imf19.hostedemail.com: domain of 3hEaRZgYKCJEDzv84x19916z.x97638FI-775Gvx5.9C1@flex--seanjc.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3hEaRZgYKCJEDzv84x19916z.x97638FI-775Gvx5.9C1@flex--seanjc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720796779; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZWyWnNJQfLis8OltmFTp+D+i2eRVmZlaO2glliGRcpM=; b=vQhrMTtXiz54ezDlmelTV56UUxDOF+fdb9UuPmoz+C0UHy+BXXSgjf44nZnlPxiyk2aq4B Wb0NL8I4Zyuk6H/jq7P59UhKpFjrxPLkNE1fcOnPLP/UD6xYyBBjfYIU8/v3O6D0dWhGBW y2zQTtNJMDLol5GqHATVv7sCX3MwA8I= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=0OPeG3oL; spf=pass (imf19.hostedemail.com: domain of 3hEaRZgYKCJEDzv84x19916z.x97638FI-775Gvx5.9C1@flex--seanjc.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3hEaRZgYKCJEDzv84x19916z.x97638FI-775Gvx5.9C1@flex--seanjc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720796779; a=rsa-sha256; cv=none; b=Rq8gMOIJDEaXgMsDBbmXgUqEaTeYhgukyVqNt993eSTsD53ZfG8i/l1KWO1qhU1tbZTwmU Xt3zaOFMWT6tVb9SQOAfGLyZF4BoGDEGHj86KreiAmCDAVnZzNtZzeaYPrRou8cDWM299V ZPpGldxBsIxMTjYiMPx2Y7GGfuml/+s= Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-1fb0d545c60so17109805ad.2 for ; Fri, 12 Jul 2024 08:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720796804; x=1721401604; darn=kvack.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=ZWyWnNJQfLis8OltmFTp+D+i2eRVmZlaO2glliGRcpM=; b=0OPeG3oLn5J+X1PD2stu571IYlfq+kmTyR7CtvnlL2EJo16mvDDiPebUvW+LSTjXw7 ecNpPe48gYEkduSUqeEZMlL8mo6K3qra280ynKHQZS4Ot50GgXMVGEOwtiySqsPhJ9zc cDvRWyr3UzPHs1ONU1/C47/b7yCLhzqn1cBd3vDhAoKrKytia8QD4ZTV5xHH9F0uXMjn 5UJD2pGvPAgfD7Lo2Ft7tBS3enzMLqK1A/B6vohZT1khBmJgCl6KDTk1kRrFHW+rJupe XdXrrzVc9GQGJH8hSXm3O/JdHTiauuNl7I7f06L7h11SxqvQfrsQujtk50iCi7tTj6Hq rA/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720796804; x=1721401604; h=content-transfer-encoding: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=ZWyWnNJQfLis8OltmFTp+D+i2eRVmZlaO2glliGRcpM=; b=XYjQB1RZ+2nIXQa6atV/x2VnI3hYknDhGFYw4Ua08ND8taJ8uDc6pn9XqHl3zOLczP duGOwzdmF2i8gkwGt0QH/U+2BiE9+R0rlKrz7G333XtHNPANwVoGyk8u65Tw6QRdQJNr eodZSYoGFuizQZ05sBpheLpeki/+4ehUJVXrWAsZzEyFFN+dE2tBOJUKwUwMtT6OnH8R AiSNnu3uUy3avzzyd6w28YsjYQWY+BMKxuZDYyOMd7sA55Sk0DVNHkGtSIugkUJZD2uh 8nJxAgBI4mHNuL6MllN+2jHQ0MJhcjWphbkC7KOgeRbOh3QTsy9SJAWg4TY/7ToR0Zfb AN9Q== X-Forwarded-Encrypted: i=1; AJvYcCWDAb0LsLYoapEQbFCRfZFgQGShL06fd+H8Y1O/bMCZJ0YZ3uf1B4pqQiNcnbgo9DMMEu1zyMjGefMSOWxGAwlAp+w= X-Gm-Message-State: AOJu0YwNvdNBt0jD+aGc73o+VLCb5MprOf2SzepCZic6OPREz5Mwgycu b7YTfuQyfeS6g3RNFPcVyjrW6NU2nyUFG4OT5Gr5Kwl4j12td6vLwzdZcwzPxWQ5e1v8+Dowdhd CFg== X-Google-Smtp-Source: AGHT+IGDfGxGyoOOVJXHRxv/7+Ukhncjw5VneesB3o9h2h6VbTln8g5EPSE4uE3ENM6QWIp1Ic1twbCkqos= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:ec8b:b0:1fb:415d:81c5 with SMTP id d9443c01a7336-1fbb6eb7039mr251225ad.8.1720796804378; Fri, 12 Jul 2024 08:06:44 -0700 (PDT) Date: Fri, 12 Jul 2024 08:06:42 -0700 In-Reply-To: Mime-Version: 1.0 References: Message-ID: Subject: Re: [PATCH v5 4/9] mm: Add test_clear_young_fast_only MMU notifier From: Sean Christopherson To: James Houghton Cc: Yu Zhao , Andrew Morton , Paolo Bonzini , Ankit Agrawal , Axel Rasmussen , Catalin Marinas , David Matlack , David Rientjes , James Morse , Jonathan Corbet , Marc Zyngier , Oliver Upton , Raghavendra Rao Ananta , Ryan Roberts , Shaoqin Huang , Suzuki K Poulose , Wei Xu , Will Deacon , Zenghui Yu , kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: ug4upbd8rymatfifuww69j8fe4zd9dd5 X-Rspam-User: X-Rspamd-Queue-Id: CC7C31A0033 X-Rspamd-Server: rspam02 X-HE-Tag: 1720796805-449651 X-HE-Meta: U2FsdGVkX19M94vN+EFlwf4uRddFZqmEm0zCoBCEn1cYoA822jtnMJ7sEdVd3AkzAv6sDhHZCjo/56YNGHxoJBxEMutse2r3QjZkh0ahKFIrpWVSCR3f4ahssUgiYV8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TGa4iAb/bHp+jQCmLC4lmjCA2ROtsclbdmVdm6Pj6c1Ft2jNJYmYD2Hq0JuJpXnjgS6WFuoOCqgYhsEhY+6dJNlz8Kq0i0E1mk+Zx2D2efzP+NmYYwaV0o0zUTwVwZNh6IZ4JnU3n9C0reNtg73Tmhpt0h4YPFRTabYzO6U4DQFp4s62WonWsj04OMU3C9XjZZ58qFB1oFSZyh2qBLFvu9WILobBri+NQ8TdaI2VfcncPqIbG7C+aof7cjAJUNjRRIZksIKxQ/myL9d0nyL6cPy2K0ZIbdzBvBqy6OtnaFiUkrM/2PduzbjSgSdDLZ9PuMeZtCd7y7sIT/EykFb6kDbVgZGFD8i6SdgROwt3GXodKFQxjFPO1ZuLQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000769, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Jul 10, 2024, James Houghton wrote: > On Tue, Jul 9, 2024 at 10:49=E2=80=AFAM Sean Christopherson wrote: > > > > On Mon, Jul 08, 2024, James Houghton wrote: > > > On Fri, Jun 28, 2024 at 7:38=E2=80=AFPM James Houghton wrote: > > > > > > > > On Mon, Jun 17, 2024 at 11:37=E2=80=AFAM Sean Christopherson wrote: > > > I still don't think we should get rid of the WAS_FAST stuff. > > > > I do :-) > > > > > The assumption that the L1 VM will almost never share pages between L= 2 > > > VMs is questionable. The real question becomes: do we care to have > > > accurate age information for this case? I think so. > > > > I think you're conflating two different things. WAS_FAST isn't about a= ccuracy, > > it's about supporting lookaround in conditionally fast secondary MMUs. > > > > Accuracy only comes into play when we're talking about the last-minute = check, > > which, IIUC, has nothing to do with WAS_FAST because any potential look= around has > > already been performed. >=20 > Sorry, I thought you meant: have the MMU notifier only ever be > lockless (when tdp_mmu_enabled), and just return a potentially wrong > result in the unlikely case that L1 is sharing pages between L2s. >=20 > I think it's totally fine to just drop WAS_FAST. So then we can either > do look-around (1) always, or (2) only when there is a secondary MMU > with has_fast_aging. (2) is pretty simple, I'll just do that. >=20 > We can add some shadow MMU lockless support later to make the > look-around not as useless for the nested TDP case. ... > > Adding the locking isn't actually all that difficult, with the *huge* c= aveat that > > the below patch is compile-tested only. The vast majority of the churn= is to make > > it so existing code ignores the new KVM_RMAP_LOCKED bit. >=20 > This is very interesting, thanks for laying out how this could be > done. I don't want to hold this series up on getting the details of > the shadow MMU lockless walk exactly right. :) ... > 1. Drop the WAS_FAST complexity. > 2. Add a function like mm_has_fast_aging_notifiers(), use that to > determine if we should be doing look-around. I would prefer a flag over a function. Long-term, if my pseudo-lockless rm= ap idea pans out, KVM can set the flag during VM creation. Until then, KVM ca= n set the flag during creation and then toggle it in (un)account_shadowed(). Rac= es will be possible, but they should be extremely rare and quite benign, all t= hings considered.