On Thu, Jul 23, 2020 at 4:28 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
Thanks a lot for your comments, Peter! My answers below.
On Wed, Jul 22, 2020 at 04:45:36PM -0700, Peter Oskolkov wrote:Will do. Should I expand the cover letter or the commit message? (I'll probably
This patchset is the first step to open-source this work. As explainedThe PDF and video can go pound sand; you get to fully explain things
in the linked pdf and video, SwitchTo API has three core operations: wait,
resume, and swap (=switch). So this patchset adds a FUTEX_SWAP operation
that, in addition to FUTEX_WAIT and FUTEX_WAKE, will provide a foundation
on top of which user-space threading libraries can be built.
here.
split the first patch into two in the latter case).
What worries me is how FUTEX_SWAP would interact with the future[+cc Waiman Long]
FUTEX_LOCK / FUTEX_UNLOCK. When we implement pthread_mutex with those,
there's very few WAIT/WAKE left.
I've looked through the latest FUTEX_LOCK patchset I could find (
https://lore.kernel.org/patchwork/cover/772643/ and related), and it seems
that FUTEX_SWAP and FUTEX_LOCK/FUTEX_UNLOCK patchsets
address the same issue (slow wakeups) but for different use cases:
FUTEX_LOCK/FUTEX_UNLOCK uses spinning and lock stealing to
improve futex wake/wait performance in high contention situations;
FUTEX_SWAP is designed to be used for fast context switching with
_no_ contention by design: the waker that is going to sleep, and the wakee
are using different futexes; the userspace will have a futex per thread/task,
and when needed the thread/task will either simply sleep on its futex,
or context switch (=FUTEX_SWAP) into a different thread/task.