Re: [PATCH 2/4 v0.5] sched/umcg: RFC: add userspace atomic helpers

From: Jann Horn
Date: Wed Sep 08 2021 - 21:16:51 EST


On Thu, Sep 9, 2021 at 1:38 AM Jann Horn <jannh@xxxxxxxxxx> wrote:
> On Wed, Sep 8, 2021 at 8:49 PM Peter Oskolkov <posk@xxxxxxx> wrote:
> > Add helper functions to work atomically with userspace 32/64 bit values -
> > there are some .*futex.* named helpers, but they are not exactly
> > what is needed for UMCG; I haven't found what else I could use, so I
> > rolled these.
[...]
> You of course won't be able to simply traverse userspace pointers in
> such a situation, only access the specific userspace object that
> you've prepared beforehand, but luckily it looks like:
>
> * idle_server_tid_ptr is only accessed in get_idle_server()
> -> which is used from process_waking_worker()
> -> which runs in sleepable context
> * idle_workers_ptr is accessed from:
> -> enqueue_idle_worker
> -> which is also used from process_waking_worker()

Ah, I guess I got that wrong: process_waking_worker() is sleepable,
but it might be holding the mmap lock, so it can't fault, right? Which
means this would actually be problematic...