linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] x86/asm: Reorder early variables
@ 2019-10-03  9:52 Jiri Slaby
  2019-10-03  9:52 ` [PATCH 2/2] x86/asm: Make boot_gdt_descr local Jiri Slaby
  2019-10-05 10:14 ` [tip: x86/asm] x86/asm: Reorder early variables tip-bot2 for Jiri Slaby
  0 siblings, 2 replies; 4+ messages in thread
From: Jiri Slaby @ 2019-10-03  9:52 UTC (permalink / raw)
  To: bp; +Cc: tglx, mingo, hpa, x86, linux-kernel, Jiri Slaby

Moving early_recursion_flag (4 bytes) after early_level4_pgt (4k) and
early_dynamic_pgts (256k) saves 4k which are used for alignment of
early_level4_pgt after early_recursion_flag.

The real improvement is merely on the source code side. Previously it
was:
* __INITDATA + .balign
* early_recursion_flag variable
* a ton of CPP MACROS
* __INITDATA (again)
* early_top_pgt and early_recursion_flag variables
* .data

Now, it is a bit simpler:
* a ton of CPP MACROS
* __INITDATA + .balign
* early_top_pgt and early_recursion_flag variables
* early_recursion_flag variable
* .data

On the binary level the change looks like this:
Before:
 (sections)
  12 .init.data    00042000  0000000000000000  0000000000000000 00008000  2**12
 (symbols)
  000000       4 OBJECT  GLOBAL DEFAULT   22 early_recursion_flag
  001000    4096 OBJECT  GLOBAL DEFAULT   22 early_top_pgt
  002000 0x40000 OBJECT  GLOBAL DEFAULT   22 early_dynamic_pgts

After:
 (sections)
  12 .init.data    00041004  0000000000000000  0000000000000000 00008000  2**12
 (symbols)
  000000    4096 OBJECT  GLOBAL DEFAULT   22 early_top_pgt
  001000 0x40000 OBJECT  GLOBAL DEFAULT   22 early_dynamic_pgts
  041000       4 OBJECT  GLOBAL DEFAULT   22 early_recursion_flag

So the resulting vmlinux is smaller by 4k with my toolchain as many
other variables can be placed after early_recursion_flag to fill the
rest of the page. Note that this is only .init data, so it is freed
right after being booted anyway. Savings on-disk are none --
compression of zeros is easy, so the size of bzImage is the same pre and
post the change.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
---
 arch/x86/kernel/head_64.S | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index f3d3e9646a99..f00d7c0c1c86 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -335,12 +335,6 @@ early_idt_handler_common:
 	jmp restore_regs_and_return_to_kernel
 END(early_idt_handler_common)
 
-	__INITDATA
-
-	.balign 4
-GLOBAL(early_recursion_flag)
-	.long 0
-
 #define NEXT_PAGE(name) \
 	.balign	PAGE_SIZE; \
 GLOBAL(name)
@@ -375,6 +369,8 @@ GLOBAL(name)
 	.endr
 
 	__INITDATA
+	.balign 4
+
 NEXT_PGD_PAGE(early_top_pgt)
 	.fill	512,8,0
 	.fill	PTI_USER_PGD_FILL,8,0
@@ -382,6 +378,9 @@ NEXT_PGD_PAGE(early_top_pgt)
 NEXT_PAGE(early_dynamic_pgts)
 	.fill	512*EARLY_DYNAMIC_PAGE_TABLES,8,0
 
+GLOBAL(early_recursion_flag)
+	.long 0
+
 	.data
 
 #if defined(CONFIG_XEN_PV) || defined(CONFIG_PVH)
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] x86/asm: Make boot_gdt_descr local
  2019-10-03  9:52 [PATCH 1/2] x86/asm: Reorder early variables Jiri Slaby
@ 2019-10-03  9:52 ` Jiri Slaby
  2019-10-05 10:14   ` [tip: x86/asm] " tip-bot2 for Jiri Slaby
  2019-10-05 10:14 ` [tip: x86/asm] x86/asm: Reorder early variables tip-bot2 for Jiri Slaby
  1 sibling, 1 reply; 4+ messages in thread
From: Jiri Slaby @ 2019-10-03  9:52 UTC (permalink / raw)
  To: bp; +Cc: tglx, mingo, hpa, x86, linux-kernel, Jiri Slaby

As far as I can see, it was never used outside head_32.S. Not even when
added in 2004. So make it local.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
---
 arch/x86/kernel/head_32.S | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 30f9cb2c0b55..7feb953e10d2 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -597,8 +597,6 @@ int_msg:
  */
 
 	.data
-.globl boot_gdt_descr
-
 	ALIGN
 # early boot GDT descriptor (must use 1:1 address mapping)
 	.word 0				# 32 bit align gdt_desc.address
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [tip: x86/asm] x86/asm: Make boot_gdt_descr local
  2019-10-03  9:52 ` [PATCH 2/2] x86/asm: Make boot_gdt_descr local Jiri Slaby
