DPDK patches and discussions
 help / color / mirror / Atom feed
From: Harman Kalra <hkalra@marvell.com>
To: "zhichaox.zeng@intel.com" <zhichaox.zeng@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"qiming.yang@intel.com" <qiming.yang@intel.com>
Subject: RE: [EXT] [DPDK] eal/linux: fix segfaults due to thread exit order
Date: Tue, 17 May 2022 15:25:23 +0000	[thread overview]
Message-ID: <BN9PR18MB4204EDF148BD6A3FAB404F2CC5CE9@BN9PR18MB4204.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20220517160444.413819-1-zhichaox.zeng@intel.com>

Hi Zhichao,

Can you please add the same API for freebsd also.

Thanks
Harman

> -----Original Message-----
> From: zhichaox.zeng@intel.com <zhichaox.zeng@intel.com>
> Sent: Tuesday, May 17, 2022 9:35 PM
> To: dev@dpdk.org; qiming.yang@intel.com
> Cc: Zhichao Zeng <zhichaox.zeng@intel.com>; Harman Kalra
> <hkalra@marvell.com>
> Subject: [EXT] [DPDK] eal/linux: fix segfaults due to thread exit order
> 
> External Email
> 
> ----------------------------------------------------------------------
> From: Zhichao Zeng <zhichaox.zeng@intel.com>
> 
> The eal-intr-thread is not closed before exiting the main thread. There is a
> small probability that when the eal-intr-thread is about to use some pointers,
> the pointers were just released in the process of exiting, which cause the
> segment fault error caught by ASan.
> 
> Close the eal-intr-thread before exiting the mian thread to avoid segment
> fault.
> 
> Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
> ---
>  lib/eal/common/eal_private.h   |  7 +++++++
>  lib/eal/linux/eal.c            |  1 +
>  lib/eal/linux/eal_interrupts.c | 12 ++++++++++++
>  3 files changed, 20 insertions(+)
> 
> diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
> index 44d14241f0..7adf41b7d7 100644
> --- a/lib/eal/common/eal_private.h
> +++ b/lib/eal/common/eal_private.h
> @@ -152,6 +152,13 @@ int rte_eal_tailqs_init(void);
>   */
>  int rte_eal_intr_init(void);
> 
> +/**
> + * Destroy interrupt handling thread.
> + *
> + * This function is private to EAL.
> + */
> +void rte_eal_intr_destroy(void);
> +
>  /**
>   * Close the default log stream
>   *
> diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index
> 1ef263434a..b310681acf 100644
> --- a/lib/eal/linux/eal.c
> +++ b/lib/eal/linux/eal.c
> @@ -1266,6 +1266,7 @@ rte_eal_cleanup(void)
>  	vfio_mp_sync_cleanup();
>  #endif
>  	rte_mp_channel_cleanup();
> +	rte_eal_intr_destroy();
>  	/* after this point, any DPDK pointers will become dangling */
>  	rte_eal_memory_detach();
>  	eal_mp_dev_hotplug_cleanup();
> diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
> index d52ec8eb4c..b246b87273 100644
> --- a/lib/eal/linux/eal_interrupts.c
> +++ b/lib/eal/linux/eal_interrupts.c
> @@ -1199,6 +1199,18 @@ rte_eal_intr_init(void)
>  	return ret;
>  }
> 
> +void
> +rte_eal_intr_destroy(void)
> +{
> +	/* cancel the host thread */
> +	pthread_cancel(intr_thread);
> +	pthread_join(intr_thread, NULL);
> +
> +	/* close the pipe used by epoll */
> +	close(intr_pipe.writefd);
> +	close(intr_pipe.readfd);
> +}
> +
>  static void
>  eal_intr_proc_rxtx_intr(int fd, const struct rte_intr_handle *intr_handle)  {
> --
> 2.25.1


  parent reply	other threads:[~2022-05-17 15:25 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-17 16:04 zhichaox.zeng
2022-05-17  8:29 ` Morten Brørup
2022-05-17 15:25 ` Harman Kalra [this message]
2022-05-18 14:39 ` [DPDK v2] lib/eal: " zhichaox.zeng
2022-05-23 11:16 ` [PATCH " zhichaox.zeng
2022-05-23 12:10   ` David Marchand
2022-05-23 13:00     ` David Marchand
2022-05-30 13:47   ` [PATCH v3] " zhichaox.zeng
2022-05-30 16:26     ` Stephen Hemminger
2022-05-30 16:28     ` Stephen Hemminger
2022-06-02  8:21       ` Zeng, ZhichaoX
2022-06-07 10:14     ` Zeng, ZhichaoX
2022-06-15  6:01     ` [PATCH v4] " zhichaox.zeng
2022-06-24  1:42       ` Zeng, ZhichaoX
2022-06-24  7:50         ` David Marchand
2022-06-30 10:38         ` Zeng, ZhichaoX
2022-06-30 12:24       ` Bruce Richardson
2022-09-06  2:51       ` [PATCH v5] lib/eal: fix segfaults in exiting Zhichao Zeng
2022-09-06 15:03         ` Stephen Hemminger
2022-09-07  8:53           ` Zeng, ZhichaoX
2022-10-11  5:25         ` [PATCH v6] " Zhichao Zeng
2022-10-11 14:04           ` Stephen Hemminger
2022-10-19  1:51             ` Zeng, ZhichaoX

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=BN9PR18MB4204EDF148BD6A3FAB404F2CC5CE9@BN9PR18MB4204.namprd18.prod.outlook.com \
    --to=hkalra@marvell.com \
    --cc=dev@dpdk.org \
    --cc=qiming.yang@intel.com \
    --cc=zhichaox.zeng@intel.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;
as well as URLs for NNTP newsgroup(s).