Re: [PATCH 0/4]: Respin local_irq_*_nmi() stuff.

From: Peter Zijlstra
Date: Tue Apr 13 2010 - 04:37:19 EST


On Tue, 2010-04-13 at 00:56 -0700, David Miller wrote:

> If we are in an NMI then doing a plain raw_local_irq_disable() will
> write PIL_NORMAL_MAX into %pil, which is lower than PIL_NMI, and thus
> we'll re-enable NMIs and recurse.
>
> Doing a simple:
>
> %pil = %pil | PIL_NORMAL_MAX
>
> does what we want, if we're already at PIL_NMI (15) we leave it at
> that setting, else we set it to PIL_NORMAL_MAX (14).

Ah indeed, and without a conditional, very nice!

It does rely on the exact values of the PIL_levels, it might make sense
to note that in the comment, something like:

* Assumes: PIL_NMI | PIL_NORMAL_MAX == PIL_NMI.

Hmm, it also assumes %pil is never anything other than 0,
PIL_NORMAL_MAX, PIL_NMI, because if:

(%pil & 1) && (%pil != PIL_NMI)

then you'll end up disabling NMIs. Could something like that ever
happen?


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