From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 1/4] lib: add new cgroup test API
Date: Mon, 1 Jun 2020 09:57:11 -0400 (EDT) [thread overview]
Message-ID: <1365679659.14324910.1591019831545.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20200601100459.32511-1-liwang@redhat.com>
----- Original Message -----
> +
> +[source,c]
> +-------------------------------------------------------------------------------
> +#include "tst_test.h"
> +
> +static void run(void)
> +{
> + ...
> +
> + tst_cgroup_move_current(PATH_TMP_CG1_MEM);
> + tst_cgroup_mem_set_maxbytes(PATH_TMP_CG1_MEM, MEMSIZE);
Goal for API is to hide differences between cgroup 1/2, but example above
is passing cgroup specific directory.
My suggestion was to have directory parameter relative to cgroup mount,
I didn't consider there would be need for mounting cgroup more than once
from single process. Is there such need?
Since there's only one global 'tst_cgroup_mnt_path', is there need to have
paths absolute? If we assume that single process will mount cgroup only once,
then all paths could be relative to 'tst_cgroup_mnt_path', and test doesn't
need to even use 'tst_cgroup_mnt_path'.
> +
> +static void tst_cgroup_set_path(const char *cgroup_dir)
> +{
> + struct tst_cgroup_path *tst_cgroup_path, *a;
> +
> + if (!cgroup_dir)
> + tst_brk(TBROK, "Invalid cgroup dir, plese check cgroup_dir");
> +
> + sprintf(tst_cgroup_mnt_path, "%s", cgroup_dir);
> + sprintf(tst_cgroup_new_path, "%s/ltp_%d", cgroup_dir, rand());
> +
> + /* To store cgroup path in the shared 'path' list */
> + tst_cgroup_path = SAFE_MMAP(NULL, (sizeof(struct tst_cgroup_path)),
> + PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
I'm not sure I understand what is the reason to have tst_cgroup_path. Is it expected,
that mount and umount are called by different processes? It might be easier
to define API as per-process and require same process to call mount and umount.
> + tst_cgroup_path->mnt_path = SAFE_MALLOC(strlen(tst_cgroup_mnt_path));
> + tst_cgroup_path->new_path = SAFE_MALLOC(strlen(tst_cgroup_new_path));
Pointers are in shared memory, but content they point to is not, so it's accessible
only from process that called tst_cgroup_set_path().
Can you describe all different scenarios you wanted to support?
next prev parent reply other threads:[~2020-06-01 13:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-01 10:04 [LTP] [PATCH v2 1/4] lib: add new cgroup test API Li Wang
2020-06-01 10:04 ` [LTP] [PATCH v2 2/4] mem: take use of new cgroup API Li Wang
2020-06-01 10:04 ` [LTP] [PATCH v2 3/4] mem: remove the old " Li Wang
2020-06-01 10:04 ` [LTP] [PATCH v2 4/4] mm: add cpuset01 to runtest file Li Wang
2020-06-01 10:58 ` [LTP] [PATCH v2 1/4] lib: add new cgroup test API Li Wang
2020-06-01 13:57 ` Jan Stancek [this message]
2020-06-02 4:42 ` Li Wang
2020-06-02 12:12 ` Jan Stancek
2020-06-03 1:38 ` Li Wang
2020-06-03 10:43 ` Jan Stancek
2020-06-03 12:51 ` Li Wang
2020-06-05 10:14 ` Jan Stancek
2020-06-08 8:53 ` Li Wang
2020-06-08 9:48 ` Jan Stancek
2020-06-08 10:18 ` Li Wang
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=1365679659.14324910.1591019831545.JavaMail.zimbra@redhat.com \
--to=jstancek@redhat.com \
--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