public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Leo Liang <ycliang@andestech.com>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [v2 2/2] lib/tst_pid.c: Increase PIDS_RESERVED to avoid fork failure.
Date: Thu, 16 Feb 2023 05:40:39 +0000	[thread overview]
Message-ID: <Y+3B1yAqIMrivj1O@ubuntu01> (raw)
In-Reply-To: <Y+ukQAh4GMXh1TiK@yuki>

Hi Cyril,

On Tue, Feb 14, 2023 at 04:09:52PM +0100, Cyril Hrubis wrote:
> Hi!
> > > > > > After Adjusting how we count used pid, we increase
> > > > > > the number of PIDS_RESERVED to void fork failure.
> > > > > nit: in this case I'd actually keep changes in single commit
> > > > > (otherwise first commit alone would break tests),
> > > > 
> > > > Do we get a different result from ps and parsing /proc? That sounds
> > > > strange...
> > > 
> > > I think that's because "ps -eT" would list threads with the same PID
> > > but with different SPID.
> > > 
> > > I get the following output on my VM.
> > > 
> > > ycliang@ubuntu01:~$ ps -eT | wc -l
> > > 170
> > > ycliang@ubuntu01:~$ ls -d /proc/[0-9]* | xargs -n1 | wc -l
> > > 127
> > 
> > Adjusting the RESERVED constant is then a lousy workaround that wouldn't
> > work for systems with many threads per process.
> > 
> > One alternative would be to open /proc/$PID/status and read the number
> > of threads from there. Should be as easy as one call to
> > SAFE_FILE_LINES_SCANF().
> 
> Thinking of it again using SAFE_FILE_LINES_SCANF() may be prone to a
> race where the process exits and the file disappears between the call to
> the readdir() and the open in the SAFE_FILE_LINES_SCANF() so I suppose
> that we should use just the FILE_LINES_SCANF() instead and add the
> threads value only if the call succeeded.

Thanks for the advice!
Will send a v3.

Just out of curiosity, is there any reason that we should do this in plain C ?
(Otherwise, we could drop this patchset and stay with the current implementation)

Best regards,
Leo

> 
> -- 
> Cyril Hrubis
> chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2023-02-16  5:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14 12:25 [LTP] [v2 1/2] lib/tst_pid.c: Count used pid by traversing /proc Leo Yu-Chi Liang
2023-02-14 12:25 ` [LTP] [v2 2/2] lib/tst_pid.c: Increase PIDS_RESERVED to avoid fork failure Leo Yu-Chi Liang
2023-02-14 13:37   ` Petr Vorel
2023-02-14 13:43     ` Cyril Hrubis
2023-02-14 14:17       ` Leo Liang
2023-02-14 14:26         ` Cyril Hrubis
2023-02-14 15:09           ` Cyril Hrubis
2023-02-16  5:40             ` Leo Liang [this message]
2023-02-16  8:46               ` Cyril Hrubis
2023-02-16 14:52                 ` Leo Liang
2023-02-16 22:59                   ` Petr Vorel
2023-02-14 14:14     ` Leo Liang

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=Y+3B1yAqIMrivj1O@ubuntu01 \
    --to=ycliang@andestech.com \
    --cc=chrubis@suse.cz \
    --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