[RFC PATCH 1/1] swap namespaces: introduce basic, simple swap namespaces (v3)

Serge E. Hallyn serue at us.ibm.com
Mon Apr 28 05:57:02 PDT 2008


One way of doing application memory checkpoint which was suggested
by Dave Hansen was to exploit the swapfile for storing memory, and
just dump the relevant metadata.

To that end, this patch allows a set of tasks to be associated with
one specific swapfile.  I called it 'swap namespaces', but it's
actually not a namespace at all, just a filter.  The initial swap_ns
is null.  In this swap_ns multiple swapfiles can be used.  In a child
swap_ns, only one swapfile can be swapon'd.  A swapfile can only be
active in one swap_ns.  When you clone a new swap_ns, you begin with
no swapfile.

You can't unshare a swap_ns, you must use clone.  You must also
CLONE_NEWIPC and not CLONE_VM.

This patch doesn't address the limited number of swapfiles per
system, which I imagine will become a tremendous shortcoming for
machines intended to run large number of c/r jobs.

This patch is based on top of Cedric's clone64 patchset so as
to have a free CLONE_SWAPNS flag, so you pass CLONE_SWAPNS in
through cloneflags_hi.

One way to test is as follows:

        login 1                         login 2
=======================================================================
dd if=/dev/zero of=/s1 bs=1M \
	count=512
dd if=/dev/zero of=/s2 bs=1M \
	count=512
strings /s2
 (you see only the swap signature)
clone64(CLONE_NEWSWAP|CLONE_NEWIPC)
				    clone64(CLONE_NEWSWAP|CLONE_NEWIPC)
swapon /s1
                                    swapon /s2
cd $LTPDIR
runltp -l out1 > txt1 2>&1
(let ltp run...)
exit
                                    exit

Now you can notice the following:

The output of strings /s2 contains no memory from the ltp run.

In ltp the following tests failed in addition to tests on an
unpatched kernel, or a patched kernel but not in a swap_ns:
        swapon01
        swapon02
        swapoff01
        swapoff02
        mem01

The first four are because you cannot swapon a new swapfile,
since you already have /s1 swapped on.
The last one, if you look at your console, is because mem01 was
killed by oom.

As I often note with patchsets like these, I don't expect this
code or even the design to go upstream, although the patch appears
to work.  Rather this posting is mainly to collect feedback and
discussion.

thanks,
-serge



More information about the Containers mailing list