@ 2019-10-05 10:14   ` tip-bot2 for Jiri Slaby
  0 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Jiri Slaby @ 2019-10-05 10:14 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Jiri Slaby, Borislav Petkov, H. Peter Anvin, Ingo Molnar,
	Thomas Gleixner, x86-ml, Ingo Molnar, Borislav Petkov,
	linux-kernel

The following commit has been merged into the x86/asm branch of tip:

Commit-ID:     5aa5cbd2e95e0079b2cc6b4b66f0d0de5e0fbbfd
Gitweb:        https://git.kernel.org/tip/5aa5cbd2e95e0079b2cc6b4b66f0d0de5e0fbbfd
Author:        Jiri Slaby <jslaby@suse.cz>
AuthorDate:    Thu, 03 Oct 2019 11:52:38 +02:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Sat, 05 Oct 2019 12:11:05 +02:00

x86/asm: Make boot_gdt_descr local

As far as I can see, it was never used outside of head_32.S. Not even
when added in 2004. So make it local.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/20191003095238.29831-2-jslaby@suse.cz
---
 arch/x86/kernel/head_32.S | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 30f9cb2..7feb953 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -597,8 +597,6 @@ int_msg:
  */
 
 	.data
-.globl boot_gdt_descr
-
 	ALIGN
 # early boot GDT descriptor (must use 1:1 address mapping)
 	.word 0				# 32 bit align gdt_desc.address

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [tip: x86/asm] x86/asm: Reorder early variables
  2019-10-03  9:52 [PATCH 1/2] x86/asm: Reorder early variables Jiri Slaby
  2019-10-03  9:52 ` [PATCH 2/2] x86/asm: Make boot_gdt_descr local Jiri Slaby
@ 2019-10-05 10:14 ` tip-bot2 for Jiri Slaby
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Jiri Slaby @ 2019-10-05 10:14 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Jiri Slaby, Borislav Petkov, Andy Lutomirski, H. Peter Anvin,
	Ingo Molnar, Josh Poimboeuf, Juergen Gross, Peter Zijlstra,
	Thomas Gleixner, x86-ml, Ingo Molnar, Borislav Petkov,
	linux-kernel

The following commit has been merged into the x86/asm branch of tip:

Commit-ID:     1a8770b746bd05ef68217989cd723b2c24d2208d
Gitweb:        https://git.kernel.org/tip/1a8770b746bd05ef68217989cd723b2c24d2208d
Author:        Jiri Slaby <jslaby@suse.cz>
AuthorDate:    Thu, 03 Oct 2019 11:52:37 +02:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Sat, 05 Oct 2019 12:11:00 +02:00

x86/asm: Reorder early variables

Moving early_recursion_flag (4 bytes) after early_level4_pgt (4k) and
early_dynamic_pgts (256k) saves 4k which are used for alignment of
early_level4_pgt after early_recursion_flag.

The real improvement is merely on the source code side. Previously it
was:
* __INITDATA + .balign
* early_recursion_flag variable
* a ton of CPP MACROS
* __INITDATA (again)
* early_top_pgt and early_recursion_flag variables
* .data

Now, it is a bit simpler:
* a ton of CPP MACROS
* __INITDATA + .balign
* early_top_pgt and early_recursion_flag variables
* early_recursion_flag variable
* .data

On the binary level the change looks like this:
Before:
 (sections)
  12 .init.data    00042000  0000000000000000  0000000000000000 00008000  2**12
 (symbols)
  000000       4 OBJECT  GLOBAL DEFAULT   22 early_recursion_flag
  001000    4096 OBJECT  GLOBAL DEFAULT   22 early_top_pgt
  002000 0x40000 OBJECT  GLOBAL DEFAULT   22 early_dynamic_pgts

After:
 (sections)
  12 .init.data    00041004  0000000000000000  0000000000000000 00008000  2**12
 (symbols)
  000000    4096 OBJECT  GLOBAL DEFAULT   22 early_top_pgt
  001000 0x40000 OBJECT  GLOBAL DEFAULT   22 early_dynamic_pgts
  041000       4 OBJECT  GLOBAL DEFAULT   22 early_recursion_flag

So the resulting vmlinux is smaller by 4k with my toolchain as many
other variables can be placed after early_recursion_flag to fill the
rest of the page. Note that this is only .init data, so it is freed
right after being booted anyway. Savings on-disk are none -- compression
of zeros is easy, so the size of bzImage is the same pre and post the
change.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/20191003095238.29831-1-jslaby@suse.cz
---
 arch/x86/kernel/head_64.S | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index f3d3e96..f00d7c0 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -335,12 +335,6 @@ early_idt_handler_common:
 	jmp restore_regs_and_return_to_kernel
 END(early_idt_handler_common)
 
-	__INITDATA
-
-	.balign 4
-GLOBAL(early_recursion_flag)
-	.long 0
-
 #define NEXT_PAGE(name) \
 	.balign	PAGE_SIZE; \
 GLOBAL(name)
@@ -375,6 +369,8 @@ GLOBAL(name)
 	.endr
 
 	__INITDATA
+	.balign 4
+
 NEXT_PGD_PAGE(early_top_pgt)
 	.fill	512,8,0
 	.fill	PTI_USER_PGD_FILL,8,0
@@ -382,6 +378,9 @@ NEXT_PGD_PAGE(early_top_pgt)
 NEXT_PAGE(early_dynamic_pgts)
 	.fill	512*EARLY_DYNAMIC_PAGE_TABLES,8,0
 
+GLOBAL(early_recursion_flag)
+	.long 0
+
 	.data
 
 #if defined(CONFIG_XEN_PV) || defined(CONFIG_PVH)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-05 10:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-03  9:52 [PATCH 1/2] x86/asm: Reorder early variables Jiri Slaby
2019-10-03  9:52 ` [PATCH 2/2] x86/asm: Make boot_gdt_descr local Jiri Slaby
2019-10-05 10:14   ` [tip: x86/asm] " tip-bot2 for Jiri Slaby
2019-10-05 10:14 ` [tip: x86/asm] x86/asm: Reorder early variables tip-bot2 for Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).