Skip to contentSkip to conversation

Documentation: Explain 4K stacks in slightly more detail.

PATCH In review Robert P. J. Day 3 participants 7 messages Apr 25, 2008 – Apr 26, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Documentation: Explain 4K stacks in slightly more detail.

---

arch/x86/Kconfig.debug +11 -5
index 610aaec..e40d8d4 100644
@@ -109,11 +109,17 @@ config 4KSTACKS
 	depends on X86_32
 	default y
 	help
-	  If you say Y here the kernel will use a 4Kb stacksize for the
-	  kernel stack attached to each process/thread. This facilitates
-	  running more threads on a system and also reduces the pressure
-	  on the VM subsystem for higher order allocations. This option
-	  will also use IRQ stacks to compensate for the reduced stackspace.
+	  If you say Y here, this will redefine the value of THREAD_SIZE
+	  from 8K to 4K and subsequently use a 4K kernel stack for each
+	  process/thread.  This facilitates running more threads on a
+	  system and also reduces the pressure on the VM subsystem for
+	  higher-order allocations (that is, trying to find two consecutive
+	  4K pages rather than just one for each per-process kernel stack).
+
+	  To compensate for the smaller per-process stack, interrupts will
+	  now be given their own 4K per-cpu stacks.  For more discussion,
+	  see http://lwn.net/Articles/150580/.  Also, see the implementation
+	  in the source file arch/x86/kernel/irq_32.c.
 
 config X86_FIND_SMP_CONFIG
 	def_bool y

====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
Have classroom, will lecture.

http://crashcourse.ca Waterloo, Ontario, CANADA
====================================

#1 lore raw

[patch mangled so I can comment on each sentence]

arch/x86/Kconfig.debug config 4KSTACKS

Quoted 5 lines · Robert P. J. Day
arch/x86/Kconfig.debug +3 -2
-	  If you say Y here the kernel will use a 4Kb stacksize for the
-	  kernel stack attached to each process/thread.
+	  If you say Y here, this will redefine the value of THREAD_SIZE
+	  from 8K to 4K and subsequently use a 4K kernel stack for each
+	  process/thread.

This is a terrible change. The user doesn't care what THREAD_SIZE is or means within the kernel. The programmer can grep for the CONFIG option to see what changed. Nack this portion.

arch/x86/Kconfig.debug config 4KSTACKS · line 117

Quoted 7 lines
arch/x86/Kconfig.debug +4 -3
-       This facilitates
-	  running more threads on a system and also reduces the pressure
-	  on the VM subsystem for higher order allocations.
+       This facilitates running more threads on a
+	  system and also reduces the pressure on the VM subsystem for
+	  higher-order allocations (that is, trying to find two consecutive
+	  4K pages rather than just one for each per-process kernel stack).

Good that you've explained the jargon. But I'd rather see it removed. How does this read?

This facilitates running more threads on your system and means the VM system has to work less hard to find two consecutive 4k pages.

arch/x86/Kconfig.debug config 4KSTACKS

Quoted 4 lines
arch/x86/Kconfig.debug +2 -2
-	  This option
-	  will also use IRQ stacks to compensate for the reduced stackspace.
+	  To compensate for the smaller per-process stack, interrupts will
+	  now be given their own 4K per-cpu stacks.

Again, your text is an improvement. How about this though:

To partially compensate for the smaller stack size, interrupts will run on their own stack, reducing the chances of a stack overflow.

arch/x86/Kconfig.debug config 4KSTACKS · line 122

Quoted 3 lines
arch/x86/Kconfig.debug +3 -0
+	  For more discussion,
+	  see http://lwn.net/Articles/150580/.  Also, see the implementation
+	  in the source file arch/x86/kernel/irq_32.c.

I'm not keen on this sentence.

Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
#2 lore raw

Re: [PATCH] Documentation: Explain 4K stacks in slightly more

In reply to Robert P. J. Day
Quoted 11 lines · Matthew Wilcox

[patch mangled so I can comment on each sentence]

arch/x86/Kconfig.debug config 4KSTACKS

Quoted 5 lines · Robert P. J. Day
arch/x86/Kconfig.debug +3 -2
-	  If you say Y here the kernel will use a 4Kb stacksize for the
-	  kernel stack attached to each process/thread.
+	  If you say Y here, this will redefine the value of THREAD_SIZE
+	  from 8K to 4K and subsequently use a 4K kernel stack for each
+	  process/thread.

This is a terrible change. The user doesn't care what THREAD_SIZE is or means within the kernel. The programmer can grep for the CONFIG option to see what changed. Nack this portion.

i thought about that, and the only reason i mentioned it is that the consequences of selecting 4K stacks is not at all obvious. i figured that, if someone was going to try something that tricky, he/she might want to understand what was happening under the hood. but i'm happy to take it out.

Quoted 11 lines

arch/x86/Kconfig.debug config 4KSTACKS · line 117

Quoted 7 lines
arch/x86/Kconfig.debug +4 -3
-       This facilitates
-	  running more threads on a system and also reduces the pressure
-	  on the VM subsystem for higher order allocations.
+       This facilitates running more threads on a
+	  system and also reduces the pressure on the VM subsystem for
+	  higher-order allocations (that is, trying to find two consecutive
+	  4K pages rather than just one for each per-process kernel stack).

Good that you've explained the jargon. But I'd rather see it removed. How does this read?

Quoted 3 lines

This facilitates running more threads on your system and means the VM system has to work less hard to find two consecutive 4k pages.

that sounds reasonable. i can find some middle ground between the two.

Quoted 10 lines

arch/x86/Kconfig.debug config 4KSTACKS

