public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 6/6] sched/cgroup: Add cfs_bandwidth01
Date: Fri, 21 May 2021 10:29:29 +0100	[thread overview]
Message-ID: <87y2c8juyu.fsf@suse.de> (raw)
In-Reply-To: <871ra1lrf3.fsf@suse.de>

Hello,

>>> +
>>> +static void cleanup(void)
>>> +{
>>> +	size_t i;
>>> +
>>> +	for (i = 0; i < ARRAY_SIZE(cg_workers); i++) {
>>> +		if (cg_workers[i])
>>> +			cg_workers[i] = tst_cgroup_group_rm(cg_workers[i]);
>>> +	}
>>> +
>>> +	if (cg_level3a)
>>> +		cg_level3a = tst_cgroup_group_rm(cg_level3a);
>>> +	if (cg_level3b)
>>> +		cg_level3b = tst_cgroup_group_rm(cg_level3b);
>>> +	if (cg_level2)
>>> +		cg_level2 = tst_cgroup_group_rm(cg_level2);
>>
>> Hmm, I wonder if we can move this part of the cleanup to the test
>> library as well. If we add all cgroups the user has created into a FIFO
>> linked list then this could be implemented as a single loop in the
>> tst_cgroup_clean().
>>
>> We would have to loop over the list in the tst_cgroup_group_rm() in
>> order to remove the about to be removed group from the list as well, but
>> I guess that this is still worth the trouble.
>
> This sounds good. We probably need to check if the groups have processes
> in them to print a nice error message. My main concern with automatic
> cleanup is confusing errors from deep in the lib.
>

I think maybe this API makes a fundamental mistake of mixing memory/object
management with actual creation and deletion of CGroups. OTOH that is
not really clear either.

But if a child process starts deleting CGroups, which might be a
reasonable thing to do, then we will get a mismatch between child and
parent. Then the cleanup will be wrong.

Also any kind of linked list or array implementation uses more lines of
code than the cleanup function and more complex for sure... even if we
have 10 test cases like this is it really work saving a few lines in
each case?

I don't know. But I think we need to see a few more cases.

-- 
Thank you,
Richard.

  reply	other threads:[~2021-05-21  9:29 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-13 15:21 [LTP] [PATCH 0/6] cfs_bandwidth01 and CGroup API Richard Palethorpe
2021-05-13 15:21 ` [LTP] [PATCH 1/6] API/cgroups: Allow fetching of CGroup name Richard Palethorpe
2021-05-19 11:14   ` Cyril Hrubis
2021-05-13 15:21 ` [LTP] [PATCH 2/6] API/cgroups: Remove obsolete function in API Richard Palethorpe
2021-05-19 11:15   ` Cyril Hrubis
2021-05-13 15:21 ` [LTP] [PATCH 3/6] API/cgroups: Check for unknown controller name Richard Palethorpe
2021-05-19 11:20   ` Cyril Hrubis
2021-05-20  8:13     ` Richard Palethorpe
2021-05-13 15:21 ` [LTP] [PATCH 4/6] API/cgroups: Add cpu controller Richard Palethorpe
2021-05-19 11:30   ` Cyril Hrubis
2021-05-20  8:35     ` Richard Palethorpe
2021-05-13 15:21 ` [LTP] [PATCH 5/6] API/cgroups: Auto add controllers to subtree_control in new subgroup Richard Palethorpe
2021-05-19 11:41   ` Cyril Hrubis
2021-05-20  8:40     ` Richard Palethorpe
2021-05-13 15:21 ` [LTP] [PATCH 6/6] sched/cgroup: Add cfs_bandwidth01 Richard Palethorpe
2021-05-19 11:51   ` Cyril Hrubis
2021-05-20  8:10     ` Cyril Hrubis
2021-05-20  8:50     ` Richard Palethorpe
2021-05-21  9:29       ` Richard Palethorpe [this message]
2021-05-25  9:06         ` Cyril Hrubis

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=87y2c8juyu.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