[CRIU] [PATCH] Skip restoring certain cgroup root directories when using full mode
Pavel Emelyanov
xemul at parallels.com
Mon Aug 17 07:48:06 PDT 2015
On 08/17/2015 08:07 AM, Hui Kang wrote:
> On Sun, Aug 16, 2015 at 9:20 PM, Pavel Emelyanov <xemul at parallels.com> wrote:
>> On 08/13/2015 07:41 PM, Hui Kang wrote:
>>> Skip these top cgroup directories: cpu, cpuset, cpuacct, memory
>>>
>>> Signed-off-by: Hui Kang <hkang.sunysb at gmail.com>
>>> ---
>>> cgroup.c | 4 ++++
>>> 1 file changed, 4 insertions(+)
>>>
>>> diff --git a/cgroup.c b/cgroup.c
>>> index a4e0146..94749b1 100644
>>> --- a/cgroup.c
>>> +++ b/cgroup.c
>>> @@ -992,6 +992,10 @@ static int prepare_cgroup_dir_properties(char *path, int off, CgroupDirEntry **e
>>> CgroupDirEntry *e = ents[i];
>>> size_t off2 = off;
>>>
>>> + if (strcmp(e->dir_name, "") == 0 &&
>>> + ((strstr(path, "cpu")) || (strstr(path, "memory"))))
>>> + continue;
>>> +
>>
>> With this "continue" won't we skip all the properties restore? The e-s we
>> have here represent all the tree, starting from root and descending. If you
>> skip the root one, then the whole subtree is skipped too.
>
> No. Although the e-s represent the tree, the for loops will iterate
> all the directories.
The loop iterates top-level directories, then dives into children. Can you show
the contents of your cgroup.img file?
> With "full" mode, the top "cpu" and "mem"
> directories should be skipped. The first condition
> (strcmp(e->dir_name, "") guarantees that non-root directory will be
> restored. For a dumped process with cgroup tree "cpuset/foo/foo1". The
> restore process with "full" mode is like
>
> (00.046731) cg: Restored cgroup property value 1 to cpuset/foo/foo1/cpuset.cpus
>
> (00.046803) cg: Restored cgroup property value 0 to cpuset/foo/foo1/cpuset.mems
>
> ... (after all foo1 properties are restore, the it moves to the top level)
>
> (00.047287) cg: ---> Skip Empty name for top path cpu , top dir
>
> As you can see, the patch will only skip those root directories.
>
> One side observations is that the property values of the intermediate
> level (e.g., cpuset/foo) is not dumpped. I confirmed this by running
> crit decode -i cgroup.img --pretty. So when restoring, I have to
> manually create cpuset/foo and populate the value. Is this a bug of
> CRIU?
CRIU only messes with the cgroups tasks live in, so if they don't live
in foo/ then foo will not be restored. And now it seems strange to me
that the root one is being restored by criu.
-- Pavel
More information about the CRIU
mailing list