All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 1/2] lib: initialize lib|main_pid to zero in the setup_ipc
Date: Tue, 13 May 2025 14:51:48 +0200	[thread overview]
Message-ID: <20250513125148.GA244619@pevik> (raw)
In-Reply-To: <aCM2PrCrCdPqNIGc@yuki.lan>

Hi all,

...
> > +++ b/lib/tst_test.c
> > @@ -59,7 +59,6 @@ static const char *tid;
> >  static int iterations = 1;
> >  static float duration = -1;
> >  static float timeout_mul = -1;
> > -static pid_t lib_pid;
> >  static int mntpoint_mounted;
> >  static int ovl_mounted;
> >  static struct timespec tst_start_time; /* valid only for test pid */
> > @@ -143,7 +142,9 @@ static void setup_ipc(void)
> >  		tst_futexes = (char *)results + sizeof(struct results);
> >  		tst_max_futexes = (size - sizeof(struct results))/sizeof(futex_t);
> >  	}
> > -	results->lib_pid = lib_pid;
> > +
> > +	results->lib_pid = 0;
> > +	results->main_pid = 0;

nit: Is it really needed to int them to 0? Because they should be 0 due the
default struct value, right?

> >  }

> >  static void cleanup_ipc(void)
> > @@ -394,7 +395,7 @@ void tst_vbrk_(const char *file, const int lineno, int ttype, const char *fmt,
> >  	 * If tst_brk() is called from some of the C helpers even before the
> >  	 * library was initialized, just exit.
> >  	 */
> > -	if (!results->lib_pid)
> > +	if (!results || !results->lib_pid)
> >  		exit(TTYPE_RESULT(ttype));

> >  	update_results(TTYPE_RESULT(ttype));
> > @@ -1334,6 +1335,8 @@ static void do_setup(int argc, char *argv[])
> >  		tst_test->forks_child = 1;
> >  	}

> > +	setup_ipc();
> > +
> >  	if (tst_test->needs_kconfigs && tst_kconfig_check(tst_test->needs_kconfigs))
> >  		tst_brk(TCONF, "Aborting due to unsuitable kernel config, see above!");

> > @@ -1393,8 +1396,6 @@ static void do_setup(int argc, char *argv[])
> >  	if (tst_test->hugepages.number)
> >  		tst_reserve_hugepages(&tst_test->hugepages);

> > -	setup_ipc();
> > -

> I suppose that this has to go before the tst_reserve_hugepages() so that
> we have results->lib_pid defined and properly clean up after the
> hugepages.

Why? Is that due possible tst_brk() calls in tst_reserve_hugepages()?
(Which uses SAFE_* macros.) That would trigger Because there are tst_brk() calls before.

Also why not assign results->lib_pid = getpid() at the beginning of
tst_run_tcases() ?

Kind regards,
Petr

> However for that to work we have to set the
> results->lib_pid directly in the setup_ipc().

> >  	if (tst_test->bufs)
> >  		tst_buffers_alloc(tst_test->bufs);

> > @@ -1929,10 +1930,11 @@ void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
> >  	unsigned int test_variants = 1;
> >  	struct utsname uval;

> > -	lib_pid = getpid();
> >  	tst_test = self;

> >  	do_setup(argc, argv);
> > +
> > +	results->lib_pid = getpid();

> Setting it here is too late.

> Other than that the patch looks good to me.

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

  parent reply	other threads:[~2025-05-13 12:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-13  5:05 [LTP] [PATCH 1/2] lib: initialize lib|main_pid to zero in the setup_ipc Li Wang via ltp
2025-05-13  5:05 ` [LTP] [PATCH 2/2] dirtyc0w_shmem: set child_needs_reinit Li Wang via ltp
2025-05-13 20:31   ` Wei Gao via ltp
2025-05-13  9:33     ` Li Wang via ltp
2025-05-13 12:09       ` Cyril Hrubis
2025-05-13 12:08 ` [LTP] [PATCH 1/2] lib: initialize lib|main_pid to zero in the setup_ipc Cyril Hrubis
2025-05-13 12:42   ` Li Wang via ltp
2025-05-14  8:00     ` Cyril Hrubis
2025-05-14  8:18       ` Li Wang via ltp
2025-05-14  8:23         ` Cyril Hrubis
2025-05-13 12:51   ` Petr Vorel [this message]
2025-05-13 13:02     ` Li Wang via ltp
2025-05-13 13:06       ` Li Wang via ltp
2025-05-13 15:41         ` Petr Vorel
2025-05-14  1:14           ` Li Wang via ltp

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=20250513125148.GA244619@pevik \
    --to=pvorel@suse.cz \
    --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.