Re: [PATCH v2 2/3] x86/smp: Allow forcing the mwait hint for play dead loop

From: Dave Hansen
Date: Tue Oct 29 2024 - 14:31:08 EST


On 10/29/24 03:15, Patryk Wlazlyn wrote:
> +void smp_set_mwait_play_dead_hint(unsigned int hint)
> +{
> + WRITE_ONCE(play_dead_mwait_hint, hint);
> +}

This all feels a bit hacky and unstructured to me.

Could we at least set up a few rules here? Like, say what the hints
are, what values can they have? Where do they come from? Can this get
called more than once? Does it _need_ to be set? What's the behavior
when it is not set? Who is responsible for calling this?

What good does the smp_ prefix do? I don't think _callers_ care whether
this is getting optimized out or not.

> - hint = get_deepest_mwait_hint();
> + hint = READ_ONCE(play_dead_mwait_hint);
> + if (hint == PLAY_DEAD_MWAIT_HINT_UNSET)
> + hint = get_deepest_mwait_hint();

This is also rather opaque.

Why are there two hints? What makes one better than the other one?