From: Richard Palethorpe <rpalethorpe@suse.de>
To: "xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com>
Cc: LTP List <ltp@lists.linux.it>
Subject: Re: [LTP] Do we have some simple way to get the current cgroup.procs path?
Date: Mon, 18 Jul 2022 10:33:20 +0100 [thread overview]
Message-ID: <87tu7eivrm.fsf@suse.de> (raw)
In-Reply-To: <8e16d91c-8307-8ea4-bde7-28ef093c1205@fujitsu.com>
Hello,
"xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com> writes:
> Hi Li
>> Hi Xu,
>>
>> On Thu, Jul 14, 2022 at 2:02 PM xuyang2018.jy@fujitsu.com
>> <mailto:xuyang2018.jy@fujitsu.com> <xuyang2018.jy@fujitsu.com
>> <mailto:xuyang2018.jy@fujitsu.com>> wrote:
>>
>> Hi Richard, LI
>>
>> I am writting a simple regression test[1]that refer to kernel
>> selftest cgroup test_core[2]. I may name it as memcontrol05.c.
>>
>> It tests cgroup migration permission check should be performed based
>> on the credentials at the time of open instead of write.
>>
>> I have used ltp cgroup framework, but ltp cgroup only use
>> SAFE_CGROUP_PRINTF to write value.
>>
>> How can get the cgroup root_dir ltp_dir path? So I can open this fd
>> and change/save effective uid between open and write?
>>
>> Not sure if I fully understand your requirements.
>> Can we achieve this test by creating a two-layer subdirectory?
>
> I think yes.
I think you must have multiple layers. Otherwise you could break other
tests running in parallel.
>
>>
>> Does only the root/ltp_dir mandatory for completing your test?
>
> It also need gettid subdirectory and cgroup name.
You could create an accessor function in the library to get dir_fd from
cgroup_dir.
This is complicated by V1 CGs where a tst_cg_group can have multiple
struct cgroup_dir's. This isn't a problem for selftests because they
only support V2, but it would be nice to make as many tests as possible
work with V1.
The easiest solution I can think of is to write a library function like
SAFE_CG_GROUP_EACH_DIR(void (*const fn_ptr)(int dir_fd)) which takes a
const function pointer and executes it with the FD of each
directory. Then you can use the internal for_each_dir macro like
SAFE_CGROUP_PRINTF.
>> If yes, I think tst_cg_print_config() maybe fits your purpose,
>> but that would need additional function help extracting that.
>>
>> Take a reference to see how Luke gets the root path (in shell):
>> https://lists.linux.it/pipermail/ltp/2022-April/028772.html
>> <https://lists.linux.it/pipermail/ltp/2022-April/028772.html>
>
> Thanks, I prefer to use c api and will think about it continuely.
>
> Best Regards
> Yang Xu
>>
>>
>> --
>> Regards,
>> Li Wang
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-07-18 10:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-14 6:00 [LTP] Do we have some simple way to get the current cgroup.procs path? xuyang2018.jy
2022-07-14 10:24 ` Li Wang
2022-07-18 7:35 ` xuyang2018.jy
2022-07-18 9:33 ` Richard Palethorpe [this message]
2022-07-21 0:59 ` xuyang2018.jy
2022-08-02 10:10 ` xuyang2018.jy
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=87tu7eivrm.fsf@suse.de \
--to=rpalethorpe@suse.de \
--cc=ltp@lists.linux.it \
--cc=xuyang2018.jy@fujitsu.com \
/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