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 9F5CFC3DA4A for ; Thu, 1 Aug 2024 23:14:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 11FCA6B007B; Thu, 1 Aug 2024 19:14:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F7B26B0083; Thu, 1 Aug 2024 19:14:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F27FA6B0085; Thu, 1 Aug 2024 19:14:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D7F336B007B for ; Thu, 1 Aug 2024 19:14:20 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5471D12110C for ; Thu, 1 Aug 2024 23:14:20 +0000 (UTC) X-FDA: 82405232280.18.9E2F404 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by imf20.hostedemail.com (Postfix) with ESMTP id 853D71C002E for ; Thu, 1 Aug 2024 23:14:18 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=vVlRVwjm; spf=pass (imf20.hostedemail.com: domain of jthoughton@google.com designates 209.85.160.178 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=1722554053; 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=bgdFSK67EnlVzS0oNU0oXBgCMZ8Z41GsOasZvN/Cis8=; b=PBaNvATa7Z5QOPpyGXlHAGCaw2S++vAQrhPLKbY5Gj3oLFwYDVdParpdOvDaHLlP5Vle3r QsnU0Y6PRI1eJgZfM14m+aa2MQ2uXA1HxRNtrcYyGQUylfI5t3YBop8D/IKxk22gh8W7Gf q7Fkf+PGbOAo/kFHv6rNs58LhYLOBeE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=vVlRVwjm; spf=pass (imf20.hostedemail.com: domain of jthoughton@google.com designates 209.85.160.178 as permitted sender) smtp.mailfrom=jthoughton@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722554053; a=rsa-sha256; cv=none; b=L+BkLut27d1LCEUQZ6XOosn/ndAG8moenCAdpmiEOaJX5QLhjspzIqKp8qv8/++hUIqXfd 26lCn6VcvdhS04dYgMxPZCAlcKFu+gfdToEt0h9qjt/m81hULnqDCekidLvS3r7tYiXuu5 LoUHrDqfTfUb6DbgXPwqPHrOOSrdBSo= Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-45029af1408so748461cf.1 for ; Thu, 01 Aug 2024 16:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722554057; x=1723158857; 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=bgdFSK67EnlVzS0oNU0oXBgCMZ8Z41GsOasZvN/Cis8=; b=vVlRVwjm8uIoTaOHr98WKLuEioD8a1+5mYm+sE8AsLV31ge2aAZ9R0XovM0OGjeR0x J9CYrPV0q7DGIrYD4gvWVc2S7c17L70owtdatafo32JUMsiTDTBj8YrnCp9aNe5NuEHf 8MdCp/6hje29G9GKX6fwvtyrDQ5wDIJScW/+xOdpNUywHTamGAUDolRdSOrWgrhq+hyR CaCZIKFgcJBq+UoLfey13MQlqmW8NyD6kQ5Cg1E5Yg3XxuwvzSmZgPlX0JkIIgVX3Mm3 sqzPO0y6zvtwdV0NvkZMEf/777Ohy+Qd166nUlMYvIK2hmbcz5Bwb9xJ8jxCsOZhLv8Q TGmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722554057; x=1723158857; 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=bgdFSK67EnlVzS0oNU0oXBgCMZ8Z41GsOasZvN/Cis8=; b=i+t8sOf2beVUiA2XxcuMQQqCh5ayF7da6439KTdgo+pZ7Gxy1pv4aGlTlr+GGsz4Lf G9GC0RE9l/3lWXkOP43kOQSh2obXnU9VFA+0H83LynIopbwIinUfzNCoAfDo3yStrQgU 9seKNHWSbf5MaLtJI/XfuMA+Eo9Swfbrsw/ENzHiUEN32enVELkWDBfPB7Hae7FMlonx wBBLJ5HfH+LTObianrVQX4v2LzNzJlVR9gp+37LSqLhZuKMTpAqzysDkA8NszPiu8UFT JoZJZIJRVaUvk3ouioabuFCzcAnXjxyX1+wDDdW8e5FOAYyhww6mbUhOK4Pm2UTNcvLi chBg== X-Forwarded-Encrypted: i=1; AJvYcCUWE4ik0Ps5XH9ze5oH8le0ln4ImM8wbyah3beB7dSzJLnP3o6Cb2OZH4GELLh2SAIaHOxu4qrmvDlOeCqN+pAWkpA= X-Gm-Message-State: AOJu0YyKtHy7y+ME7dwDcMA0/P1/3BLDmS4GY7pOk/hQq0cTg0IWjez8 aUrQXI6BNMVqG0oskvS6zzxmGYp1/Gj3fewmGa11yPUBGI5uM6VfATW6z3XnL2ODK1iXMrv0EbR lUj9JMetNFDCdR7nEm9JjPHuiDqQjzCCsgkwz X-Google-Smtp-Source: AGHT+IEavFuwjE3Uo37LnJzCLlUcmMvqQudZCR32/8HyzTxNRzd5eGXPN4zy9/nrSL3qCpUTpDg7un5y0ylSK+y54Ao= X-Received: by 2002:a05:622a:178a:b0:447:e153:66e0 with SMTP id d75a77b69052e-4518c6e3d95mr497911cf.2.1722554057325; Thu, 01 Aug 2024 16:14:17 -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> In-Reply-To: <37ae59f2-777a-4a58-ae58-4a20066364dd@redhat.com> From: James Houghton Date: Thu, 1 Aug 2024 16:13:40 -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-Rspam-User: X-Stat-Signature: 1ipif9px4uyj6ndt7a6539yxsxichsrb X-Rspamd-Queue-Id: 853D71C002E X-Rspamd-Server: rspam11 X-HE-Tag: 1722554058-19794 X-HE-Meta: U2FsdGVkX1/NgTABowa7mX0vjuOalsO6MdFZkwcsxMqLs+168AG8ZKqbKhMxJgKocA0ItzEGZ1jUNv5z140C/uwxy9g68ySH87Hx/3lQvHsSHq9hTlq9CRmpfl8yepOzNyZ55pNlM2x1ByWVd5nHSNpHS0G1eFspPL+nt1thyP3Fq3lLWGZJxF1aFMX1fEdWFOYG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ux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 information > > needs to be harvested such that we do not slow down other MMU operation= s, > > 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 bitf= lag * in the secondary pte, but it may omit flushing the secondary tlb= . + * + * The fast_only parameter indicates that this call should not bloc= k, + * 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 unless + * has_fast_aging is set on the struct mmu_notifier. + * + * 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 tearing * down the secondary mapping on the page. + * + * The fast_only parameter has the same meaning as with clear_young= . */ 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.