Thread (52 messages) 52 messages, 7 authors, 2023-06-08

Re: [PATCH] tracing/user_events: Run BPF program if attached

flat view

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2023-05-17 00:56:29
Also in: bpf, lkml

On Tue, May 16, 2023 at 5:36 PM Alexei Starovoitov
[off-list ref] wrote:
On Mon, May 15, 2023 at 12:24:07PM -0700, Beau Belgrave wrote:
quoted
quoted
quoted
  ret = pin_user_pages_remote(mm->mm, uaddr, 1, FOLL_WRITE | FOLL_NOFAULT,
                              &page, NULL, NULL);
... which will call pin_user_pages_remote() in RCU CS.
This looks buggy, since pin_user_pages_remote() may schedule.
If it's possible to schedule, I can change this to cache the probe
callbacks under RCU then drop it. However, when would
pin_user_pages_remote() schedule with FOLL_NOFAULT?
Are you saying that passing FOLL_NOFAULT makes it work in atomic context?
Absolutely not.

It may not fault missing pages in, but that does *not* make it atomic.

That code depends on all the usual MM locking, and it does not work at
all in the same way that "pagefault_disable()" does, for example. That
will fail on any fault and never take locks, and is designed to work
in atomic contexts. Very different.

So no, don't think you can call pin_user_pages_remote() or any other
GUP function from atomic context.

We do have "get_user_page[s]_fast_only()" and that is the only version
of GUP that is actually lock-free.

Also, just FYI, those special gup_user*fast_only()" functions simply
will not work on some architectures at all.

               Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help