[CRIU] [PATCH 1/2] cg: Add ability to dump custom cgroup properties
Cyrill Gorcunov
gorcunov at gmail.com
Thu Apr 28 08:09:27 PDT 2016
On Thu, Apr 28, 2016 at 09:04:18AM -0600, Tycho Andersen wrote:
> On Wed, Apr 27, 2016 at 10:17:48PM +0300, Cyrill Gorcunov wrote:
> >
> > +static int cgp_merge_props(cgp_list_entry_t *t)
> > +{
> > + cgp_list_entry_t *p, *n;
> > + size_t nr_props, i, j;
> > +
> > + /* FIXME This is O^2, optimize! */
> > + list_for_each_entry_safe(p, n, &cgp_predefined_list, list) {
> > + if (strcmp(t->cgp.name, p->cgp.name))
> > + continue;
> > +
> > + pr_debug("Merging \'%s\' controller props\n", t->cgp.name);
> > +
> > + nr_props = t->cgp.nr_props + p->cgp.nr_props;
> > +
> > + if (xrealloc_safe(&t->cgp.props, nr_props * sizeof(char *)))
> > + return -ENOMEM;
> > +
> > + for (i = t->cgp.nr_props, j = 0; i < nr_props; i++, j++) {
> > + t->cgp.props[i] = xstrdup(p->cgp.props[j]);
> > + if (!t->cgp.props[i])
> > + return -ENOMEM;
> > + t->cgp.nr_props++;
> > + }
>
> here it might make sense to dedup so that we don't save a predefined
> property twice if the user supplies it as well, but it's a minor
> point.
>
> Acked-by: Tycho Andersen <tycho.andersen at canonical.com>
Thanks!
There are ways to optimize ;)
Cyrill
More information about the CRIU
mailing list