public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jiri Vohanka <jvohanka@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] mtest01 parent/child process synchronization issue
Date: Wed, 25 Nov 2015 11:47:36 +0100	[thread overview]
Message-ID: <565591C8.7060308@redhat.com> (raw)
In-Reply-To: <5652E62A.3090403@redhat.com>

Hi,

>> diff --git a/testcases/kernel/mem/mtest01/mtest01.c b/testcases/kernel/mem/mtest01/mtest01.c
>> index 8c9e81c..06f41d5 100644
>> --- a/testcases/kernel/mem/mtest01/mtest01.c
>> +++ b/testcases/kernel/mem/mtest01/mtest01.c

>> @@ -51,9 +51,12 @@
>>   char *TCID = "mtest01";
>>   int TST_TOTAL = 1;
>>   int pid_count = 0;
>> +int oom_count = 0;
>
> both of these should be static

You are right, I also added volatile just to be sure.

>> @@ -284,7 +288,9 @@ int main(int argc, char *argv[])
>>   			kill(pid_list[i], SIGKILL);
>>   			i++;
>>   		}
>> -		if (dowrite)
>> +		if (oom_count)
>> +			tst_resm(TFAIL, "the child process was killed");
>
> I wouldn't combine two "if"s into one if else block, the information how
> much was allocated could be useful even when we hit OOM.

The original_maxbytes tells us how much we want to allocate, not how much was already allocated. You have to watch TINFO messages emitted by 
child processes to see what was actually allocated. I think that printing ""%llu kbytes allocated" would be misleading since that is true only 
if the test passes. I kept the if statement at its current place, but I made the fail message more verbose.

> But mainly, problem here is that ~6 lines above child processes get killed,
> so you are racing with SIGCHLD here. I'd suggest to move this TFAIL before
> kill() loop.

I moved the part that kills the child processes after PASS/FAIL evaluation to avoid possible race condition.
(Another option would be to uninstall the SIGCHLD signal handler before killing the processes.)

>> +		else if (dowrite)
>>   			tst_resm(TPASS, "%llu kbytes allocated and used.",
>>   				 original_maxbytes / 1024);
>>   		else

I am new to the list and I am not sure what the rules for posting patches are. Should I use 'git send-email', sign the patch or something?

Regards,
Jiri
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Watch-for-SIGCHLD-in-mtest01-in-case-the-child-gets-.patch
Type: text/x-patch
Size: 2887 bytes
Desc: not available
URL: <http://lists.linux.it/pipermail/ltp/attachments/20151125/77c5390d/attachment.bin>

  reply	other threads:[~2015-11-25 10:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18 16:51 [LTP] mtest01 parent/child process synchronization issue Jiri Vohanka
2015-11-23 10:10 ` Jan Stancek
2015-11-25 10:47   ` Jiri Vohanka [this message]
2015-11-26 14:38     ` Jan Stancek
2015-11-26 14:50     ` 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=565591C8.7060308@redhat.com \
    --to=jvohanka@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