Removing an executable while it runs
Hello,
I would like to remove an executable from the file-system while it is running and get all the blocks back immediately, not after the end of the program. Is this possible ?
From what I understand, the inode is not released until the program ends. Do all the file-systems behave the same way ?
Thank you for your help.
Quoted 11 lines · Cyrille Beraud
Hello,
I would like to remove an executable from the file-system while it is running and
get all the blocks back immediately, not after the end of the program. Is this possible ?
From what I understand, the inode is not released until the program
ends. Do all the
file-systems behave the same way ?Thank you for your help.
It is not possible to reclaim the disk space until the program exits. This is because of demand paging of executables. The file must be kept around to handle possible future page faults, otherwise the program would crash if it called code that hadn't been loaded yet or was discarded due to memory pressure. This is true of all filesystems.
--
Brian Gerst
Quoted 12 lines · Brian Gerst
Quoted 10 lines · Cyrille Beraud
Hello,
I would like to remove an executable from the file-system while it is running and
get all the blocks back immediately, not after the end of the program. Is this possible ?
From what I understand, the inode is not released until the program
ends. Do all the
file-systems behave the same way ?
Quoted 7 lines
Quoted 1 line
Thank you for your help.
It is not possible to reclaim the disk space until the program exits. This is because of demand paging of executables. The file must be kept around to handle possible future page faults, otherwise the program would crash if it called code that hadn't been loaded yet or was discarded due to memory pressure. This is true of all filesystems.
Couldn't you use mlockall() to ensure that demand paging is not a factor? Then you should be able to free up the disk space since the actual application is guaranteed to be in ram.
Chris
Signature · 4 lines
Chris Friesen | MailStop: 043/33/F10 Nortel Networks | work: (613) 765-0557 3500 Carling Avenue | fax: (613) 765-2986 Nepean, ON K2H 8E9 Canada | email: [email protected]
Quoted 4 lines · Christopher Friesen
Quoted 4 lines
Couldn't you use
mlockall()to ensure that demand paging is not a factor? Then you should be able to free up the disk space since the actual application is guaranteed to be in ram.
mlockall() only locks those pages that are **currently** paged in, or optionally those that will be paged in in the future. Unless you have a way to make sure that all pages of the binary are actually in memory before you call mlockall(), this gains you nothing.
Signature · 1 line
[email protected]
Quoted 4 lines · [email protected] said:
mlockall()only locks those pages that are **currently** paged in, or optionally those that will be paged in in the future. Unless you have a way to make sure that all pages of the binary are actually in memory before you callmlockall(), this gains you nothing.
No, mlockall will page in the entire process before returning if you ask it to.
See this snippet in mlock_fixup:
if (newflags & VM_LOCKED) {
pages = -pages;
make_pages_present(start, end);
}VM_LOCKED comes in through the mlockall system call.
Jeff
Quoted 10 lines · Jeff Dike
Quoted 4 lines · [email protected] said:
mlockall()only locks those pages that are **currently** paged in, or optionally those that will be paged in in the future. Unless you have a way to make sure that all pages of the binary are actually in memory before you callmlockall(), this gains you nothing.No, mlockall will page in the entire process before returning if you ask it to.
See this snippet in
mlock_fixup:
Quoted 8 lines
if (newflags & VM_LOCKED) { pages = -pages; make_pages_present(start, end); }
VM_LOCKEDcomes in through the mlockall system call.Jeff
Well, according to the man page, mister Walberg is right. How can I force mlockall to page in the entire process ? And if it is possible, I guess it won't resolve my problem since it is the filesystem which refuses to release the blocks, right ?
To be more precise, here is my situation: the executable file is located on a ramfs filesystem. Once it is started, I would like to get the space back so that the RAM can be used. Is there a clean solution ?
P.S: on behalf of Cyrille (who made the first post), I would like to thank you for your answers, it is greatly appreciated.
P.P.S: is it required to include the people involved in the thread in the Cc: field ? I have looked in the mailing list FAQ and have not found the reason.
Signature · 1 line
Eric-Olivier Lamey