Linux Test Project
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 3/7] Add new CGroups APIs
Date: Mon, 26 Apr 2021 17:01:53 +0100	[thread overview]
Message-ID: <87lf95m3v2.fsf@suse.de> (raw)
In-Reply-To: <CAEemH2fmw0_HuetkiFTnyQGsa0HiD3vsUH-oD9XTTMsynOzn+g@mail.gmail.com>

Hello,

Li Wang <liwang@redhat.com> writes:

>  Hi Richard,
>
> Thanks for your work, the whole design looks good.
>
> Minor suggestions as below:
>
>
>> +static const char *ltp_cgroup_dir = "ltp";
>> +static const char *ltp_cgroup_drain_dir = "drain";
>> +static char test_cgroup_dir[PATH_MAX/4];
>> +static const char *ltp_mount_prefix = "/tmp/cgroup_";
>> +static const char *ltp_v2_mount = "unified";
>> +
>> +#define first_root                             \
>> +       (roots[0].ver ? roots : roots + 1)
>> +#define for_each_root(r)                       \
>> +       for ((r) = first_root; (r)->ver; (r)++)
>> +#define for_each_v1_root(r)                    \
>> +       for ((r) = roots + 1; (r)->ver; (r)++)
>>
>
> If you go through the whole files you will find, there are some places use
> 'r' to represent the root but other uses 't', even in functions that
> include ?t?
> to represent a tree.
>
> That probably a minor issue to make people get lost:).
>
> So I'd suggest a unified abbreviation in all:
>
> r  --> root
> t  --> tree
>
> if a function has root and tree, plz avoid using abbreviations, just use
> itself.

Yes, I should do something about this naming. I think this is related to
other issues Cyril mentioned in the naming of tree items.

>
>
>
>> +#define for_each_css(css)                      \
>> +       for ((css) = items + 1; (css)->name; (css)++)
>> +
>> +/* Controller items may only be in a single tree. So when (ss) > 0
>> + * we only loop once.
>> + */
>> +#define for_each_tree(cg, css, t)                                      \
>> +       for ((t) = (css) ? (cg)->trees_by_css + (css) : (cg)->trees;    \
>> +            *(t);                                                      \
>> +            (t) = (css) ? (cg)->trees + TST_CGROUP_MAX_TREES : (t) + 1)
>> +
>> +static int has_css(uint32_t css_field, enum tst_cgroup_css type)
>> +{
>> +       return !!(css_field & (1 << type));
>>  }
>>
>>
>
>
>> +struct tst_cgroup *tst_cgroup_mk(const struct tst_cgroup *parent,
>> +                                const char *name)
>>  {
>>
>
> Since we have already got the parent tst_cgroup, it means we know which
> controllers/type has been mounted.
>
> Can we add the required controllers (e.g. "+memory")  to subtree_control
> automatically at here, rather than doing it manually before creating
> children?
> (then we can remove the line#27~30 in tst_cgroup02.c)

It is possible and more consistent with V1 behavior. I suppose users
could remove controllers again if they wanted to test some V2 specific
configuration.

OTOH we could leave this for a later patch when we actually have some
real tests containing child groups? I'm not fully sure what the results
of doing this are and we may just have to reverse it.

-- 
Thank you,
Richard.

  reply	other threads:[~2021-04-26 16:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 14:54 [LTP] [PATCH v3 0/7] CGroup API rewrite Richard Palethorpe
2021-04-12 14:55 ` [LTP] [PATCH v3 1/7] API: Add safe openat, printfat, readat and unlinkat Richard Palethorpe
2021-04-16  6:59   ` Li Wang
2021-04-26 15:07     ` Richard Palethorpe
2021-04-12 14:55 ` [LTP] [PATCH v3 2/7] API: Add macro for the container_of trick Richard Palethorpe
2021-04-16  7:01   ` Li Wang
2021-04-26 15:15     ` Richard Palethorpe
2021-04-27 11:03       ` Cyril Hrubis
2021-04-12 14:55 ` [LTP] [PATCH v3 3/7] Add new CGroups APIs Richard Palethorpe
2021-04-14 15:39   ` Cyril Hrubis
2021-04-15 13:10     ` Richard Palethorpe
2021-04-16  5:00       ` Li Wang
2021-04-26 16:39         ` Richard Palethorpe
2021-04-16  6:57   ` Li Wang
2021-04-26 16:01     ` Richard Palethorpe [this message]
2021-04-12 14:55 ` [LTP] [PATCH v3 4/7] Add new CGroups API library tests Richard Palethorpe
2021-04-16  7:22   ` Li Wang
2021-04-12 14:55 ` [LTP] [PATCH v3 5/7] docs: Update CGroups API Richard Palethorpe
2021-04-16  8:11   ` Li Wang
2021-04-26 16:44     ` Richard Palethorpe
2021-04-12 14:55 ` [LTP] [PATCH v3 6/7] mem: Convert tests to new " Richard Palethorpe
2021-04-12 14:55 ` [LTP] [PATCH v3 7/7] madvise06: Convert " Richard Palethorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lf95m3v2.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox