[dpdk-dev] [PATCH] Added Spinlock to l3fwd-vf example to prevent race conditioning
Hi Daniel, This old patch is probably good but I'd like you explain it please. Reviewers are also welcome. Thanks -- Thomas 2014-07-23 10:33, Thomas Monjalon: > Hi Daniel, > > Some explanations are missing here. > > > Signed-off-by: Daniel Mrzyglod > > > > --- a/examples/l3fwd-vf/main.c > > +++ b/examples/l3fwd-vf/main.c > > @@ -54,6 +54,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -328,7 +329,7 @@ struct lcore_conf { > > } __rte_cache_aligned; > > > > static struct lcore_conf lcore_conf[RTE_MAX_LCORE]; > > - > > +static rte_spinlock_t > > spinlock_conf[RTE_MAX_ETHPORTS]={RTE_SPINLOCK_INITIALIZER}; > > /* Send burst of packets on an output interface */ > > static inline int > > send_burst(struct lcore_conf *qconf, uint16_t n, uint8_t port) > > @@ -340,7 +341,10 @@ send_burst(struct lcore_conf *qconf, uint16_t n, > > uint8_t port) > > queueid = qconf->tx_queue_id; > > m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table; > > > > + rte_spinlock_lock(_conf[port]) ; > > ret = rte_eth_tx_burst(port, queueid, m_table, n); > > + rte_spinlock_unlock(_conf[port]); > > + > > if (unlikely(ret < n)) { > > do { > > rte_pktmbuf_free(m_table[ret]); > >
[dpdk-dev] [PATCH] Added Spinlock to l3fwd-vf example to prevent race conditioning
> -Original Message- > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Thomas Monjalon > Sent: Tuesday, November 11, 2014 3:57 PM > To: Mrzyglod, DanielX T > Cc: dev at dpdk.org > Subject: Re: [dpdk-dev] [PATCH] Added Spinlock to l3fwd-vf example to prevent > race conditioning > > Hi Daniel, > > This old patch is probably good but I'd like you explain it please. > Reviewers are also welcome. > > Thanks > -- > Thomas > > 2014-07-23 10:33, Thomas Monjalon: > > Hi Daniel, > > > > Some explanations are missing here. > > > > > Signed-off-by: Daniel Mrzyglod > > > > > > --- a/examples/l3fwd-vf/main.c > > > +++ b/examples/l3fwd-vf/main.c > > > @@ -54,6 +54,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -328,7 +329,7 @@ struct lcore_conf { > > > } __rte_cache_aligned; > > > > > > static struct lcore_conf lcore_conf[RTE_MAX_LCORE]; > > > - > > > +static rte_spinlock_t > spinlock_conf[RTE_MAX_ETHPORTS]={RTE_SPINLOCK_INITIALIZER}; > > > /* Send burst of packets on an output interface */ > > > static inline int > > > send_burst(struct lcore_conf *qconf, uint16_t n, uint8_t port) > > > @@ -340,7 +341,10 @@ send_burst(struct lcore_conf *qconf, uint16_t n, > uint8_t port) > > > queueid = qconf->tx_queue_id; > > > m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table; > > > > > > + rte_spinlock_lock(_conf[port]) ; > > > ret = rte_eth_tx_burst(port, queueid, m_table, n); > > > + rte_spinlock_unlock(_conf[port]); It might not be good choice for here, but how about we also provide spin_trylock as alternative API? > > > + > > > if (unlikely(ret < n)) { > > > do { > > > rte_pktmbuf_free(m_table[ret]); > > >
[dpdk-dev] [PATCH] Added Spinlock to l3fwd-vf example to prevent race conditioning
Signed-off-by: Daniel Mrzyglod --- examples/l3fwd-vf/main.c |6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c index 2ca5c21..57852d0 100644 --- a/examples/l3fwd-vf/main.c +++ b/examples/l3fwd-vf/main.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -328,7 +329,7 @@ struct lcore_conf { } __rte_cache_aligned; static struct lcore_conf lcore_conf[RTE_MAX_LCORE]; - +static rte_spinlock_t spinlock_conf[RTE_MAX_ETHPORTS]={RTE_SPINLOCK_INITIALIZER}; /* Send burst of packets on an output interface */ static inline int send_burst(struct lcore_conf *qconf, uint16_t n, uint8_t port) @@ -340,7 +341,10 @@ send_burst(struct lcore_conf *qconf, uint16_t n, uint8_t port) queueid = qconf->tx_queue_id; m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table; + rte_spinlock_lock(_conf[port]) ; ret = rte_eth_tx_burst(port, queueid, m_table, n); + rte_spinlock_unlock(_conf[port]); + if (unlikely(ret < n)) { do { rte_pktmbuf_free(m_table[ret]); -- 1.7.9.5