DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Tyler Retzlaff <roretzla@linux.microsoft.com>
Cc: <dev@dpdk.org>, <thomas@monjalon.net>
Subject: Re: [PATCH 1/6] dma/skeleton: use rte thread API
Date: Tue, 18 Apr 2023 10:19:15 +0100	[thread overview]
Message-ID: <ZD5gk3ltHuFjzKx6@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <1679092460-9930-2-git-send-email-roretzla@linux.microsoft.com>

On Fri, Mar 17, 2023 at 03:34:15PM -0700, Tyler Retzlaff wrote:
> Update driver to use rte thread API where available instead of pthread
> as a prerequisite to removing pthread stubs on Windows.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  drivers/dma/skeleton/skeleton_dmadev.c | 15 ++++++++-------
>  drivers/dma/skeleton/skeleton_dmadev.h |  4 ++--
>  2 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c
> index daf35ec..2ec10db 100644
> --- a/drivers/dma/skeleton/skeleton_dmadev.c
> +++ b/drivers/dma/skeleton/skeleton_dmadev.c
> @@ -5,6 +5,8 @@
>  #include <inttypes.h>
>  #include <stdlib.h>
>  
> +#include <pthread.h>
> +

Curious as to why this is needed here. Does rte_thread.h not include all
needed threading dependencies?
[Self-answer] I assume this is for pthread_cancel below, right?


>  #include <bus_vdev_driver.h>
>  #include <rte_cycles.h>
>  #include <rte_eal.h>
> @@ -53,7 +55,7 @@
>  	return 0;
>  }
>  
> -static void *
> +static uint32_t
>  cpucopy_thread(void *param)
>  {
>  #define SLEEP_THRESHOLD		10000
> @@ -81,7 +83,7 @@
>  		(void)rte_ring_enqueue(hw->desc_completed, (void *)desc);
>  	}
>  
> -	return NULL;
> +	return 0;
>  }
>  
>  static void
> @@ -126,7 +128,7 @@
>  	rte_mb();
>  
>  	snprintf(name, sizeof(name), "dma_skel_%d", dev->data->dev_id);
> -	ret = rte_ctrl_thread_create(&hw->thread, name, NULL,
> +	ret = rte_thread_create_control(&hw->thread, name, NULL,
>  				     cpucopy_thread, dev);
>  	if (ret) {
>  		SKELDMA_LOG(ERR, "Start cpucopy thread fail!");
> @@ -135,8 +137,7 @@
>  
>  	if (hw->lcore_id != -1) {
>  		cpuset = rte_lcore_cpuset(hw->lcore_id);
> -		ret = pthread_setaffinity_np(hw->thread, sizeof(cpuset),
> -					     &cpuset);
> +		ret = rte_thread_get_affinity_by_id(hw->thread, &cpuset);
>  		if (ret)
>  			SKELDMA_LOG(WARNING,
>  				"Set thread affinity lcore = %d fail!",
> @@ -154,8 +155,8 @@
>  	hw->exit_flag = true;
>  	rte_delay_ms(1);
>  
> -	(void)pthread_cancel(hw->thread);
> -	pthread_join(hw->thread, NULL);
> +	(void)pthread_cancel((pthread_t)hw->thread.opaque_id);
> +	rte_thread_join(hw->thread, NULL);
>  

Is there no rte_* equivalent to pthread_cancel? Will that cause issues
later?

>  	return 0;
>  }
> diff --git a/drivers/dma/skeleton/skeleton_dmadev.h b/drivers/dma/skeleton/skeleton_dmadev.h
> index 6f89400..8670a68 100644
> --- a/drivers/dma/skeleton/skeleton_dmadev.h
> +++ b/drivers/dma/skeleton/skeleton_dmadev.h
> @@ -5,9 +5,9 @@
>  #ifndef SKELETON_DMADEV_H
>  #define SKELETON_DMADEV_H
>  
> -#include <pthread.h>
>  
>  #include <rte_ring.h>
> +#include <rte_thread.h>
>  
>  #define SKELDMA_ARG_LCORE	"lcore"
>  
> @@ -21,7 +21,7 @@ struct skeldma_desc {
>  struct skeldma_hw {
>  	int lcore_id; /* cpucopy task affinity core */
>  	int socket_id;
> -	pthread_t thread; /* cpucopy task thread */
> +	rte_thread_t thread; /* cpucopy task thread */
>  	volatile int exit_flag; /* cpucopy task exit flag */
>  
>  	struct skeldma_desc *desc_mem;
> -- 
> 1.8.3.1
> 

  reply	other threads:[~2023-04-18  9:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 22:34 [PATCH 0/6] windows: remove most pthread lifetime shim functions Tyler Retzlaff
2023-03-17 22:34 ` [PATCH 1/6] dma/skeleton: use rte thread API Tyler Retzlaff
2023-04-18  9:19   ` Bruce Richardson [this message]
2023-04-18 15:04     ` Tyler Retzlaff
2023-03-17 22:34 ` [PATCH 2/6] net/ixgbe: " Tyler Retzlaff
2023-03-17 22:34 ` [PATCH 3/6] net/ice: " Tyler Retzlaff
2023-03-17 22:34 ` [PATCH 4/6] net/iavf: " Tyler Retzlaff
2023-03-17 22:34 ` [PATCH 5/6] eal: " Tyler Retzlaff
2023-03-17 22:34 ` [PATCH 6/6] windows: remove most pthread lifetime shim functions Tyler Retzlaff
2023-04-03  5:34 ` [PATCH 0/6] " Tyler Retzlaff
2023-04-18  9:21   ` Bruce Richardson
2023-06-01  8:49     ` David Marchand
2023-06-01 12:23       ` Zhang, Qi Z
2023-06-02 16:22         ` Tyler Retzlaff
2023-06-09 12:38           ` David Marchand
2023-04-17 16:46 ` Tyler Retzlaff
2023-06-09 12:39 ` David Marchand

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=ZD5gk3ltHuFjzKx6@bricha3-MOBL.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=roretzla@linux.microsoft.com \
    --cc=thomas@monjalon.net \
    /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).