perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <torsten.foert...@gmx.net>
Subject [RFC] Apache::SizeLimit on Linux
Date Fri, 16 Sep 2005 12:34:48 GMT
Hi,

now that we have Apache2::SizeLimit using Linux::Smaps the old functionality 
of accounting COW pages as shared is restored on linux 2.6. It should show 
for linux 2.4 and 2.6 the same behavior (can someone using 2.4 and 2.6 check 
this please? I have no 2.4 box available) since the algorithm computing the 
figures is the same.

Hence, the problems are the same when paging occurs. And these problems make 
it almost useless by default. The algorithm counting shared memory simply 
checks the reference count of each page table entry. If it is at least 2 the 
page is shared. If a page is not present (paged out) it is not counted at 
all.

Now what happens if the master apache is mostly paged out? Then there are only 
a few shared pages left. That makes SizeLimit terminate the process 
practically after each check.

I have found 3 solutions:

1. obviously: not to use swap space at all

2. mlockall(2) while the master is initializing. This means the master apache 
is always completely present in memory. The lock is not inherited by child 
processes, thus, the workers can be paged out.

3. patch linux to report shared swap space as well. I have not looked into 
this any further.

Would it be right to patch the mlockall(2) into SizeLimit.pm with an option to 
disable it?

This has the drawback that to mlockall a process you must be root. It could be 
done in a PostConfig handler that checks if MIN_SHARED or MAX_UNSHARED are 
set and executes the syscall only if yes. That would then also be the right 
place to check for the presence of /proc/PID/smaps. If only MAX_PROCESS_SIZE 
is set then checking /proc/PID/statm will also do and is a lot cheaper (on 
2.6).

I think a description of the behavior should be in the docs in any case.

Torsten

Mime
View raw message