Re: [tip:x86/idle] x86, idle: Use static_cpu_has() for CLFLUSHworkaround, add barriers

From: Linus Torvalds
Date: Thu Dec 19 2013 - 15:46:48 EST


On Fri, Dec 20, 2013 at 5:40 AM, Ingo Molnar <mingo@xxxxxxxxxx> wrote:
>
> The first mb() looks superfluous, because see
> current_set_polling_and_test():
>
> static inline bool __must_check current_set_polling_and_test(void)
> {
> __current_set_polling();
>
> /*
> * Polling state must be visible before we test NEED_RESCHED,
> * paired by resched_task()
> */
> smp_mb();
>
> return unlikely(tif_need_resched());
> }
>
> So it already has a (MFENCE) barrier after ->flags is modified.

So what?

The mb() isn't necessarily against the *write*, it is also against the *read*.

If the cflush is needed before the monitor, it's likely because the
monitor instruction has some bug with already-existing cachelines in
shared state or whatever.

Which means that we want to make sure that the cflush is ordered wrt
*reads* from that cacheline too.

cflush has nothing specifically to do with writes.

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