All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Alistair Popple <apopple@nvidia.com>,
	Andrew Morton <akpm@linux-foundation.org>, <will@kernel.org>,
	<catalin.marinas@arm.com>, David Rientjes <rientjes@google.com>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	<robin.murphy@arm.com>, <nicolinc@nvidia.com>,
	<linux-arm-kernel@lists.infradead.org>, <kvm@vger.kernel.org>,
	<jgg@nvidia.com>, <zhi.wang.linux@gmail.com>,
	Sean Christopherson <seanjc@google.com>
Subject: Re: [PATCH 1/2] mmu_notifiers: Restore documentation for .invalidate_range()
Date: Tue, 23 May 2023 19:20:31 -0700	[thread overview]
Message-ID: <cb706d3f-1fa8-2047-e65c-e1dc1fa6821f@nvidia.com> (raw)
In-Reply-To: <3cece716fc09724793aa832e755abfc9d70a8bb3.1684892404.git-series.apopple@nvidia.com>

On 5/23/23 18:47, Alistair Popple wrote:
> The .invalidate_range() callback is called by
> mmu_notifier_invalidate_range() which is often called while holding
> the ptl spin-lock. Therefore any implementations of this callback must
> not sleep. This was originally documented when the call back was added
> in commit 0f0a327fa12c ("mmu_notifier: add the callback for
> mmu_notifier_invalidate_range()") but appears to have been

Thanks for digging into this. I expect that you're on the right
track, I'm just wondering about something still:

> inadvertently removed by commit 5ff7091f5a2c ("mm, mmu_notifier:
> annotate mmu notifiers with blockable invalidate callbacks").

Was it really inadvertent, though? The initial patch proposed said this:

"Also remove a bogus comment about invalidate_range() always being called
under the ptl spinlock." [1]

I've added David Rientjes to CC.

I almost think we should rename the callback to something with
"non blocking" or similar in the name. It not great to have to
do this much research to figure out the intent. And it still feels
backwards.


[1] https://lore.kernel.org/all/alpine.DEB.2.10.1801091339570.240101@chino.kir.corp.google.com/T/#u


> 
> Restore the comment to make it clear that .invalidate_range()
> callbacks may not sleep.
> 
> Signed-off-by: Alistair Popple <apopple@nvidia.com>
> ---
>   include/linux/mmu_notifier.h | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
> index 64a3e05..447d757 100644
> --- a/include/linux/mmu_notifier.h
> +++ b/include/linux/mmu_notifier.h
> @@ -200,6 +200,9 @@ struct mmu_notifier_ops {
>   	 * external TLB range needs to be flushed. For more in depth
>   	 * discussion on this see Documentation/mm/mmu_notifier.rst
>   	 *
> +	 * The invalidate_range() function is called under the ptl
> +	 * spin-lock and not allowed to sleep.
> +	 *
>   	 * Note that this function might be called with just a sub-range
>   	 * of what was passed to invalidate_range_start()/end(), if
>   	 * called between those functions.
> 
> base-commit: 44c026a73be8038f03dbdeef028b642880cf1511

Hooray for --base! :)


thanks,
-- 
John Hubbard
NVIDIA


WARNING: multiple messages have this Message-ID (diff)
From: John Hubbard <jhubbard@nvidia.com>
To: Alistair Popple <apopple@nvidia.com>,
	Andrew Morton <akpm@linux-foundation.org>, <will@kernel.org>,
	<catalin.marinas@arm.com>, David Rientjes <rientjes@google.com>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	<robin.murphy@arm.com>, <nicolinc@nvidia.com>,
	<linux-arm-kernel@lists.infradead.org>, <kvm@vger.kernel.org>,
	<jgg@nvidia.com>, <zhi.wang.linux@gmail.com>,
	Sean Christopherson <seanjc@google.com>
Subject: Re: [PATCH 1/2] mmu_notifiers: Restore documentation for .invalidate_range()
Date: Tue, 23 May 2023 19:20:31 -0700	[thread overview]
Message-ID: <cb706d3f-1fa8-2047-e65c-e1dc1fa6821f@nvidia.com> (raw)
In-Reply-To: <3cece716fc09724793aa832e755abfc9d70a8bb3.1684892404.git-series.apopple@nvidia.com>

On 5/23/23 18:47, Alistair Popple wrote:
> The .invalidate_range() callback is called by
> mmu_notifier_invalidate_range() which is often called while holding
> the ptl spin-lock. Therefore any implementations of this callback must
> not sleep. This was originally documented when the call back was added
> in commit 0f0a327fa12c ("mmu_notifier: add the callback for
> mmu_notifier_invalidate_range()") but appears to have been

Thanks for digging into this. I expect that you're on the right
track, I'm just wondering about something still:

> inadvertently removed by commit 5ff7091f5a2c ("mm, mmu_notifier:
> annotate mmu notifiers with blockable invalidate callbacks").

Was it really inadvertent, though? The initial patch proposed said this:

"Also remove a bogus comment about invalidate_range() always being called
under the ptl spinlock." [1]

I've added David Rientjes to CC.

I almost think we should rename the callback to something with
"non blocking" or similar in the name. It not great to have to
do this much research to figure out the intent. And it still feels
backwards.


[1] https://lore.kernel.org/all/alpine.DEB.2.10.1801091339570.240101@chino.kir.corp.google.com/T/#u


> 
> Restore the comment to make it clear that .invalidate_range()
> callbacks may not sleep.
> 
> Signed-off-by: Alistair Popple <apopple@nvidia.com>
> ---
>   include/linux/mmu_notifier.h | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
> index 64a3e05..447d757 100644
> --- a/include/linux/mmu_notifier.h
> +++ b/include/linux/mmu_notifier.h
> @@ -200,6 +200,9 @@ struct mmu_notifier_ops {
>   	 * external TLB range needs to be flushed. For more in depth
>   	 * discussion on this see Documentation/mm/mmu_notifier.rst
>   	 *
> +	 * The invalidate_range() function is called under the ptl
> +	 * spin-lock and not allowed to sleep.
> +	 *
>   	 * Note that this function might be called with just a sub-range
>   	 * of what was passed to invalidate_range_start()/end(), if
>   	 * called between those functions.
> 
> base-commit: 44c026a73be8038f03dbdeef028b642880cf1511

Hooray for --base! :)


thanks,
-- 
John Hubbard
NVIDIA


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-05-24  2:20 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24  1:47 [PATCH 1/2] mmu_notifiers: Restore documentation for .invalidate_range() Alistair Popple
2023-05-24  1:47 ` Alistair Popple
2023-05-24  1:47 ` [PATCH 2/2] arm64: Notify on pte permission upgrades Alistair Popple
2023-05-24  1:47   ` Alistair Popple
2023-05-28  0:02   ` Jason Gunthorpe
2023-05-28  0:02     ` Jason Gunthorpe
2023-05-30  8:05     ` Alistair Popple
2023-05-30  8:05       ` Alistair Popple
2023-05-30 11:54       ` Jason Gunthorpe
2023-05-30 11:54         ` Jason Gunthorpe
2023-05-30 12:14         ` Robin Murphy
2023-05-30 12:14           ` Robin Murphy
2023-05-30 12:52           ` Jason Gunthorpe
2023-05-30 12:52             ` Jason Gunthorpe
2023-05-30 13:44             ` Robin Murphy
2023-05-30 13:44               ` Robin Murphy
2023-05-30 14:06               ` Jason Gunthorpe
2023-05-30 14:06                 ` Jason Gunthorpe
2023-05-30 21:44                 ` Sean Christopherson
2023-05-30 21:44                   ` Sean Christopherson
2023-05-30 23:08                   ` Jason Gunthorpe
2023-05-30 23:08                     ` Jason Gunthorpe
2023-05-31  0:30                     ` Alistair Popple
2023-05-31  0:30                       ` Alistair Popple
2023-05-31  0:32                       ` Jason Gunthorpe
2023-05-31  0:32                         ` Jason Gunthorpe
2023-05-31  2:46                         ` Alistair Popple
2023-05-31  2:46                           ` Alistair Popple
2023-05-31 15:30                           ` Jason Gunthorpe
2023-05-31 15:30                             ` Jason Gunthorpe
2023-05-31 23:56                             ` Alistair Popple
2023-05-31 23:56                               ` Alistair Popple
     [not found]                       ` <31cdd164783fefad4c9ef4a6d33c1e0094405d0f03added523a82dd9febdf15f@mu.id>
2023-06-09  2:06                         ` Alistair Popple
2023-06-09  2:06                           ` Alistair Popple
2023-06-09  6:05                           ` Alistair Popple
2023-06-09  6:05                             ` Alistair Popple
2023-05-24  2:20 ` John Hubbard [this message]
2023-05-24  2:20   ` [PATCH 1/2] mmu_notifiers: Restore documentation for .invalidate_range() John Hubbard
2023-05-24  4:45   ` Alistair Popple
2023-05-24  4:45     ` Alistair Popple
2023-05-27 23:56   ` Jason Gunthorpe
2023-05-27 23:56     ` Jason Gunthorpe
2023-05-24  3:48 ` Zhi Wang
2023-05-24  3:48   ` Zhi Wang
2023-05-24  4:57   ` Alistair Popple
2023-05-24  4:57     ` Alistair Popple

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb706d3f-1fa8-2047-e65c-e1dc1fa6821f@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=catalin.marinas@arm.com \
    --cc=jgg@nvidia.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nicolinc@nvidia.com \
    --cc=rientjes@google.com \
    --cc=robin.murphy@arm.com \
    --cc=seanjc@google.com \
    --cc=will@kernel.org \
    --cc=zhi.wang.linux@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.