Can we release vma that include code when one process is running?
Hi, All:
I am writing a patch to swap process memory to swap partition or
swap file.
We think this make system speed up on PC that more little memory. It have a bit like with page replacement algorithm depend application hit, but ours idea is more easier.We found, if we try swap out openoffice.org, this way can save more than 50M memory, and when switch task to run openoffice.org again, it do not read all data that did swapped from swap space at most time.
According to result of experimmnt, the anonymous memory of one
process are more than code
and data, even, it look some shared library as private code.
As general rule, we can only some swap anonymous memory. this's OK!
I also done that.
However my question is if we release vma that include code when one process is running? Of course, if the refcnt of vma is more than one, it can not be released yet. In fact, I writing one patch to do this, some it do successfully on some simple process, but in more time, I will get a SIGSEGV!
I am running IA32 architecture, I used one little python script to
try this. and
get SIGSEGV each time. I dump memory that include that code, they are too simple:
...
nop
int $0x80
ret
nop
...
It seem that code in other place jump here to enter kernel. this is
in a anonymous
code area.
At first time, I think this SIGSEGV will trigger by anonymous code
that is swapped,
but I wrote one specical condition check to filte out this sort of code, IOW, I do not swap out it. but I still get SIGSEGV.
May be, we can not be release the vma that include code? or, Is
there have some errors
in my words for page fault?
sailor
Quoted 8 lines · liyu@WAN wrote:
It seem that code in other place jump here to enter kernel. this is
in a anonymous
code area.
At first time, I think this SIGSEGV will trigger by anonymous code
that is swapped,
but I wrote one specical condition check to filte out this sort of code, IOW, I do not swap out it. but I still get SIGSEGV.
Quoted 4 lines
May be, we can not be release the vma that include code? or, Is there
have some errors
in my words for page fault?
That's right, you cannot release the VMA if the application still expects to use memory in that area. The page fault handler will see that no VMA exists in that region and raise a SIGSEGV.
See arch/i386/mm/fault.c:do_page_fault
Nick
Signature · 3 lines
SUSE Labs, Novell Inc. Send instant messages to your online friends http://au.messenger.yahoo.com
Sorry, I perhaps didn't said clearly.
As I knwon, if we remove vma from vma tree of task, the SIGSEGV must be got! but I am not removed them , I just unmapped them. and the SIGSEGV occurs some times, not alway.
I doublt on it.
Any clearly idea?
many thanks.
Quoted 24 lines
Quoted 8 lines · liyu@WAN wrote:
It seem that code in other place jump here to enter kernel. this
is in a anonymous
code area.
At first time, I think this SIGSEGV will trigger by anonymous code
that is swapped,
but I wrote one specical condition check to filte out this sort of code, IOW, I do not swap out it. but I still get SIGSEGV.Quoted 4 lines
May be, we can not be release the vma that include code? or, Is
there have some errors
in my words for page fault?That's right, you cannot release the VMA if the application still expects to use memory in that area. The page fault handler will see that no VMA exists in that region and raise a SIGSEGV.
See arch/i386/mm/fault.c:do_page_fault
Nick
Quoted 4 lines · liyu@WAN wrote:
Sorry, I perhaps didn't said clearly.
Quoted 8 lines
As I knwon, if we remove vma from vma tree of task, the SIGSEGV must be got! but I am not removed them , I just unmapped them. and the SIGSEGV occurs some times, not alway.
I doublt on it.
Any clearly idea?
No clear ideas, no. Are you doing the proper synchronization and flushing required when unmapping those regions?
If you can post your unmapping code to lkml, someone might be able to spot a bug in it.
Thanks,
Nick
Signature · 3 lines
SUSE Labs, Novell Inc. Send instant messages to your online friends http://au.messenger.yahoo.com