Re: Allocating and switching to larger stack during syscall

2018-02-03 Thread Waldek Kozaczuk
I actually managed to modify entry.S to call C function to set up large 
stack lazily and it works. I will be sending patch soon.

On Friday, February 2, 2018 at 4:43:07 PM UTC-5, Waldek Kozaczuk wrote:
>
> I am trying to implement the idea that Nadav proposed to save memory when 
> implementing callstack switch during syscall. Here is excerpt from our 
> conversation:
>
> " 
>
>>
>> I was also wondering that existing implementation of syscall stack makes 
>> every app thread allocate it upon creation eagerly whether syscall are 
>> going to be made or not. For example java apps (which I believe use libc 
>> functions) would be penalized by memory usage. I was wondering how 
>> difficult it would be to make allocation of syscall stack lazily only when 
>> first syscall is made.
>>
>
> The problem is that we won't have a stack to do this allocation work on.
>
> One thing we could do have for all threads a tiny syscall stack (doesn't 
> even need to be a whole page, can be smaller!), and the first thing a 
> syscall does is
> to check if this thread has this tiny stack, and if it does it allocates a 
> different one. The stack needs to be just big enough for malloc() to run. 
> We could
> even avoid calling malloc() directly and just send a message to a 
> different thread to do this for us, but I think this will be an overkill.
> "
>
> So I am trying to avoid messing with assembly as much as possible. Is it 
> possible to implement it almost all in C by calling a function from 
> linux.cc/syscall_wrapper() that would lazily allocate larger stack? 
> Obviously we would still need to change RSP register to new value and then 
> restore it back with could be done with asm("...") instruction. Is it 
> possible?
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Allocating and switching to larger stack during syscall

2018-02-02 Thread Waldek Kozaczuk
I am trying to implement the idea that Nadav proposed to save memory when 
implementing callstack switch during syscall. Here is excerpt from our 
conversation:

" 

>
> I was also wondering that existing implementation of syscall stack makes 
> every app thread allocate it upon creation eagerly whether syscall are 
> going to be made or not. For example java apps (which I believe use libc 
> functions) would be penalized by memory usage. I was wondering how 
> difficult it would be to make allocation of syscall stack lazily only when 
> first syscall is made.
>

The problem is that we won't have a stack to do this allocation work on.

One thing we could do have for all threads a tiny syscall stack (doesn't 
even need to be a whole page, can be smaller!), and the first thing a 
syscall does is
to check if this thread has this tiny stack, and if it does it allocates a 
different one. The stack needs to be just big enough for malloc() to run. 
We could
even avoid calling malloc() directly and just send a message to a different 
thread to do this for us, but I think this will be an overkill.
"

So I am trying to avoid messing with assembly as much as possible. Is it 
possible to implement it almost all in C by calling a function from 
linux.cc/syscall_wrapper() that would lazily allocate larger stack? 
Obviously we would still need to change RSP register to new value and then 
restore it back with could be done with asm("...") instruction. Is it 
possible?

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.