public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH] arm64: move THREAD_* definitions to separated header
Date: Wed, 30 Aug 2017 10:58:54 +0100	[thread overview]
Message-ID: <20170830095854.GA17353@leverpostej> (raw)
In-Reply-To: <20170830092249.20638-1-ynorov@caviumnetworks.com>

On Wed, Aug 30, 2017 at 12:22:49PM +0300, Yury Norov wrote:
> Hi Mark, all.

Hi Yury, 

> In patch 'dbc9344a68e506f19f8 ("arm64: clean up THREAD_* definitions")'
> you move THREAD_* definitions from arch/arm64/include/asm/thread_info.h
> to asm/memory.h. After that asm/thread_info.h starts to depend on
> asm/memory.h.
> 
> When I try to apply ilp32 series on top of it [1], it causes circular
> dependencies like this one:
> 
> In file included from ./arch/arm64/include/asm/memory.h:30:0,
>                  from ./arch/arm64/include/asm/thread_info.h:30,
>                  from ./include/linux/thread_bits.h:20,
>                  from ./include/linux/thread_info.h:13,
>                  from ./include/asm-generic/preempt.h:4,
>                  from ./arch/arm64/include/generated/asm/preempt.h:1,
>                  from ./include/linux/preempt.h:80,
>                  from ./include/linux/rcupdate.h:40,
>                  from ./include/linux/rculist.h:10,
>                  from ./include/linux/pid.h:4,
>                  from ./include/linux/sched.h:13,
>                  from arch/arm64/kernel/asm-offsets.c:21:
> ./arch/arm64/include/asm/is_compat.h: In function ?is_a32_compat_task?:
> ./arch/arm64/include/asm/is_compat.h:25:9: error: implicit declaration of function ?test_thread_flag? [-Werror=implicit-function-declaration]
>   return test_thread_flag(TIF_32BIT);
>          ^~~~~~~~~~~~~~~~
> 
> The problem is that asm/memory.h depends on asm/is_compat.h to define
> TASK_SIZE, which in turn requires asm/thread_info.h.

... and <asm/thread_info.h> include <asm/memory.h>, giving a circular
dependency.

In other architectures, TASK_SIZE is defined in processor.h. Can we not
move TASK_SIZE instead of THREAD_SIZE, given that TASK_SIZE is what
causes the dependency?

We'd need a new __ASSEMBLY__ guard, but otherwise it looks like that
would solve the issue.

> The most obvious solution for it is to create is_compat.c file and make
> is_*_compat() real functions. The other option is to move THREAD_*
> definitions to separated macro. I would prefer 2nd one because of following
> reasons:
>  - TASK_SIZE macro is used many times in kernel, including hot paths;
>  - asm/memory.h is included widely, as well as asm/thread_info.h, and it's
>    better not to make them depend one from another;
>  - THREAD_SIZE etc are not memory-related definitions.

I disagree with this last point. THREAD_SIZE is in <asm/memory.h>
because it affects the kernel's memory layout, as with other definitions
at the top of <asm/memory.h>.

I would much prefer keeping those definitions together.

> In this patch THREAD_* definitions moved to separated asm/thread_size.h
> header. It's enough to resolve dependency above.
>
> If you find this approach useful, I can prepare other patch that moves
> TASK_* definitions from asm/memory.h to new header to remove the dependency
> from asm/is_compat.h.

I'd prefer that we moved the TASK_SIZE* definitions first, but if
necessary, I'm ok with seeing the THREAD_SIZE* definitions move.

[...]

> diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h

> -#include <asm/memory.h>
> +#include <asm/thread_size.h>
>  #include <asm/stack_pointer.h>
>  #include <asm/types.h>

Nit: please keep includes ordered alphabetically.

[...]

> diff --git a/arch/arm64/include/asm/thread_size.h b/arch/arm64/include/asm/thread_size.h

> +#ifdef __KERNEL__

This can go. We haven't needed __KERNEL__ ifdefs for a long time now...

[...]

> diff --git a/arch/arm64/kernel/hibernate-asm.S b/arch/arm64/kernel/hibernate-asm.S
> index e56d848b6466..46b91702ea26 100644
> --- a/arch/arm64/kernel/hibernate-asm.S
> +++ b/arch/arm64/kernel/hibernate-asm.S
> @@ -22,7 +22,6 @@
>  #include <asm/asm-offsets.h>
>  #include <asm/assembler.h>
>  #include <asm/cputype.h>
> -#include <asm/memory.h>
>  #include <asm/page.h>
>  #include <asm/virt.h>

AFAICT, we can also lose <linux/errno.h>, <asm/cputype.h>, and
<asm/virt.h>.

Changes to this file might be better as a preparatory cleanup.

Thanks,
Mark.

  reply	other threads:[~2017-08-30  9:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30  9:22 [RFC PATCH] arm64: move THREAD_* definitions to separated header Yury Norov
2017-08-30  9:58 ` Mark Rutland [this message]
2017-08-30 10:48   ` Yury Norov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170830095854.GA17353@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox