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 v2] controllers/memcg: Add testcase for kmem_limit_in_bytes of memory cgroup
Date: Wed, 14 Apr 2021 09:04:19 +0100	[thread overview]
Message-ID: <87im4p2sxo.fsf@suse.de> (raw)
In-Reply-To: <F3D3F6AC3820BB4C9FCA340DB5C32CB4038B507A@dggeml531-mbx.china.huawei.com>

Hello,

zhaogongyi <zhaogongyi@huawei.com> writes:

> Hi Richard,
>
> Thanks so much for your review!
>
>> >> > +	pid = SAFE_FORK();
>> >> > +	if (!pid) {
>> >> > +		SAFE_SETPGID(0, 0);
>> >> > +
>> >> > +		SAFE_FILE_PRINTF(KMEM_LIMIT_IN_BYTES, "%d", 0);
>> >> > +
>> >> > +		SAFE_FILE_PRINTF(CGROUP_PROCS, "%d", getpgid(getpid()));
>> >>
>> >> After setting this we should avoid doing any work in this process
>> >> except calling fork. AFAIK there is no guarantee that some other
>> >> syscall or tasklet etc. Won't try to allocate memory and also fail.
>> >>
>> >
>> > It seems that we would not be afraid since there is no asynchronous
>> > operation in the test process.
>> 
>> IIRC one of the problems with tasklets is they can run in any process. Also,
>> in theory stdout can point to anything. So write() might allocate memory.
>> 
>> Why not do something like:
>> 
>> SAFE_FILE_PRINTF(CGROUP_PROCS, "%d", getpgid(getpid())); errno = 0;
>> fork(); exit(errno);
>> 
>> Then check that errno == ENOMEM, in the parent process?
>>
>>
>>> > +		TEST(fork());
>>> > +		if (TST_RET == -1) {
>>> > +			if (TST_ERR == ENOMEM)
>>> > +				tst_res(TPASS, "fork fail as expected");
>>> > +			else
>>> > +				tst_brk(TFAIL | TTERRNO,
>>> > +					"fork fail as unexpected");
>
> As far as my personal understanding, after setpgid, the controlled process is the sub process whose process id is pid, excluded from the parent process, and the functions tst_res or tst_brk
> Is executed in its parent process.

setpgid(0, 0) sets the process group id (pgid) to be the same as the
(pid), which creates a new process group. This probably has the effect
that the calling process will not recieve signals from the
terminal. Also it should receive SIGTTOU when calling tst_res and
tst_brk, if stdout/stderr point to a terminal with the right
configuration.

AFAICT process groups are for shells and affect where signals are
sent. Nothing else.

>
> In this case, is it no affection to this test?
>
>
> Best Regards,
> Gongyi


-- 
Thank you,
Richard.

  reply	other threads:[~2021-04-14  8:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-14  6:40 [LTP] [PATCH v2] controllers/memcg: Add testcase for kmem_limit_in_bytes of memory cgroup zhaogongyi
2021-04-14  8:04 ` Richard Palethorpe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-04-15  3:30 zhaogongyi
2021-04-14 12:18 zhaogongyi
2021-04-14 13:31 ` Richard Palethorpe
2021-04-14 13:32 ` Cyril Hrubis
2021-04-14  8:19 zhaogongyi
2021-04-14 10:00 ` Richard Palethorpe
2021-04-13 12:29 zhaogongyi
2021-04-13 13:50 ` Richard Palethorpe
2021-04-12  8:44 Zhao Gongyi
2021-04-12 16:01 ` 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=87im4p2sxo.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