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

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.

-- 
Cyril Hrubis
chrubis@suse.cz

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

  reply	other threads:[~2023-02-14 15:08 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 [this message]
2023-02-16  5:40             ` Leo Liang
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+ukQAh4GMXh1TiK@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=ycliang@andestech.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