Re: [PATCH] futex: split PI support to a file of its own

From: Thomas Gleixner
Date: Mon Jul 31 2017 - 03:58:49 EST


On Sat, 29 Jul 2017, Nicolas Pitre wrote:

> Split out the priority inheritance support to a file of its own
> to make futex.c much smaller, easier to understand and, hopefully,
> to maintain. This also makes it easy to preserve basic futex support
> and compile out the PI support when RT mutexes are not available.

I can see your motivation to compile out PI support, which is why you
worked on this in the first place.

But I really do not agree with your reasoning about easier to understand
and maintain. I have the dubious pleasure to stare into that code on a
regular base. PI and non PI share a lot of code and it's really not helping
to have two separate files to stare at. That makes following the PI code
even harder than it is already. So I rather like to see that PI code in an
#ifdef block and not split out into its own file.

> Signed-off-by: Nicolas Pitre <nico@xxxxxxxxxx>

Please provide a diffstat along with the patch next time.

> diff --git a/include/linux/futex.h b/include/linux/futex.h

> +#ifdef CONFIG_FUTEX_PI
> +#include "futex_pi.c"
> +#else
> +#define get_pi_state(...)
> +#define put_pi_state(...)
> +#define refill_pi_state_cache() false
> +#define lookup_pi_state(...) -ENOSYS
> +#define rt_mutex_start_proxy_lock(...) -ENOSYS
> +#define requeue_pi_wake_futex(...)
> +#define futex_proxy_trylock_atomic(...) -ENOSYS
> +#define futex_lock_pi(...) -ENOSYS
> +#define futex_unlock_pi(...) -ENOSYS
> +#define futex_wait_requeue_pi(...) -ENOSYS
> +#endif

Bah, no. We use static inlines as stubs whereever it's possible. Using
macros is just a sloppy hackery.

Thanks,

tglx