Re: [PATCH] sched: correct testing need_resched inmutex_spin_on_owner()

From: Peter Zijlstra
Date: Tue Jun 07 2011 - 11:20:51 EST


On Tue, 2011-06-07 at 22:47 +0800, Hillf Danton wrote:
> Oh, it looks you are willing to rethink about testing need_resched?

Dude, however did you come up with that deduction?

mutex_spin_on_owner() does two things:

- it validates that owner is in fact still running (if so it must be on
another cpu, since we're running on this one).

- it ensures we play nice and reschedule when we need to, so we don't
hog our cpu.

Testing TIF_NEED_RESCHED on owner like you propose is wrong because:

- owner is not a stable pointer you can dereference, see
owner_running(), you first need to validate that its still a valid
pointer and then keep it valid while dereferencing it.

- if owner were to reschedule, it would leave the cpu and we'd break
out of the loop anyway by means of owner_running() failing, so its
superfluous.

Please, get a grip on reality and stop sending endless streams of
patches based on wrong assumptions and mis-understandings.


--
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/