DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/failsafe: fix FreeBSD build
@ 2018-02-13 21:33 Thomas Monjalon
  2018-02-13 21:39 ` Thomas Monjalon
  2018-02-13 22:13 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Monjalon @ 2018-02-13 21:33 UTC (permalink / raw)
  To: matan; +Cc: dev, gaetan.rivet

The type pthread_t is not portable because it is freely defined.
On Linux, it is an unsigned long int which can be printed with %l.

The debug printing of the thread id is restricted to Linux only.

Fixes: 655fcd68c7d2 ("net/failsafe: fix hotplug races")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/net/failsafe/failsafe_private.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h
index 5b84db905..86ade029f 100644
--- a/drivers/net/failsafe/failsafe_private.h
+++ b/drivers/net/failsafe/failsafe_private.h
@@ -374,8 +374,10 @@ fs_lock(struct rte_eth_dev *dev, unsigned int is_alarm)
 			return ret;
 		}
 	}
+#ifdef RTE_EXEC_ENV_LINUXAPP
 	DEBUG("Hot-plug mutex was locked by thread %lu%s", pthread_self(),
 	      PRIV(dev)->alarm_lock ? " by the hot-plug alarm" : "");
+#endif
 	return ret;
 }
 
@@ -387,7 +389,6 @@ static inline void
 fs_unlock(struct rte_eth_dev *dev, unsigned int is_alarm)
 {
 	int ret;
-	unsigned int prev_alarm_lock = PRIV(dev)->alarm_lock;
 
 	if (is_alarm) {
 		RTE_ASSERT(PRIV(dev)->alarm_lock == 1);
@@ -396,10 +397,14 @@ fs_unlock(struct rte_eth_dev *dev, unsigned int is_alarm)
 	ret = pthread_mutex_unlock(&PRIV(dev)->hotplug_mutex);
 	if (ret)
 		ERROR("Cannot unlock hot-plug mutex(%s)", strerror(ret));
-	else
+#ifdef RTE_EXEC_ENV_LINUXAPP
+	else {
+		unsigned int prev_alarm_lock = PRIV(dev)->alarm_lock;
 		DEBUG("Hot-plug mutex was unlocked by thread %lu%s",
 		      pthread_self(),
 		      prev_alarm_lock ? " by the hot-plug alarm" : "");
+	}
+#endif
 }
 
 /*
-- 
2.15.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] net/failsafe: fix FreeBSD build
  2018-02-13 21:33 [dpdk-dev] [PATCH] net/failsafe: fix FreeBSD build Thomas Monjalon
@ 2018-02-13 21:39 ` Thomas Monjalon
  2018-02-13 22:13 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2018-02-13 21:39 UTC (permalink / raw)
  To: matan; +Cc: dev, gaetan.rivet, Pablo de Lara

13/02/2018 22:33, Thomas Monjalon:
> The type pthread_t is not portable because it is freely defined.
> On Linux, it is an unsigned long int which can be printed with %l.

Forgot to add:

On FreeBSD, it is a pointer.
That's why there was this error:
drivers/net/failsafe/failsafe_private.h:377:53: error:
format specifies type 'unsigned long' but the argument has
type 'pthread_t' (aka 'struct pthread *')

Reported-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

