DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Subject: test_debug: calling rte_exit() in a forked child
Date: Sat, 13 Nov 2021 09:29:15 -0800	[thread overview]
Message-ID: <20211113092915.225bbd3f@hermes.local> (raw)

This test looks bogus it is doing something that DPDK as a library
really shouldn't allow:


/* use fork() to test rte_exit() */
static int
test_exit_val(int exit_val)
{
	int pid;
	int status;

	/* manually cleanup EAL memory, as the fork() below would otherwise
	 * cause the same hugepages to be free()-ed multiple times.
	 */
	rte_service_finalize();

	pid = fork();

	if (pid == 0)
		rte_exit(exit_val, __func__);

The problem is that rte_exit in the child process will end up
calling rte_eal_cleanup(). But rte_eal_init was never called in
the forked process it just inherits the state in the child;
the service finalize comment hints at the problem.

Why does it matter?  Well if rte_eal_cleanup ends up trying
to do the right thing and cleanup the worker threads it will fail
because in the child process, those threads are not related (they
are threads in the parent not the child).

The question is does rte_exit() have to be allowed for the
case where rte_eal_init() never succeeded in that process
context? It looks like the eal_init() run_once flag should
also be checked int eal_cleanup() to avoid doing cleanup
if never initted?

Alternatively, rte_exit() could never call eal_cleanup?


                 reply	other threads:[~2021-11-13 17:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20211113092915.225bbd3f@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /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;
as well as URLs for NNTP newsgroup(s).