DPDK patches and discussions
 help / color / mirror / Atom feed
* test_debug: calling rte_exit() in a forked child
@ 2021-11-13 17:29 Stephen Hemminger
  0 siblings, 0 replies; only message in thread
From: Stephen Hemminger @ 2021-11-13 17:29 UTC (permalink / raw)
  To: dev

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?


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-13 17:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-13 17:29 test_debug: calling rte_exit() in a forked child Stephen Hemminger

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).