The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH bpf-next v4 2/4] uaccess: Define pagefault lock guard
       [not found] <cover.1746598898.git.vmalik@redhat.com>
@ 2025-05-07  6:40 ` Viktor Malik
  2025-05-08 10:00   ` Matt Bobrowski
  0 siblings, 1 reply; 4+ messages in thread
From: Viktor Malik @ 2025-05-07  6:40 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	linux-kernel, Viktor Malik

Define a pagefault lock guard which allows to simplify functions that
need to disable page faults.

Signed-off-by: Viktor Malik <vmalik@redhat.com>
---
 include/linux/uaccess.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index 7c06f4795670..1beb5b395d81 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -296,6 +296,8 @@ static inline bool pagefault_disabled(void)
  */
 #define faulthandler_disabled() (pagefault_disabled() || in_atomic())
 
+DEFINE_LOCK_GUARD_0(pagefault, pagefault_disable(), pagefault_enable())
+
 #ifndef CONFIG_ARCH_HAS_SUBPAGE_FAULTS
 
 /**
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next v4 2/4] uaccess: Define pagefault lock guard
  2025-05-07  6:40 ` [PATCH bpf-next v4 2/4] uaccess: Define pagefault lock guard Viktor Malik
@ 2025-05-08 10:00   ` Matt Bobrowski
  2025-05-09 18:20     ` Andrii Nakryiko
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Bobrowski @ 2025-05-08 10:00 UTC (permalink / raw)
  To: Viktor Malik
  Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	linux-kernel

On Wed, May 07, 2025 at 08:40:37AM +0200, Viktor Malik wrote:
> Define a pagefault lock guard which allows to simplify functions that
> need to disable page faults.
> 
> Signed-off-by: Viktor Malik <vmalik@redhat.com>
> ---
>  include/linux/uaccess.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
> index 7c06f4795670..1beb5b395d81 100644
> --- a/include/linux/uaccess.h
> +++ b/include/linux/uaccess.h
> @@ -296,6 +296,8 @@ static inline bool pagefault_disabled(void)
>   */
>  #define faulthandler_disabled() (pagefault_disabled() || in_atomic())
>  
> +DEFINE_LOCK_GUARD_0(pagefault, pagefault_disable(), pagefault_enable())

I can't help but mention that naming this scope-based cleanup helper
`pagefault` just seems overly ambiguous. That's just me though...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next v4 2/4] uaccess: Define pagefault lock guard
  2025-05-08 10:00   ` Matt Bobrowski
@ 2025-05-09 18:20     ` Andrii Nakryiko
  2025-05-13  6:55       ` Matt Bobrowski
  0 siblings, 1 reply; 4+ messages in thread
From: Andrii Nakryiko @ 2025-05-09 18:20 UTC (permalink / raw)
  To: Matt Bobrowski
  Cc: Viktor Malik, bpf, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, linux-kernel

On Thu, May 8, 2025 at 3:01 AM Matt Bobrowski <mattbobrowski@google.com> wrote:
>
> On Wed, May 07, 2025 at 08:40:37AM +0200, Viktor Malik wrote:
> > Define a pagefault lock guard which allows to simplify functions that
> > need to disable page faults.
> >
> > Signed-off-by: Viktor Malik <vmalik@redhat.com>
> > ---
> >  include/linux/uaccess.h | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
> > index 7c06f4795670..1beb5b395d81 100644
> > --- a/include/linux/uaccess.h
> > +++ b/include/linux/uaccess.h
> > @@ -296,6 +296,8 @@ static inline bool pagefault_disabled(void)
> >   */
> >  #define faulthandler_disabled() (pagefault_disabled() || in_atomic())
> >
> > +DEFINE_LOCK_GUARD_0(pagefault, pagefault_disable(), pagefault_enable())
>
> I can't help but mention that naming this scope-based cleanup helper
> `pagefault` just seems overly ambiguous. That's just me though...

I do see the concern, but

DEFINE_LOCK_GUARD_0(preempt, preempt_disable(), preempt_enable())
DEFINE_LOCK_GUARD_0(irq, local_irq_disable(), local_irq_enable())

so we are just staying consistent here? But also "guard (against) the
pagefault" does (internally) read somewhat meaningfully, no?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next v4 2/4] uaccess: Define pagefault lock guard
  2025-05-09 18:20     ` Andrii Nakryiko
@ 2025-05-13  6:55       ` Matt Bobrowski
  0 siblings, 0 replies; 4+ messages in thread
From: Matt Bobrowski @ 2025-05-13  6:55 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Viktor Malik, bpf, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, linux-kernel

On Fri, May 09, 2025 at 11:20:48AM -0700, Andrii Nakryiko wrote:
> On Thu, May 8, 2025 at 3:01 AM Matt Bobrowski <mattbobrowski@google.com> wrote:
> >
> > On Wed, May 07, 2025 at 08:40:37AM +0200, Viktor Malik wrote:
> > > Define a pagefault lock guard which allows to simplify functions that
> > > need to disable page faults.
> > >
> > > Signed-off-by: Viktor Malik <vmalik@redhat.com>
> > > ---
> > >  include/linux/uaccess.h | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
> > > index 7c06f4795670..1beb5b395d81 100644
> > > --- a/include/linux/uaccess.h
> > > +++ b/include/linux/uaccess.h
> > > @@ -296,6 +296,8 @@ static inline bool pagefault_disabled(void)
> > >   */
> > >  #define faulthandler_disabled() (pagefault_disabled() || in_atomic())
> > >
> > > +DEFINE_LOCK_GUARD_0(pagefault, pagefault_disable(), pagefault_enable())
> >
> > I can't help but mention that naming this scope-based cleanup helper
> > `pagefault` just seems overly ambiguous. That's just me though...
> 
> I do see the concern, but
> 
> DEFINE_LOCK_GUARD_0(preempt, preempt_disable(), preempt_enable())
> DEFINE_LOCK_GUARD_0(irq, local_irq_disable(), local_irq_enable())
> 
> so we are just staying consistent here? But also "guard (against) the
> pagefault" does (internally) read somewhat meaningfully, no?

Now that you've written it out like that, yes I do agree, that does
read somewhat meaningfully. I also don't have any better suggestions
at this point, so I think leaving it as it is now is also totally
fine.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-13  6:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1746598898.git.vmalik@redhat.com>
2025-05-07  6:40 ` [PATCH bpf-next v4 2/4] uaccess: Define pagefault lock guard Viktor Malik
2025-05-08 10:00   ` Matt Bobrowski
2025-05-09 18:20     ` Andrii Nakryiko
2025-05-13  6:55       ` Matt Bobrowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox