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 85B28C3DA7F for ; Mon, 5 Aug 2024 16:54:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0912F6B008A; Mon, 5 Aug 2024 12:54:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 069176B0093; Mon, 5 Aug 2024 12:54:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E4AEA6B00A0; Mon, 5 Aug 2024 12:54:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C6B136B008A for ; Mon, 5 Aug 2024 12:54:50 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 75428121C04 for ; Mon, 5 Aug 2024 16:54:50 +0000 (UTC) X-FDA: 82418791140.24.611FCBA Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) by imf06.hostedemail.com (Postfix) with ESMTP id A18CA180015 for ; Mon, 5 Aug 2024 16:54:48 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=K6GfMHIg; spf=pass (imf06.hostedemail.com: domain of jthoughton@google.com designates 209.85.160.175 as permitted sender) smtp.mailfrom=jthoughton@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=1722876828; 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=w+EjPosfkeXziba69Qb6GXWNK9P7pF1IIw+Hux9jBR8=; b=hLk2ojaIjeYw93b6RI2GGvrVfVDosGUGPYzkUphqtP52KyBA4T4wcHBdOzjKVqWGGhwZ/I PwSDF6b+L90YXIYJbe9VcLCWq1csRqYJJyVCTSTzg6ccxtn/SGbxA/0E0pd8eAGIh1RecP nx9tgbiNf1iKyKFL6hSEoDVaEvNK/NI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722876828; a=rsa-sha256; cv=none; b=oBEgbqziFkJLKtFlFLWT2Zf20477WahOCv2UVFQzSyrT9GpuS4UR0KyHsnjb0PJEVr4uyn ta0TCQpkYA0mwB2SvL2hanV0lWIxM7K5Wzwo58IJCySBDN3egpSfxEkNnShgyeWE7ZmkFO R/ODxXdF9IV4VKeZa6l60FdsAp3d/e8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=K6GfMHIg; spf=pass (imf06.hostedemail.com: domain of jthoughton@google.com designates 209.85.160.175 as permitted sender) smtp.mailfrom=jthoughton@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-44fdc70e695so12091cf.0 for ; Mon, 05 Aug 2024 09:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722876888; x=1723481688; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=w+EjPosfkeXziba69Qb6GXWNK9P7pF1IIw+Hux9jBR8=; b=K6GfMHIgZq3cWqDrfNeW7rWfcXsVt5TWANnXwi4RuWwuZ56KKB/kUj1auYCciEqS3L X8sJiPG0T12ZwC61Usj9ZOffCD1T2LWuJUPSow8Lho+fszQdUNpl9W9pgK8SiD8aDtsH EtlJCFk6PCBdFMzRKIJjPgo7Lfj7yb6hPsSgQBjldI0+UGIswRCTNWXS7mGviIZDYwS5 NTjv1te5LYgbnQo/OXXa0dpF9n1PXqvtriBSskH5RoM8iLyYI2n7AHFgwAoCrlNbOAVY TtgPSb+6IsqNht680q+YAc+9BOmN2SE/FGbElFK9Gbl4rd6livp3215xSMCR4yP/jN8k aV0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722876888; x=1723481688; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w+EjPosfkeXziba69Qb6GXWNK9P7pF1IIw+Hux9jBR8=; b=v0LqKrw4iTedjMi5FPXAt4Ie6fY0cGMyn1Rnqw2f2RjQJWxs1ZVO+qooKtsMShuKZZ TqufdSSBJTajskAAD2am95RpOYL0HkehL2QwUScotDeEwpa/HmilxKYZkV2+VkNvjYKY g/lzN3HODeP0h9E2VSOXrK1tkaU6PtLqxNPNVevu/Oril0tZxe0Gs3UrcEZ0yOiqJBwA SzH/K9g0gnItIxacCDExgwr+bXXat1cxf4Xnuym/jI1cyucOoLz7EIa2sTH7z8vtQJEP z5Tu1EuU47pBV90xGajcv9GWFevaw22XKobf+CHkoNn7TxW0OOqcbFVtbHLVMmxv6zha F1tA== X-Forwarded-Encrypted: i=1; AJvYcCU96a9kkeGwk7dEO7xXru+Vmzf3qCpr+I4jFdML36jlbQmAe0DT8alCMfv5GVd6bZIfYLzhJcVm5lvBJ8UGu+S1Pnw= X-Gm-Message-State: AOJu0YywbTTqEwjJvNTOO6HqFdy/4MalGG3NAsiHuM6hn+bvbTj/nSHp hiy0Ej0BzC7CrN9kincAciFmU/O8KCrF2kCMYqZ8So0A4UO9W9oG8Px4VAVYUl8RKdd1QKkdY06 sIUNpjPLttx+v+10HRAEU2mZDPbh6fc9HIeps X-Google-Smtp-Source: AGHT+IEew9O40a1eagPinVnKq66XRqxq93dCPlTyT+sju/BWCkpRZjCn//Ri9HlnLHZeIehCzQD5j6qeXg1tqDmASbI= X-Received: by 2002:a05:622a:301:b0:44f:cb30:8b71 with SMTP id d75a77b69052e-4519b663469mr5193091cf.25.1722876887583; Mon, 05 Aug 2024 09:54:47 -0700 (PDT) MIME-Version: 1.0 References: <20240724011037.3671523-1-jthoughton@google.com> <20240724011037.3671523-6-jthoughton@google.com> <37ae59f2-777a-4a58-ae58-4a20066364dd@redhat.com> <1ea7a0d2-e640-4549-ac0e-8ae0df8d8e6a@redhat.com> In-Reply-To: <1ea7a0d2-e640-4549-ac0e-8ae0df8d8e6a@redhat.com> From: James Houghton Date: Mon, 5 Aug 2024 09:54:10 -0700 Message-ID: Subject: Re: [PATCH v6 05/11] mm: Add fast_only bool to test_young and clear_young MMU notifiers To: David Hildenbrand Cc: Andrew Morton , Paolo Bonzini , Ankit Agrawal , Axel Rasmussen , Catalin Marinas , David Matlack , David Rientjes , James Morse , Jason Gunthorpe , Jonathan Corbet , Marc Zyngier , Oliver Upton , Raghavendra Rao Ananta , Ryan Roberts , Sean Christopherson , Shaoqin Huang , Suzuki K Poulose , Wei Xu , Will Deacon , Yu Zhao , 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-Rspamd-Queue-Id: A18CA180015 X-Stat-Signature: prjxpir18hdcoxcehdojxr63yxf83q1b X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1722876888-369316 X-HE-Meta: U2FsdGVkX19yEX/5C1TW4xEM4GAHihdurwMLI+5T+cxCfr7wE5ECHiVvr0U93dEWe17jEBxhhdv/QKE6y3RDdsfVQ8tkbZrss1ne0Opck3x+ZjYdrbhzitbgxWFUvLjwrzNFUbE+7MQ2icfMJbuYYI1h8Dz5k4a3WxicdatHo95xla4w8yoS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=bogofilter, spamicity=0.000000, 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 Fri, Aug 2, 2024 at 8:57=E2=80=AFAM David Hildenbrand = wrote: > > On 02.08.24 01:13, James Houghton wrote: > > On Thu, Aug 1, 2024 at 2:36=E2=80=AFAM David Hildenbrand wrote: > >> > >> On 24.07.24 03:10, James Houghton wrote: > >>> For implementers, the fast_only bool indicates that the age informati= on > >>> needs to be harvested such that we do not slow down other MMU operati= ons, > >>> and ideally that we are not ourselves slowed down by other MMU > >>> operations. Usually this means that the implementation should be > >>> lockless. > >> > >> But what are the semantics if "fast_only" cannot be achieved by the > >> implementer? > >> > >> Can we add some documentation to the new functions that explain what > >> this mysterious "fast_only" is and what the expected semantics are? > >> Please? :) > > > > Thanks for pointing out the missing documentation. How's this? > > > > diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.= h > > index 45c5995ebd84..c21992036dd3 100644 > > --- a/include/linux/mmu_notifier.h > > +++ b/include/linux/mmu_notifier.h > > @@ -106,6 +106,18 @@ struct mmu_notifier_ops { > > * clear_young is a lightweight version of clear_flush_young. = Like the > > * latter, it is supposed to test-and-clear the young/accessed= bitflag > > * in the secondary pte, but it may omit flushing the secondar= y tlb. > > + * > > Probably makes sense to highlight the parameters like @fast_only Will do. > > > + * The fast_only parameter indicates that this call should not = block, > > + * and this function should not cause other MMU notifier calls = to > > + * block. Usually this means that the implementation should be > > + * lockless. > > + * > > + * When called with fast_only, this notifier will be a no-op un= less > > + * has_fast_aging is set on the struct mmu_notifier. > > "... and will return 0 (NOT young)." ? Thanks, I'll add this. > > > + * > > + * When fast_only is true, if the implementer cannot determine = that a > > + * range is young without blocking, it should return 0 (i.e., > > + * that the range is NOT young). > > */ > > int (*clear_young)(struct mmu_notifier *subscription, > > struct mm_struct *mm, > > @@ -118,6 +130,8 @@ struct mmu_notifier_ops { > > * the secondary pte. This is used to know if the page is > > * frequently used without actually clearing the flag or teari= ng > > * down the secondary mapping on the page. > > + * > > + * The fast_only parameter has the same meaning as with clear_y= oung. > > */ > > int (*test_young)(struct mmu_notifier *subscription, > > struct mm_struct *mm, > > > > I've also moved the commit that follows this one (the one that adds > > has_fast_aging) to be before this one so that the comment makes sense. > > > Makes sense, thanks! Thanks David!