> 
> The debug printing of the thread id is restricted to Linux only.
> 
> Fixes: 655fcd68c7d2 ("net/failsafe: fix hotplug races")
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v2] net/failsafe: fix FreeBSD build
  2018-02-13 21:33 [dpdk-dev] [PATCH] net/failsafe: fix FreeBSD build Thomas Monjalon
  2018-02-13 21:39 ` Thomas Monjalon
@ 2018-02-13 22:13 ` Thomas Monjalon
  2018-02-13 22:18   ` De Lara Guarch, Pablo
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2018-02-13 22:13 UTC (permalink / raw)
  To: matan; +Cc: dev, gaetan.rivet

The type pthread_t is not portable because it is freely defined.
On Linux, it is an unsigned long int which can be printed with %l.
On FreeBSD, it is a pointer which can be printed with %p.

That's why there was this error:
drivers/net/failsafe/failsafe_private.h:377:53: error:
	format specifies type 'unsigned long' but the argument has
	type 'pthread_t' (aka 'struct pthread *')

Fixes: 655fcd68c7d2 ("net/failsafe: fix hotplug races")

Reported-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
v2: adapt printing to BSD and Linux
---
 drivers/net/failsafe/failsafe_private.h | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h
index 5b84db905..2d16ba4ca 100644
--- a/drivers/net/failsafe/failsafe_private.h
+++ b/drivers/net/failsafe/failsafe_private.h
@@ -318,6 +318,14 @@ extern int mac_from_arg;
 	 &((struct txq *)((s)->fs_dev->data->tx_queues[i]))->refcnt[(s)->sid] \
 	)
 
+#ifdef RTE_EXEC_ENV_BSDAPP
+#define FS_THREADID_TYPE void*
+#define FS_THREADID_FMT  "p"
+#else
+#define FS_THREADID_TYPE unsigned long
+#define FS_THREADID_FMT  "lu"
+#endif
+
 #define LOG__(level, m, ...) \
 	RTE_LOG(level, PMD, "net_failsafe: " m "%c", __VA_ARGS__)
 #define LOG_(level, ...) LOG__(level, __VA_ARGS__, '\n')
@@ -374,7 +382,8 @@ fs_lock(struct rte_eth_dev *dev, unsigned int is_alarm)
 			return ret;
 		}
 	}
-	DEBUG("Hot-plug mutex was locked by thread %lu%s", pthread_self(),
+	DEBUG("Hot-plug mutex was locked by thread %" FS_THREADID_FMT "%s",
+	      (FS_THREADID_TYPE)pthread_self(),
 	      PRIV(dev)->alarm_lock ? " by the hot-plug alarm" : "");
 	return ret;
 }
@@ -397,8 +406,8 @@ fs_unlock(struct rte_eth_dev *dev, unsigned int is_alarm)
 	if (ret)
 		ERROR("Cannot unlock hot-plug mutex(%s)", strerror(ret));
 	else
-		DEBUG("Hot-plug mutex was unlocked by thread %lu%s",
-		      pthread_self(),
+		DEBUG("Hot-plug mutex was unlocked by thread %" FS_THREADID_FMT "%s",
+		      (FS_THREADID_TYPE)pthread_self(),
 		      prev_alarm_lock ? " by the hot-plug alarm" : "");
 }
 
-- 
2.15.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/failsafe: fix FreeBSD build
  2018-02-13 22:13 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
@ 2018-02-13 22:18   ` De Lara Guarch, Pablo
  2018-02-13 22:19     ` Matan Azrad
  0 siblings, 1 reply; 6+ messages in thread
From: De Lara Guarch, Pablo @ 2018-02-13 22:18 UTC (permalink / raw)
  To: Thomas Monjalon, matan; +Cc: dev, gaetan.rivet



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Tuesday, February 13, 2018 10:13 PM
> To: matan@mellanox.com
> Cc: dev@dpdk.org; gaetan.rivet@6wind.com
> Subject: [dpdk-dev] [PATCH v2] net/failsafe: fix FreeBSD build
> 
> The type pthread_t is not portable because it is freely defined.
> On Linux, it is an unsigned long int which can be printed with %l.
> On FreeBSD, it is a pointer which can be printed with %p.
> 
> That's why there was this error:
> drivers/net/failsafe/failsafe_private.h:377:53: error:
> 	format specifies type 'unsigned long' but the argument has
> 	type 'pthread_t' (aka 'struct pthread *')
> 
> Fixes: 655fcd68c7d2 ("net/failsafe: fix hotplug races")
> 
> Reported-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

Tested-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/failsafe: fix FreeBSD build
  2018-02-13 22:18   ` De Lara Guarch, Pablo
@ 2018-02-13 22:19     ` Matan Azrad
  2018-02-13 22:20       ` Thomas Monjalon
  0 siblings, 1 reply; 6+ messages in thread
From: Matan Azrad @ 2018-02-13 22:19 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, Thomas Monjalon; +Cc: dev, gaetan.rivet



> -----Original Message-----
> From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
> Sent: Wednesday, February 14, 2018 12:19 AM
> To: Thomas Monjalon <thomas@monjalon.net>; Matan Azrad
> <matan@mellanox.com>
> Cc: dev@dpdk.org; gaetan.rivet@6wind.com
> Subject: RE: [dpdk-dev] [PATCH v2] net/failsafe: fix FreeBSD build
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
> > Sent: Tuesday, February 13, 2018 10:13 PM
> > To: matan@mellanox.com
> > Cc: dev@dpdk.org; gaetan.rivet@6wind.com
> > Subject: [dpdk-dev] [PATCH v2] net/failsafe: fix FreeBSD build
> >
> > The type pthread_t is not portable because it is freely defined.
> > On Linux, it is an unsigned long int which can be printed with %l.
> > On FreeBSD, it is a pointer which can be printed with %p.
> >
> > That's why there was this error:
> > drivers/net/failsafe/failsafe_private.h:377:53: error:
> > 	format specifies type 'unsigned long' but the argument has
> > 	type 'pthread_t' (aka 'struct pthread *')
> >
> > Fixes: 655fcd68c7d2 ("net/failsafe: fix hotplug races")
> >
> > Reported-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> 
> Tested-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> 
Acked-by: Matan Azrad <matan@mellanox.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/failsafe: fix FreeBSD build
  2018-02-13 22:19     ` Matan Azrad
@ 2018-02-13 22:20       ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2018-02-13 22:20 UTC (permalink / raw)
  To: Matan Azrad, De Lara Guarch, Pablo; +Cc: dev, gaetan.rivet

> > > The type pthread_t is not portable because it is freely defined.
> > > On Linux, it is an unsigned long int which can be printed with %l.
> > > On FreeBSD, it is a pointer which can be printed with %p.
> > >
> > > That's why there was this error:
> > > drivers/net/failsafe/failsafe_private.h:377:53: error:
> > > 	format specifies type 'unsigned long' but the argument has
> > > 	type 'pthread_t' (aka 'struct pthread *')
> > >
> > > Fixes: 655fcd68c7d2 ("net/failsafe: fix hotplug races")
> > >
> > > Reported-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > 
> > Tested-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > 
> Acked-by: Matan Azrad <matan@mellanox.com>

Applied

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-02-13 22:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 21:33 [dpdk-dev] [PATCH] net/failsafe: fix FreeBSD build Thomas Monjalon
2018-02-13 21:39 ` Thomas Monjalon
2018-02-13 22:13 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
2018-02-13 22:18   ` De Lara Guarch, Pablo
2018-02-13 22:19     ` Matan Azrad
2018-02-13 22:20       ` Thomas Monjalon

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