Re: [patch 02/12] futex: Move futex exit handling into futex code

From: Peter Zijlstra
Date: Thu Nov 07 2019 - 04:24:59 EST


On Wed, Nov 06, 2019 at 10:55:36PM +0100, Thomas Gleixner wrote:

> -#ifdef CONFIG_FUTEX
> - if (unlikely(tsk->robust_list)) {
> - exit_robust_list(tsk);
> - tsk->robust_list = NULL;
> - }
> -#ifdef CONFIG_COMPAT
> - if (unlikely(tsk->compat_robust_list)) {
> - compat_exit_robust_list(tsk);
> - tsk->compat_robust_list = NULL;
> - }
> -#endif
> - if (unlikely(!list_empty(&tsk->pi_state_list)))
> - exit_pi_state_list(tsk);
> -#endif

> +void futex_mm_release(struct task_struct *tsk)
> +{
> + if (unlikely(tsk->robust_list)) {
> + exit_robust_list(tsk);
> + tsk->robust_list = NULL;
> + }
> +
> + if (IS_ENABLED(CONFIG_COMPAT)) {
> + if (unlikely(tsk->compat_robust_list)) {
> + compat_exit_robust_list(tsk);
> + tsk->compat_robust_list = NULL;
> + }
> + }

I suppose it is this substitution that causes the compile error mingo
found. The problem with IS_ENABLED() is that the whole block still needs
to compile (before it can be thrown out), and in this case
tsk->compat_robust_list doesn't exist.

> +
> + if (unlikely(!list_empty(&tsk->pi_state_list)))
> + exit_pi_state_list(tsk);
> +}