Re: [RFC][PATCH 0/5] Reduce runqueue lock contention -v2

From: Frank Rowand
Date: Thu Dec 16 2010 - 14:12:35 EST


On 12/16/10 06:56, Peter Zijlstra wrote:
> Hi, here a new posting of my scary patch(es) ;-)
>
> These actually survive a sembench run (and everything else I threw at it).
> The discussion between Mike and Frank over the task_running() check made me
> realize what was wrong with the previous one.
>
> As it turns out, what was needed (p->oncpu) was something Thomas wanted me
> to do for an entirely different reason (see patch #2).
>
> Frank's patch, while encouraging me to poke at it again, has a number of
> very fundamental problems with it, the most serious one being that it
> completely wrecks the wake-up load-balancing.

And also as Peter pointed out when I posted the patch (thank you Peter),
I did not properly handle the return value for try_to_wake_up() - a rather
fatal flaw.

By coincidence, I was about to post a new version of my scary patch when
this email arrived. I'll post my patches as a reply to this email, then
read through Peter's.


Frank's patch, Version 2

Changes from Version 1:
- Ensure return value of try_to_wake_up() is correct, even when queueing
wake up on a different cpu.
- rq->lock contention reduction not as good as first version

patch 1

The core changes. All the scary lock related stuff.

select_task_rq() uses the smp_processor_id() of the old task_cpu(p) instead
of the waking smp_processor_id().

patch 2

select_task_rq() uses the smp_processor_id() of the waking smp_processor_id()

Limitations
x86 only

Tests
- tested on 2 cpu x86_64
- very simplistic workload
- results:
rq->lock contention count reduced by ~ 75%
rq->lock contention wait time reduced by ~ 70%
test duration reduction is in the noise
rq->lock contention improvement is slightly better with just patch 1
applied, but the difference is in the noise

Todo
- handle cpu being offlined


-Frank
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/