diff mbox series

[05/14] arm64: clean up THREAD_* definitions

Message ID 1502130965-18710-6-git-send-email-mark.rutland@arm.com
State Superseded
Headers show
Series arm64: VMAP_STACK support | expand

Commit Message

Mark Rutland Aug. 7, 2017, 6:35 p.m. UTC
Currently we define THREAD_SIZE and THREAD_SIZE order separately, with
the latter dependent on particular CONFIG_ARM64_*K_PAGES definitions.
This is somewhat opaque, and will get in the way of future modifications
to THREAD_SIZE.

This patch cleans this up, defining both in terms of a common
THREAD_SHIFT, and using PAGE_SHIFT to calculate THREAD_SIZE_ORDER,
rather than using a number of definitions dependent on config symbols.
Subsequent patches will make use of this to alter the stack size used in
some configurations.

At the same time, these are moved into <asm/memory.h>, which will avoid
circular include issues in subsequent patches. To ensure that existing
code isn't adversely affected, <asm/thread_info.h> is updated to
transitively include these definitions.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/include/asm/memory.h      | 8 ++++++++
 arch/arm64/include/asm/thread_info.h | 9 +--------
 2 files changed, 9 insertions(+), 8 deletions(-)

-- 
1.9.1

Comments

Catalin Marinas Aug. 14, 2017, 11:59 a.m. UTC | #1
On Mon, Aug 07, 2017 at 07:35:56PM +0100, Mark Rutland wrote:
> Currently we define THREAD_SIZE and THREAD_SIZE order separately, with


s/THREAD_SIZE order/THREAD_SIZE_ORDER/

> the latter dependent on particular CONFIG_ARM64_*K_PAGES definitions.

> This is somewhat opaque, and will get in the way of future modifications

> to THREAD_SIZE.

> 

> This patch cleans this up, defining both in terms of a common

> THREAD_SHIFT, and using PAGE_SHIFT to calculate THREAD_SIZE_ORDER,

> rather than using a number of definitions dependent on config symbols.

> Subsequent patches will make use of this to alter the stack size used in

> some configurations.

> 

> At the same time, these are moved into <asm/memory.h>, which will avoid

> circular include issues in subsequent patches. To ensure that existing

> code isn't adversely affected, <asm/thread_info.h> is updated to

> transitively include these definitions.

> 

> Signed-off-by: Mark Rutland <mark.rutland@arm.com>

> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> Cc: Catalin Marinas <catalin.marinas@arm.com>

> Cc: James Morse <james.morse@arm.com>

> Cc: Laura Abbott <labbott@redhat.com>

> Cc: Will Deacon <will.deacon@arm.com>

> ---

>  arch/arm64/include/asm/memory.h      | 8 ++++++++

>  arch/arm64/include/asm/thread_info.h | 9 +--------

>  2 files changed, 9 insertions(+), 8 deletions(-)

> 

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

> index 77d55dc..8ab4774 100644

> --- a/arch/arm64/include/asm/memory.h

> +++ b/arch/arm64/include/asm/memory.h

> @@ -102,6 +102,14 @@

>  #define KASAN_SHADOW_SIZE	(0)

>  #endif

>  

> +#define THREAD_SHIFT		14

> +

> +#if THREAD_SHIFT >= PAGE_SHIFT

> +#define THREAD_SIZE_ORDER	(THREAD_SHIFT - PAGE_SHIFT)

> +#endif

> +

> +#define THREAD_SIZE		(UL(1) << THREAD_SHIFT)


I haven't tried the series to this patch but it seems to me that
THREAD_SIZE_ORDER is undefined for a PAGE_SHIFT of 16. Without
VMAP_STACKS, it may fail to build.

-- 
Catalin
Mark Rutland Aug. 14, 2017, 1:10 p.m. UTC | #2
On Mon, Aug 14, 2017 at 12:59:59PM +0100, Catalin Marinas wrote:
> On Mon, Aug 07, 2017 at 07:35:56PM +0100, Mark Rutland wrote:

> > Currently we define THREAD_SIZE and THREAD_SIZE order separately, with

> 

> s/THREAD_SIZE order/THREAD_SIZE_ORDER/


Whoops; I'll fix that up now.

> > +#define THREAD_SHIFT		14

> > +

> > +#if THREAD_SHIFT >= PAGE_SHIFT

> > +#define THREAD_SIZE_ORDER	(THREAD_SHIFT - PAGE_SHIFT)

> > +#endif

> > +

> > +#define THREAD_SIZE		(UL(1) << THREAD_SHIFT)

> 

> I haven't tried the series to this patch but it seems to me that

> THREAD_SIZE_ORDER is undefined for a PAGE_SHIFT of 16. 


That is already the case without these patches, as we have:

#ifdef CONFIG_ARM64_4K_PAGES
#define THREAD_SIZE_ORDER       2
#elif defined(CONFIG_ARM64_16K_PAGES)
#define THREAD_SIZE_ORDER       0
#endif

... this is also deliberate, as we'd need an order of -2 with 16K stacks and
64K pages, and this doesn't make sense.

THREAD_SIZE_ORDER only matters if THREAD_SIZE >= PAGE_SIZE (or if we're using a
VMAP'd stack). For 64K pages && VMAP_STACK, we'll use a 64K stack, avoiding the
problem.

Thanks,
Mark.
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 77d55dc..8ab4774 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -102,6 +102,14 @@ 
 #define KASAN_SHADOW_SIZE	(0)
 #endif
 
+#define THREAD_SHIFT		14
+
+#if THREAD_SHIFT >= PAGE_SHIFT
+#define THREAD_SIZE_ORDER	(THREAD_SHIFT - PAGE_SHIFT)
+#endif
+
+#define THREAD_SIZE		(UL(1) << THREAD_SHIFT)
+
 /*
  * Memory types available.
  */
diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index b29ab0e..aa04b73 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -23,18 +23,11 @@ 
 
 #include <linux/compiler.h>
 
-#ifdef CONFIG_ARM64_4K_PAGES
-#define THREAD_SIZE_ORDER	2
-#elif defined(CONFIG_ARM64_16K_PAGES)
-#define THREAD_SIZE_ORDER	0
-#endif
-
-#define THREAD_SIZE		16384
-
 #ifndef __ASSEMBLY__
 
 struct task_struct;
 
+#include <asm/memory.h>
 #include <asm/stack_pointer.h>
 #include <asm/types.h>