Skip to contentSkip to conversation

Port SquashFS to 2.6

PATCH [email protected] 3 participants 4 messages Jul 22, 2003 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"JE" == J.ANvrnEngel <[email protected]> writes:

Quoted 5 lines · JE> On Sat, 19 July 2003 22:40:22 -0700, [email protected] wrote:
Quoted 5 lines

- I would imagine that the acceptable stack usage for functions would depend on where they are called and what they call. Coulc you suggest a rule-of-thumb number for address_space_operations.readpage (say, would 1kB be OK but not 3kB?)

JE> Depending on where and what you do,...

Well, isn't asking about address_space_operations.readpage specific enough?

JE> ... also depends a bit on the architecture. s390 has JE> giant stacks because function call overhead is huge, ...

The discussion was about putting variables (or arrays or large structs) the kernel programmer defines on the stack, and I do not think architecture calling convention has much to do with this.

If an architecture has a big stack usage per call that is imposed by the ABI, and larger kernel stack is allocated compared to other architectures because of this reason, shouldn't there be about the same amount of usable space left for the kernel programs within the allocated per-process kernel stack space to use? If that is not the case then the port to that particular architecture would not be optimal, wouldn't it?

#3 lore raw
Quoted 7 lines · On Mon, 21 Jul 2003 19:52:39 PDT, [email protected] said:

If an architecture has a big stack usage per call that is imposed by the ABI, and larger kernel stack is allocated compared to other architectures because of this reason, shouldn't there be about the same amount of usable space left for the kernel programs within the allocated per-process kernel stack space to use? If that is not the case then the port to that particular architecture would not be optimal, wouldn't it?

Not necessarily. It's quite possible (likely even) that one architecture might have N bytes overhead per call, and is allowed a 4K stack, and some other architecture has (N+30%) overhead, so 4K isn't enough - 5K is needed. However, other considerations cause a whole-page allocation, so instead of allocating 5K, it goes to 8K, with a 3K wastage....

So yes, you can end up with suboptimal results.

#4 lore raw
Quoted 6 lines · On Mon, 21 July 2003 23:42:37 -0400, [email protected] wrote:

Not necessarily. It's quite possible (likely even) that one architecture might have N bytes overhead per call, and is allowed a 4K stack, and some other architecture has (N+30%) overhead, so 4K isn't enough - 5K is needed. However, other considerations cause a whole-page allocation, so instead of allocating 5K, it goes to 8K, with a 3K wastage....

And even worse, for short call chains, 4.1k would be enough, but for long ones, you need up to 5.2k. How much is too much? We don't know and it depends, so make a pessimistic guess.

Joern

#5 lore raw
In reply to [email protected]
Quoted 6 lines · On Mon, 21 July 2003 19:52:39 -0700, [email protected] wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"JE" == JörnEngel <[email protected]> writes:

JE> Depending on where and what you do,...

Well, isn't asking about address_space_operations.readpage specific enough?

Not for someone as lazy as me. If you want to know for sure:
- Figure out all possible path leading to that function.
- Figure out all possible path called by that function.
- Sum up all the stack allocated variable size for both.
- Add the architecture-specific function call overhead, multiplied by the number of functions on both paths.

Now you have the stack consumption that you were not responsible for, which depends on the architecture. Substract that number from the total stack size, which is also architecture-specific and you know how much is left. It is a lot of work and the hard part is finding all the possible paths. If you have a good idea how to automate that, please tell me. Else, we have to live with rules of thumb.

Quoted 8 lines

JE> ... also depends a bit on the architecture. s390 has JE> giant stacks because function call overhead is huge, ...

The discussion was about putting variables (or arrays or large structs) the kernel programmer defines on the stack, and I do not think architecture calling convention has much to do with this.

Quoted 7 lines

If an architecture has a big stack usage per call that is imposed by the ABI, and larger kernel stack is allocated compared to other architectures because of this reason, shouldn't there be about the same amount of usable space left for the kernel programs within the allocated per-process kernel stack space to use? If that is not the case then the port to that particular architecture would not be optimal, wouldn't it?

You end up with all sorts of architecture dependent stuff when allocating stack. A long is 4 or 8 bytes, same for pointers, the amount and size of saved registers differs, the size of the stack differs, some architectures have a seperate interrupt stack.

If you look closely at the kernel, there is currently no way of telling whether it contains stack overflows waiting to happen, or not. We live with lots of hope and the comforting feeling that there were not many stack overflows in the past. I wish we had better tools, but we don't.

Jörn

Signature · 3 lines
The cheapest, fastest and most reliable components of a computer
system are those that aren't there.
-- Gordon Bell, DEC labratories