Skip to contentSkip to conversation

x86: setup code_bytes - use mask to restrict it's size

RFC In review Cyrill Gorcunov 2 participants 4 messages Feb 2, 2008 x86

lore
Share & tools
lore
#0 lore raw

RFC 1/1 x86: setup code_bytes - use mask to restrict it's size

This patch strips off 8 bytes from text section. Not a really big advantage (especially for __init section). It seems 8192 bytes of disassembled code is rare used anyway.

before:

	text    data     bss     dec     hex filename
	9900     176      20   10096    2770 arch/x86/kernel/traps_64.o.old
after:
	text    data     bss     dec     hex filename
	9892     176      20   10088    2768 arch/x86/kernel/traps_64.o

---

If there is no benefit at all - just drop the patch. Any comments are welcome ;)

arch/x86/kernel/traps_32.c +3 -2
Index: linux-2.6.git/arch/x86/kernel/traps_32.c
===================================================================
@@ -1229,8 +1229,9 @@ __setup("kstack=", kstack_setup);
 static int __init code_bytes_setup(char *s)
 {
 	code_bytes = simple_strtoul(s, NULL, 0);
-	if (code_bytes > 8192)
-		code_bytes = 8192;
+
+	/* we don't want too long code-dump */
+	code_bytes &= 8191;
 
 	return 1;
 }
arch/x86/kernel/traps_64.c +3 -2
Index: linux-2.6.git/arch/x86/kernel/traps_64.c
===================================================================
@@ -1196,8 +1196,9 @@ early_param("kstack", kstack_setup);
 static int __init code_bytes_setup(char *s)
 {
 	code_bytes = simple_strtoul(s, NULL, 0);
-	if (code_bytes > 8192)
-		code_bytes = 8192;
+
+	/* we don't want too long code-dump */
+	code_bytes &= 8191;
 
 	return 1;
 }
#1 lore raw
Quoted 11 lines · Cyrill Gorcunov

This patch strips off 8 bytes from text section. Not a really big advantage (especially for __init section). It seems 8192 bytes of disassembled code is rare used anyway.

before:

	text    data     bss     dec     hex filename
	9900     176      20   10096    2770 arch/x86/kernel/traps_64.o.old
after:
	text    data     bss     dec     hex filename
	9892     176      20   10088    2768 arch/x86/kernel/traps_64.o
Quoted 5 lines

---

If there is no benefit at all - just drop the patch. Any comments are welcome ;)

I don't think this is the behaviour we want (wrapping around); worse, if people enter a larger power of two they will get zero.

So NAK on this patch, IMO.

-hpa

#2 lore raw

Thanks for review. Agreed with you absolutely. Silly patch, sorry :(

Quoted 25 lines · H. Peter Anvin
Quoted 11 lines · Cyrill Gorcunov

This patch strips off 8 bytes from text section. Not a really big advantage (especially for __init section). It seems 8192 bytes of disassembled code is rare used anyway.

before:

	text    data     bss     dec     hex filename
	9900     176      20   10096    2770 arch/x86/kernel/traps_64.o.old
after:
	text    data     bss     dec     hex filename
	9892     176      20   10088    2768 arch/x86/kernel/traps_64.o
Quoted 5 lines

---

If there is no benefit at all - just drop the patch. Any comments are welcome ;)

I don't think this is the behaviour we want (wrapping around); worse, if people enter a larger power of two they will get zero.

So NAK on this patch, IMO.

-hpa

#3 lore raw
Quoted 1 line · Cyrill Gorcunov

Thanks for review. Agreed with you absolutely. Silly patch, sorry :(

S'okay :) Thanks for trying!

-hpa