[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <605a9d20-8fe4-ec9a-97b4-bc6db38da62f@uwaterloo.ca>
Date: Wed, 4 Aug 2021 15:12:58 -0400
From: Thierry Delisle <tdelisle@...terloo.ca>
To: <posk@...k.io>
CC: <avagin@...gle.com>, <bsegall@...gle.com>, <jannh@...gle.com>,
<linux-api@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<mingo@...hat.com>, <peterz@...radead.org>, <pjt@...gle.com>,
<posk@...gle.com>, <tdelisle@...terloo.ca>, <tglx@...utronix.de>,
Peter Buhr <pabuhr@...terloo.ca>
Subject: Re: [PATCH 3/4 v0.4] sched/umcg: add
Documentation/userspace-api/umcg.rst
These state transition descriptions are very helpful, but what is not
clear is the details of these transitions when there are concurrent
wake/waits. I do not know enough about the kernel code to be able to
read the implementation and answer my own questions.
For example, imagine two worker threads W1 and W2. W1 adds itself to a
concurrent list and calls umcg_wait(next_tid = 0). W2 pops from the list
and calls umcg_wait(UMCG_WAIT_WAKE_ONLY | UMCG_WAIT_WF_CURRENT_CPU) on the
popped worker, W1 in this example.
If W1 calls umcg_wait first, W2 context-switches to W1 and W2's state
changes to IDLE. My understanding is that wake detection/block does not
apply to this case.
If W2 calls umcg_wait first, what happens? I can imagine two different
behaviour in this case:
1. W2 waits for W1 to call umcg_wait, by spinning or blocking, and then
execution proceed like the first ordering.
2. W2 sets W1's state to RUNNING. When W1 eventually calls umcg_wait, it
simply notices the state change and returns without context-switching.
In this case, W1 is not migrated to W2's CPU.
Behaviour 1 makes me uncomfortable since it means umcg_wait must wait for
cooperation that potentially never comes.
But in Behaviour 2, the state of W2 after both calls to umcg_wait is not
clear to me, either. I could imagine that W2 is set to IDLE, but since W1
is not migrated, W2 could also simply be left RUNNING.
Which behaviour is correct and in what state does W2 end up?
Thierry
Powered by blists - more mailing lists