From: Leo Liang <ycliang@andestech.com>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 1/1] tst_pids.c: fix fork failure on small memory systems
Date: Thu, 9 Feb 2023 13:36:36 +0000 [thread overview]
Message-ID: <Y+T25EqnoMz60ESf@ubuntu01> (raw)
In-Reply-To: <Y+Tvqit/PmTn8Da5@yuki>
Hi Cyril,
On Thu, Feb 09, 2023 at 02:05:46PM +0100, Cyril Hrubis wrote:
> Hi!
> > lib/tst_pid.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/tst_pid.c b/lib/tst_pid.c
> > index 21cadef2a..3fb3f39ad 100644
> > --- a/lib/tst_pid.c
> > +++ b/lib/tst_pid.c
> > @@ -31,6 +31,7 @@
> > #include "tst_safe_macros.h"
> >
> > #define PID_MAX_PATH "/proc/sys/kernel/pid_max"
> > +#define THREADS_MAX_PATH "/proc/sys/kernel/threads-max"
> > #define CGROUPS_V1_SLICE_FMT "/sys/fs/cgroup/pids/user.slice/user-%d.slice/pids.max"
> > #define CGROUPS_V2_SLICE_FMT "/sys/fs/cgroup/user.slice/user-%d.slice/pids.max"
> > /* Leave some available processes for the OS */
> > @@ -113,7 +114,7 @@ static int get_session_pids_limit(void (*cleanup_fn) (void))
> > int tst_get_free_pids_(void (*cleanup_fn) (void))
> > {
> > FILE *f;
> > - int rc, used_pids, max_pids, max_session_pids;
> > + int rc, used_pids, max_pids, max_session_pids, max_threads;
> >
> > f = popen("ps -eT | wc -l", "r");
> > if (!f) {
> > @@ -129,6 +130,8 @@ int tst_get_free_pids_(void (*cleanup_fn) (void))
> > }
> >
> > SAFE_FILE_SCANF(cleanup_fn, PID_MAX_PATH, "%d", &max_pids);
> > + SAFE_FILE_SCANF(cleanup_fn, THREADS_MAX_PATH, "%d", &max_threads);
> > + max_pids = (max_pids < max_threads) ? max_pids : max_threads;
>
> BTW: We do have a MIN() macro definition in tst_minmax.h header so we
> can just do max_pids = MIN(max_pids, max_threads);
>
Thanks for the review!
Will send a v2 to fix this!
Best regards,
Leo
> > max_session_pids = get_session_pids_limit(cleanup_fn);
> > if ((max_session_pids > 0) && (max_session_pids < max_pids))
>
> Otherwise:
>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
>
> --
> Cyril Hrubis
> chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2023-02-09 13:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 12:40 [LTP] [PATCH 1/1] tst_pids.c: fix fork failure on small memory systems Leo Yu-Chi Liang
2023-02-07 13:42 ` Petr Vorel
2023-02-07 16:33 ` Jan Stancek
2023-02-09 13:35 ` Leo Liang
2023-02-09 13:49 ` Petr Vorel
2023-02-09 13:05 ` Cyril Hrubis
2023-02-09 13:36 ` Leo Liang [this message]
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+T25EqnoMz60ESf@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.