From: peterz@infradead.org
To: Peter Oskolkov <posk@posk.io>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Ingo Molnar <mingo@kernel.org>,
Darren Hart <dvhart@infradead.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Peter Oskolkov <posk@google.com>,
Andrei Vagin <avagin@google.com>, Paul Turner <pjt@google.com>,
Ben Segall <bsegall@google.com>, Aaron Lu <aaron.lwe@gmail.com>
Subject: Re: [PATCH for 5.9 v2 1/4] futex: introduce FUTEX_SWAP operation
Date: Tue, 4 Aug 2020 14:31:47 +0200 [thread overview]
Message-ID: <20200804123147.GI2674@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200803221510.170674-2-posk@posk.io>
On Mon, Aug 03, 2020 at 03:15:07PM -0700, Peter Oskolkov wrote:
> A simplified/idealized use case: imagine a multi-user service application
> (e.g. a DBMS) that has to implement the following user CPU quota
> policy:
So the last posting made hackernews; and there a bunch expressed far
more interest in coroutines, which, if I'm not mistaken, can also be
implemented using all this.
Would that not make for a far simpler and more convincing use-case?
> - block detection: when a task blocks in the kernel (on a network
> read, for example), the userspace scheduler is notified and
> schedules (resumes or swaps into) a pending task in the newly available
> CPU slot;
> - wake detection: when a task wakes from a previously blocking kernel
> operation (e.g. can now process some data on a network socket), the
> userspace scheduler is notified and can now schedule the task to
> run on a CPU when a CPU is available and the task can use it according
> to its scheduling policy.
>
> (Technically, block/wake detection is still experimental and not
> used widely: as we control the userspace, we can actually determine
> blocking/waking syscalls without kernel support).
>
> Internally we currently use kernel patches that are too "intrusive" to be
> included in a general-purpose Linux kernel, so we are exploring ways to
> upstream this functionality.
>
> The easiest/least intrusive approach that we have come up with is this:
>
> - block/resume map perfectly to futex wait/wake;
> - switch_to thus maps to FUTEX_SWAP;
> - block and wake detection can be done either through tracing
> or by introducing new BPF attach points (when a task blocks or wakes,
> a BPF program is triggered that then communicates with the userspace);
> - the BPF attach points are per task, and the task needs to "opt in"
> (i.e. all other tasks suffer just an additional pointer comparison
> on block/wake);
> - the BPF programs triggered on block/wake should be able to perform
> futex ops (e.g. wake a designated userspace scheduling task) - this
> probably indicates that tracing is not enough, and a new BPF prog type
> is needed.
I really think we want to have block/resume detection sorted before this
goes anywhere, I also strongly feel BPF should not be used for
functional interfaces like that.
That is, I want to see a complete interface before I want to commit to
an ABI that we're stuck with.
I also want to see userspace that goes along with it; like with
sys_membarrier() / liburcu and sys_rseq() / librseq (which seems to be
heading for glibc).
Also, and this seems to be the crux of the whole endeavour, you want to
allow your 'fibers' to block. Which is what makes
{make,swap,get,set}context() unsuited for your needs and gives rise to
the whole block/resume issue above.
Also, I want words on the interaction between resume notification and
wake-up preemption. That is, how do you envision managing the
interaction between the two schedulers.
All in all, I don't think you're even close to having something
mergable.
next prev parent reply other threads:[~2020-08-04 12:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-03 22:15 [PATCH for 5.9 v2 0/4] FUTEX_SWAP (tip/locking/core) Peter Oskolkov
2020-08-03 22:15 ` [PATCH for 5.9 v2 1/4] futex: introduce FUTEX_SWAP operation Peter Oskolkov
2020-08-04 12:31 ` peterz [this message]
2020-08-11 15:26 ` Rik van Riel
2020-08-03 22:15 ` [PATCH for 5.9 v2 2/4] futex: implement FUTEX_SWAP as wake+wait Peter Oskolkov
2020-08-03 22:15 ` [PATCH for 5.9 v2 3/4] futex/sched: add wake_up_swap, use in FUTEX_SWAP Peter Oskolkov
2020-08-03 22:15 ` [PATCH for 5.9 v2 4/4] selftests/futex: add futex_swap selftest Peter Oskolkov
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=20200804123147.GI2674@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=aaron.lwe@gmail.com \
--cc=avagin@google.com \
--cc=bsegall@google.com \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=pjt@google.com \
--cc=posk@google.com \
--cc=posk@posk.io \
--cc=tglx@linutronix.de \
--cc=vincent.guittot@linaro.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®