User-Mode-Linux SYSEMU Patches

Why ?

UML uses ptrace() and PTRACE_SYSCALL to catch system calls. But, by this way, you can't remove the real system call, only monitor it. UML, to avoid the real syscall and emulate it, replaces the real syscall by a call to getpid(). This method generates two context-switches instead of one.

A Solution

A solution is to change the behaviour of ptrace() to not call the real syscall and thus we don't have to replace it by a call to getpid().

How ?

By adding a new command to ptrace(), PTRACE_SYSEMU, that acts like PTRACE_SYSCALL without executing syscall. To add this command we need to patch the host kernel. To use this new command in UML kernel, we need to patch the UML kernel too.

Patches

Host patches
linux-2.4.22 host-sysemu-2.4.22-1.patch
linux-2.4.26 host-sysemu-2.4.26-1.patch
linux-2.6.6 host-sysemu-2.6.6-1.patch
fedora
linux-2.6.6-1.383
host-sysemu-fedora-2.6.6-1.383-1.patch
linux-2.6.7 host-sysemu-2.6.7-1.patch
UML patches
linux-2.4.22 um-sysemu-2.4.22-1.patch
linux-2.4.26 um-sysemu-2.4.26-1.patch
linux-2.6.6 um-sysemu-2.6.6-1.patch

You can use UML linux 2.4.22 on host linux 2.6.6 and vice-versa.

See user-mode-linux web page for more details

Thank you to roland for his help on 2.6.6 patch.

host-sysemu-2.6.7-1.patch by blaisorblade.

Bernard Johnson provides RPM kernel package for fedora.

roland and blaisorblade provide two patches to enable/disable SYSEMU. These both patches must be applied after SYSEMU on UML kernel.

command line parametersysemu_cmdParam.patch"nosysemu" on command line disables SYSEMU
/proc/sysemuproc_sysemu.patch "echo 0 > /proc/sysemu" from inside UML disables SYSEMU

Benchmarks

Basic syscall cost

We try to measure only the syscall cost, i.e. the cost to enter and exit from the kernel. To make this measure, we use the most primitive syscall: getpid(). We use the following program:
#include <stdio.h>
                                                                                
int main(int argc, char** argv)
{
        int i;
        int loop = atol(argv[1]);
                                                                                
        for (i = 0; i < loop; i++)
        {
                getpid();
        }
}
		
Command Native w/o SYSEMU w/ SYSEMU SYSEMU
improvement
time ./getpid 10000000
real 0m7.920s
user 0m3.990s
sys  0m3.940s
real 6m16.956s 6m17.126s 6m16.461s
user 0m5.250s  0m4.846s  0m5.077s
sys  0m58.462s 1m1.731s  0m59.365s
real 3m55.052s 3m56.964s 3m54.179s
user 0m5.962s  0m5.846s  0m5.981s
sys  0m46.385s 0m42.635s 0m47.154s

60 %

MySQL benchmark

Benchmark provided by Christopher S. Aker

benchmark w/o SYSEMUw/ SYSEMUSYSEMU
improvement
Mysql's "run-all-tests"
real 18m38.329s
user 2m37.370s
sys  6m3.040s
real 13m57.353s
user 2m17.370s
sys  3m54.310s

33 %

Mysql test results here: http://www.theshore.net/~caker/uml/sysemu-benchmarks.txt

kernel build

Command w/o SYSEMU w/ SYSEMU SYSEMU
improvement
time make bzImage modules > /dev/null
real 13m35.457s
user 4m18.885s
sys  1m40.481s
real 13m5.980s
user 4m18.096s
sys  1m40.115s

4 %

You can contact me at Laurent@lvivier.info

Valid HTML 4.01! SourceForge.net Logo Support This Project