Re: [PATCH] thread_info: include <current.h> for THREAD_INFO_IN_TASK (WAS: [PATCH 2/3] sched/preempt: include asm/current.h)

From: Mark Rutland
Date: Mon Oct 17 2016 - 10:48:56 EST


On Fri, Oct 14, 2016 at 11:42:25AM +0100, Mark Rutland wrote:
> When CONFIG_THREAD_INFO_IN_TASK is selected, the current_thread_info()
> macro relies on current having been defined prior to its use. However,
> not all users of current_thread_info() include <asm/current.h>, and thus
> current is not guaranteed to be defined.
>
> When CONFIG_THREAD_INFO_IN_TASK is not selected, it's possible that
> get_current() / current are based upon current_thread_info(), and
> <asm/current.h> includes <asm/thread_info.h>. Thus always including
> <asm/current.h> would result in circular dependences on some platforms.
>
> To ensure both cases work, this patch includes <asm/current.h>, but only
> when CONFIG_THREAD_INFO_IN_TASK is selected.
>
> Signed-off-by: Mark Rutland <mark.rutland@xxxxxxx>
> ---
> include/linux/thread_info.h | 1 +
> 1 file changed, 1 insertion(+)
>
> As discussed, it would be great if this could go in along with the patch to
> make thread_info arch-specific again, to make merging the arch-specific parts
> easier (for arm64 and s390).

Urrgh; I've just recalled that this patch alone is insufficient. The
h8300 arch code has an unfixed bug [1], and relies on some implicit
definition ordering that will be broken by this patch.

I have a workaround/cleanup for core code that I'll send with an updated
version of my arm64 series shortly.

Thanks,
Mark.

[1] http://lkml.kernel.org/r/<1476714934-11635-1-git-send-email-mark.rutland@xxxxxxx

> Mark.
>
> diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
> index 45f004e..521f84b 100644
> --- a/include/linux/thread_info.h
> +++ b/include/linux/thread_info.h
> @@ -25,6 +25,7 @@ struct thread_info {
> #endif
>
> #ifdef CONFIG_THREAD_INFO_IN_TASK
> +#include <asm/current.h>
> #define current_thread_info() ((struct thread_info *)current)
> #endif
>
> --
> 1.9.1
>