Quoted 4 lines
arch/x86/Kconfig.debug +2 -2
-	  This option
-	  will also use IRQ stacks to compensate for the reduced stackspace.
+	  To compensate for the smaller per-process stack, interrupts will
+	  now be given their own 4K per-cpu stacks.

Again, your text is an improvement. How about this though:

To partially compensate for the smaller stack size, interrupts will run on their own stack, reducing the chances of a stack overflow.

i would want to keep the explanation that there is going to an interrupt stack *per CPU*. that's not obvious from your text.

Quoted 5 lines

arch/x86/Kconfig.debug config 4KSTACKS · line 122

Quoted 3 lines
arch/x86/Kconfig.debug +3 -0
+	  For more discussion,
+	  see http://lwn.net/Articles/150580/.  Also, see the implementation
+	  in the source file arch/x86/kernel/irq_32.c.

I'm not keen on this sentence.

i can leave out the reference to the source file, but i still think a pointer to a discussion of the feature would be useful.

rday
--

====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
Have classroom, will lecture.

http://crashcourse.ca Waterloo, Ontario, CANADA
====================================

#3 lore raw
In reply to Robert P. J. Day
Quoted 13 lines · Robert P. J. Day
Quoted 11 lines · Matthew Wilcox

[patch mangled so I can comment on each sentence]

arch/x86/Kconfig.debug config 4KSTACKS

Quoted 5 lines · Robert P. J. Day
arch/x86/Kconfig.debug +3 -2
-	  If you say Y here the kernel will use a 4Kb stacksize for the
-	  kernel stack attached to each process/thread.
+	  If you say Y here, this will redefine the value of THREAD_SIZE
+	  from 8K to 4K and subsequently use a 4K kernel stack for each
+	  process/thread.

This is a terrible change. The user doesn't care what THREAD_SIZE is or means within the kernel. The programmer can grep for the CONFIG option to see what changed. Nack this portion.

Quoted 5 lines

i thought about that, and the only reason i mentioned it is that the consequences of selecting 4K stacks is not at all obvious. i figured that, if someone was going to try something that tricky, he/she might want to understand what was happening under the hood. but i'm happy to take it out.

I just ran a grep for 4KSTACKS ... this text appears to have been duplicated into three other architectures, so should be updated on all of them together. Except for the bit about the interrupt stacks; as far as I can tell, they don't do that.

Quoted 7 lines
Quoted 7 lines

arch/x86/Kconfig.debug config 4KSTACKS

Quoted 4 lines
arch/x86/Kconfig.debug +2 -2
-	  This option
-	  will also use IRQ stacks to compensate for the reduced stackspace.
+	  To compensate for the smaller per-process stack, interrupts will
+	  now be given their own 4K per-cpu stacks.

Again, your text is an improvement. How about this though:

Quoted 6 lines
Quoted 3 lines

To partially compensate for the smaller stack size, interrupts will run on their own stack, reducing the chances of a stack overflow.

i would want to keep the explanation that there is going to an interrupt stack *per CPU*. that's not obvious from your text.

Why does the user care? It's important to you and me, but someone who's configuring their kernel needs to be told enough information to make an informed decision about an option. There's already a lot of complex information here, let's not distract them with an implementation detail.

Quoted 8 lines
Quoted 5 lines

arch/x86/Kconfig.debug config 4KSTACKS · line 122

Quoted 3 lines
arch/x86/Kconfig.debug +3 -0
+	  For more discussion,
+	  see http://lwn.net/Articles/150580/.  Also, see the implementation
+	  in the source file arch/x86/kernel/irq_32.c.

I'm not keen on this sentence.

i can leave out the reference to the source file, but i still think a pointer to a discussion of the feature would be useful.

I disagree; someone may be configuring their kernel on an aeroplane (don't laugh, I have) or other location without internet access. A summary of the discussion may be useful, but keep it short.

By the way, something missing from the original is "what to do if you don't understand". A sentence like:

	  If you don't know how to answer this question, it is safest to
	  say "N".

goes a long way. OK, this is under DEBUG_KERNEL, but even so.

Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
#4 lore raw

Re: [PATCH] Documentation: Explain 4K stacks in slightly more

In reply to Robert P. J. Day
Quoted 4 lines · Matthew Wilcox

I just ran a grep for 4KSTACKS ... this text appears to have been duplicated into three other architectures, so should be updated on all of them together. Except for the bit about the interrupt stacks; as far as I can tell, they don't do that.

all right, that's just confusing. for one thing, 4K stacks are still classified as a "debug" feature under x86, but apparently a regular feature under m68knommu and back to being a debug feature under SH. grrrrr.

i'm going to look at this more closely. carry on.

rday
--

====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
Have classroom, will lecture.

http://crashcourse.ca Waterloo, Ontario, CANADA
====================================

#5 lore raw
In reply to Robert P. J. Day
Quoted 2 lines · Matthew Wilcox
	  If you don't know how to answer this question, it is safest to
	  say "N".

How about:

If unsure, say "N".

Nick.

Signature · 2 lines
PGP Key ID = 0x418487E7                      http://www.nick-andrew.net/
PGP Key fingerprint = B3ED 6894 8E49 1770 C24A  67E3 6266 6EB9 4184 87E7
#6 lore raw

Re: [PATCH] Documentation: Explain 4K stacks in slightly more

In reply to Robert P. J. Day
Quoted 7 lines · Nick Andrew
Quoted 2 lines · Matthew Wilcox
	  If you don't know how to answer this question, it is safest to
	  say "N".

How about:

If unsure, say "N".

as matthew pointed out earlier (and i was unaware of), 4K stacks is also an option for architectures SH and M68KNOMMU. so i'm just going to hold off until maybe this is centralized.

rday
--

====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
Have classroom, will lecture.

http://crashcourse.ca Waterloo, Ontario, CANADA
====================================