* [PATCH RT 3/5] allow preemption in check_task_state
@ 2014-02-10 16:28 Nicholas Mc Guire
2014-02-14 13:22 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Mc Guire @ 2014-02-10 16:28 UTC (permalink / raw)
To: linux-rt-users
Cc: LKML, Sebastian Andrzej Siewior, Steven Rostedt, Peter Zijlstra,
Carsten Emde, Thomas Gleixner, Andreas Platschek
A lockfree approach to check_task_state
This treates the state as an indicator variable and use it to probe
saved_state lock free. There is actually no consistency demand on
state/saved_state but rather a consistency demand on the transitions
of the two variables but those transition, based on path inspection,
are not independent.
Its probably not faster than the lock/unlock case if uncontended - atleast
it does not show up in benchmark results, but it would never be hit by a
full pi-boost cycle as there is no contention.
This also was tested against the test-case from Sebastian as well as
rnning a few scripted gdb breakpoint debugging/single-stepping loops
to trigger this.
Tested-by: Andreas Platschek <platschek@ict.tuwien.ac.at>
Tested-by: Carsten Emde <C.Emde@osadl.org>
Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
---
kernel/sched/core.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index bf93f63..5690ba3 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1074,11 +1074,17 @@ static int migration_cpu_stop(void *data);
static bool check_task_state(struct task_struct *p, long match_state)
{
bool match = false;
+ long state, saved_state;
+
+ /* catch restored state */
+ do {
+ state = p->state;
+ saved_state = p->saved_state;
+ rmb(); /* make sure we actually catch updates */
+ } while (state != p->state);
- raw_spin_lock_irq(&p->pi_lock);
if (p->state == match_state || p->saved_state == match_state)
match = true;
- raw_spin_unlock_irq(&p->pi_lock);
return match;
}
--
1.7.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH RT 3/5] allow preemption in check_task_state
2014-02-10 16:28 [PATCH RT 3/5] allow preemption in check_task_state Nicholas Mc Guire
@ 2014-02-14 13:22 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2014-02-14 13:22 UTC (permalink / raw)
To: Nicholas Mc Guire
Cc: linux-rt-users, LKML, Steven Rostedt, Peter Zijlstra,
Carsten Emde, Thomas Gleixner, Andreas Platschek
* Nicholas Mc Guire | 2014-02-10 17:28:16 [+0100]:
>A lockfree approach to check_task_state
I ignore this due to was has been written in the thread "allow
preemption in check_task_state" for now.
Also I just want to state that this function is hardly used on regular
basis except for ptrace attach case which ends up beeing a power user in
the test case mentioned.
Sebastian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-14 13:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-10 16:28 [PATCH RT 3/5] allow preemption in check_task_state Nicholas Mc Guire
2014-02-14 13:22 ` Sebastian Andrzej Siewior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).