<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 18, 2015 at 11:13 AM, Pavel Emelyanov <span dir="ltr">&lt;<a href="mailto:xemul@parallels.com" target="_blank">xemul@parallels.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 08/18/2015 12:55 AM, Hui Kang wrote:<br>
&gt; On Mon, Aug 17, 2015 at 10:48 AM, Pavel Emelyanov &lt;<a href="mailto:xemul@parallels.com">xemul@parallels.com</a>&gt; wrote:<br>
&gt;&gt; On 08/17/2015 08:07 AM, Hui Kang wrote:<br>
&gt;&gt;&gt; On Sun, Aug 16, 2015 at 9:20 PM, Pavel Emelyanov &lt;<a href="mailto:xemul@parallels.com">xemul@parallels.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt; On 08/13/2015 07:41 PM, Hui Kang wrote:<br>
&gt;&gt;&gt;&gt;&gt; Skip these top cgroup directories: cpu, cpuset, cpuacct, memory<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Signed-off-by: Hui Kang &lt;<a href="mailto:hkang.sunysb@gmail.com">hkang.sunysb@gmail.com</a>&gt;<br>
&gt;&gt;&gt;&gt;&gt; ---<br>
&gt;&gt;&gt;&gt;&gt;  cgroup.c | 4 ++++<br>
&gt;&gt;&gt;&gt;&gt;  1 file changed, 4 insertions(+)<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; diff --git a/cgroup.c b/cgroup.c<br>
&gt;&gt;&gt;&gt;&gt; index a4e0146..94749b1 100644<br>
&gt;&gt;&gt;&gt;&gt; --- a/cgroup.c<br>
&gt;&gt;&gt;&gt;&gt; +++ b/cgroup.c<br>
&gt;&gt;&gt;&gt;&gt; @@ -992,6 +992,10 @@ static int prepare_cgroup_dir_properties(char *path, int off, CgroupDirEntry **e<br>
&gt;&gt;&gt;&gt;&gt;               CgroupDirEntry *e = ents[i];<br>
&gt;&gt;&gt;&gt;&gt;               size_t off2 = off;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; +             if (strcmp(e-&gt;dir_name, &quot;&quot;) == 0 &amp;&amp;<br>
&gt;&gt;&gt;&gt;&gt; +                 ((strstr(path, &quot;cpu&quot;)) || (strstr(path, &quot;memory&quot;))))<br>
&gt;&gt;&gt;&gt;&gt; +                     continue;<br>
&gt;&gt;&gt;&gt;&gt; +<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; With this &quot;continue&quot; won&#39;t we skip all the properties restore? The e-s we<br>
&gt;&gt;&gt;&gt; have here represent all the tree, starting from root and descending. If you<br>
&gt;&gt;&gt;&gt; skip the root one, then the whole subtree is skipped too.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; No. Although the e-s represent the tree, the for loops will iterate<br>
&gt;&gt;&gt; all the directories.<br>
&gt;&gt;<br>
&gt;&gt; The loop iterates top-level directories, then dives into children. Can you show<br>
&gt;&gt; the contents of your cgroup.img file?<br>
&gt;<br>
&gt; {<br>
&gt;     &quot;magic&quot;: &quot;CGROUP&quot;,<br>
&gt;     &quot;entries&quot;: [<br>
<br>
</div></div>Ah, I see. The thing is that in your case you don&#39;t have nested directories. In<br>
particular -- cpuset is only the &quot;foo/foo1&quot; dir, so your check doesn&#39;t match<br>
one and it&#39;s restored. The cpu/cpuacct are both &quot;/&quot; only, so you check matches<br>
them, skips, but we notice nothing as there are no sub-directories.<br></blockquote><div><br></div><div>HI, Pavel,<br></div><div>can you give me an example which has nested directories? I added the process to foo/foo1/tasks and then dump the process. So no value in foo is dumped. <br><br></div><div>For a nested cgroup directory, do you mean I should also add a parent tasks to foo and then dump both parent and child?<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
And for the same reason restore-special-props works OK -- the cpuset controller<br>
is &quot;foo/foo1&quot;, so it gets restored successfully.<br>
<br>
So my concern about the wrong place for strcmp(name, &quot;&quot;) check still stands.<br></blockquote><div><br></div><div>If you could give me an counter example like nested directory, it will helpful to fix this check. Thanks.<br><br></div><div>- Hui<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
-- Pavel<br>
</font></span><div><div class="h5"><br>
&gt;         {<br>
&gt;             &quot;sets&quot;: [<br>
&gt;                 {<br>
&gt;                     &quot;id&quot;: 2,<br>
&gt;                     &quot;ctls&quot;: [<br>
&gt;                         {<br>
&gt;                             &quot;name&quot;: &quot;blkio&quot;,<br>
&gt;                             &quot;path&quot;: &quot;/&quot;<br>
&gt;                         },<br>
&gt;                         {<br>
&gt;                             &quot;name&quot;: &quot;cpu&quot;,<br>
&gt;                             &quot;path&quot;: &quot;/&quot;<br>
&gt;                         },<br>
&gt;                         {<br>
&gt;                             &quot;name&quot;: &quot;cpuacct&quot;,<br>
&gt;                             &quot;path&quot;: &quot;/&quot;<br>
&gt;                         },<br>
&gt;                         {<br>
&gt;                             &quot;name&quot;: &quot;cpuset&quot;,<br>
&gt;                             &quot;path&quot;: &quot;/foo/foo1&quot;<br>
&gt;                         },<br>
&gt;                         {<br>
&gt;                             &quot;name&quot;: &quot;devices&quot;,<br>
&gt;                             &quot;path&quot;: &quot;/&quot;<br>
&gt;                         },<br>
&gt;                         {<br>
&gt;                             &quot;name&quot;: &quot;freezer&quot;,<br>
&gt;                             &quot;path&quot;: &quot;/&quot;<br>
&gt;                         },<br>
&gt;                         {<br>
&gt;                             &quot;name&quot;: &quot;hugetlb&quot;,<br>
&gt;                             &quot;path&quot;: &quot;/&quot;<br>
&gt;                         },<br>
&gt;                         {<br>
&gt;                             &quot;name&quot;: &quot;memory&quot;,<br>
&gt;                             &quot;path&quot;: &quot;/&quot;<br>
&gt;                         },<br>
&gt;                         {<br>
&gt;                             &quot;name&quot;: &quot;name=systemd&quot;,<br>
&gt;                             &quot;path&quot;: &quot;/&quot;<br>
&gt;                         },<br>
&gt;                         {<br>
&gt;                             &quot;name&quot;: &quot;perf_event&quot;,<br>
&gt;                             &quot;path&quot;: &quot;/&quot;<br>
&gt;                         }<br>
&gt;                     ]<br>
&gt;                 }<br>
&gt;             ],<br>
&gt;             &quot;controllers&quot;: [<br>
&gt;                 {<br>
&gt;                     &quot;cnames&quot;: [<br>
&gt;                         &quot;cpuset&quot;<br>
&gt;                     ],<br>
&gt;                     &quot;dirs&quot;: [<br>
&gt;                         {<br>
&gt;                             &quot;dir_name&quot;: &quot;foo/foo1&quot;,<br>
&gt;                             &quot;properties&quot;: [<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpuset.cpus&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;1&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpuset.mems&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpuset.memory_migrate&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpuset.cpu_exclusive&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpuset.mem_exclusive&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpuset.mem_hardwall&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpuset.memory_spread_page&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpuset.memory_spread_slab&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpuset.sched_load_balance&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;1&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpuset.sched_relax_domain_level&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;-1&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;notify_on_release&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 }<br>
&gt;                             ]<br>
&gt;                         }<br>
&gt;                     ]<br>
&gt;                 },<br>
&gt;                 {<br>
&gt;                     &quot;cnames&quot;: [<br>
&gt;                         &quot;cpu&quot;<br>
&gt;                     ],<br>
&gt;                     &quot;dirs&quot;: [<br>
&gt;                         {<br>
&gt;                             &quot;dir_name&quot;: &quot;&quot;,<br>
&gt;                             &quot;properties&quot;: [<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpu.shares&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;1024&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpu.cfs_period_us&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;100000&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;cpu.cfs_quota_us&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;-1&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;notify_on_release&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 }<br>
&gt;                             ]<br>
&gt;                         }<br>
&gt;                     ]<br>
&gt;                 },<br>
&gt;                 {<br>
&gt;                     &quot;cnames&quot;: [<br>
&gt;                         &quot;cpuacct&quot;<br>
&gt;                     ],<br>
&gt;                     &quot;dirs&quot;: [<br>
&gt;                         {<br>
&gt;                             &quot;dir_name&quot;: &quot;&quot;<br>
&gt;                         }<br>
&gt;                     ]<br>
&gt;                 },<br>
&gt;                 {<br>
&gt;                     &quot;cnames&quot;: [<br>
&gt;                         &quot;memory&quot;<br>
&gt;                     ],<br>
&gt;                     &quot;dirs&quot;: [<br>
&gt;                         {<br>
&gt;                             &quot;dir_name&quot;: &quot;&quot;,<br>
&gt;                             &quot;properties&quot;: [<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;memory.limit_in_bytes&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;-1&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;memory.use_hierarchy&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;notify_on_release&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 }<br>
&gt;                             ]<br>
&gt;                         }<br>
&gt;                     ]<br>
&gt;                 },<br>
&gt;                 {<br>
&gt;                     &quot;cnames&quot;: [<br>
&gt;                         &quot;devices&quot;<br>
&gt;                     ],<br>
&gt;                     &quot;dirs&quot;: [<br>
&gt;                         {<br>
&gt;                             &quot;dir_name&quot;: &quot;&quot;<br>
&gt;                         }<br>
&gt;                     ]<br>
&gt;                 },<br>
&gt;                 {<br>
&gt;                     &quot;cnames&quot;: [<br>
&gt;                         &quot;freezer&quot;<br>
&gt;                     ],<br>
&gt;                     &quot;dirs&quot;: [<br>
&gt;                         {<br>
&gt;                             &quot;dir_name&quot;: &quot;&quot;,<br>
&gt;                             &quot;properties&quot;: [<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;notify_on_release&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 }<br>
&gt;                             ]<br>
&gt;                         }<br>
&gt;                     ]<br>
&gt;                 },<br>
&gt;                 {<br>
&gt;                     &quot;cnames&quot;: [<br>
&gt;                         &quot;blkio&quot;<br>
&gt;                     ],<br>
&gt;                     &quot;dirs&quot;: [<br>
&gt;                         {<br>
&gt;                             &quot;dir_name&quot;: &quot;&quot;,<br>
&gt;                             &quot;properties&quot;: [<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;blkio.weight&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;1000&quot;<br>
&gt;                                 },<br>
&gt;                                 {<br>
&gt;                                     &quot;name&quot;: &quot;notify_on_release&quot;,<br>
&gt;                                     &quot;value&quot;: &quot;0&quot;<br>
&gt;                                 }<br>
&gt;                             ]<br>
&gt;                         }<br>
&gt;                     ]<br>
&gt;                 },<br>
&gt;                 {<br>
&gt;                     &quot;cnames&quot;: [<br>
&gt;                         &quot;perf_event&quot;<br>
&gt;                     ],<br>
&gt;                     &quot;dirs&quot;: [<br>
&gt;                         {<br>
&gt;                             &quot;dir_name&quot;: &quot;&quot;<br>
&gt;                         }<br>
&gt;                     ]<br>
&gt;                 },<br>
&gt;                 {<br>
&gt;                     &quot;cnames&quot;: [<br>
&gt;                         &quot;hugetlb&quot;<br>
&gt;                     ],<br>
&gt;                     &quot;dirs&quot;: [<br>
&gt;                         {<br>
&gt;                             &quot;dir_name&quot;: &quot;&quot;<br>
&gt;                         }<br>
&gt;                     ]<br>
&gt;                 },<br>
&gt;                 {<br>
&gt;                     &quot;cnames&quot;: [<br>
&gt;                         &quot;name=systemd&quot;<br>
&gt;                     ],<br>
&gt;                     &quot;dirs&quot;: [<br>
&gt;                         {<br>
&gt;                             &quot;dir_name&quot;: &quot;&quot;<br>
&gt;                         }<br>
&gt;                     ]<br>
&gt;                 }<br>
&gt;             ]<br>
&gt;         }<br>
&gt;     ]<br>
&gt; }<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; With &quot;full&quot; mode, the top &quot;cpu&quot; and &quot;mem&quot;<br>
&gt;&gt;&gt; directories should be skipped. The first condition<br>
&gt;&gt;&gt; (strcmp(e-&gt;dir_name, &quot;&quot;) guarantees that non-root directory will be<br>
&gt;&gt;&gt; restored. For a dumped process with cgroup tree &quot;cpuset/foo/foo1&quot;. The<br>
&gt;&gt;&gt; restore process with &quot;full&quot; mode is like<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; (00.046731) cg: Restored cgroup property value 1 to cpuset/foo/foo1/cpuset.cpus<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; (00.046803) cg: Restored cgroup property value 0 to cpuset/foo/foo1/cpuset.mems<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ... (after all foo1 properties are restore, the it moves to the top level)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; (00.047287) cg: ---&gt; Skip Empty name for top path cpu , top dir<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; As you can see, the patch will only skip those root directories.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; One side observations is that the property values of the intermediate<br>
&gt;&gt;&gt; level (e.g., cpuset/foo) is not dumpped. I confirmed this by running<br>
&gt;&gt;&gt; crit decode -i cgroup.img --pretty. So when restoring, I have to<br>
&gt;&gt;&gt; manually create cpuset/foo and populate the value. Is this a bug of<br>
&gt;&gt;&gt; CRIU?<br>
&gt;&gt;<br>
&gt;&gt; CRIU only messes with the cgroups tasks live in, so if they don&#39;t live<br>
&gt;&gt; in foo/ then foo will not be restored. And now it seems strange to me<br>
&gt;&gt; that the root one is being restored by criu.<br>
&gt;<br>
&gt; When you use &quot;--mange-cgroup=full&quot;, criu will try to restore<br>
&gt; /sys/fs/cgroup/cpusets/cpuset.cpus, which is not supposed to be<br>
&gt; written.<br>
&gt; But this will not happen with the default &quot;soft&quot; mode; the code sets<br>
&gt; n_properties = 0.<br>
&gt;<br>
&gt; if (opts.manage_cgroups &amp; (CG_MODE_SOFT | CG_MODE_NONE)) {<br>
&gt;                                 pr_info(&quot;Skip restoring properties on<br>
&gt; cgroup dir %s\n&quot;, paux);<br>
&gt; if (e-&gt;n_properties &gt; 0) {<br>
&gt;                                         xfree(e-&gt;properties);<br>
&gt;                                         e-&gt;properties = NULL;<br>
&gt;                                         e-&gt;n_properties = 0;<br>
&gt;                                 }<br>
&gt;                         }<br>
&gt;<br>
&gt; - Hui<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; -- Pavel<br>
&gt;&gt;<br>
</div></div>&gt; .<br>
&gt;<br>
<br>
</blockquote></div><br></div></div>