Re: [dpdk-dev] [PATCH v2] mem: memory leaks of hubedir caused by strdup
As Burakov said, for no other reason, I just followed the old version. On Tue, Apr 17, 2018 at 6:31 PM Burakov, Anatoly wrote: > On 17-Apr-18 11:24 AM, Thomas Monjalon wrote: > > 17/04/2018 12:06, Yangchao Zhou: > >> Coverity issue: 272585 > >> Fixes: cb97d93e9d3b ("mem: share hugepage info primary and secondary") > >> > >> Signed-off-by: Yangchao Zhou > >> Acked-by: Anatoly Burakov > > > > Better to provide a small explanation. > > > >> -retval = strdup(splitstr[MOUNTPT]); > >> +snprintf(hugedir, len, "%s", > splitstr[MOUNTPT]); > > > > I think it is candidate to be replaced by strlcpy. > > Please check > > > > Yes, it seems that strlcpy thingie was merged without much fanfare. I'll > be submitting a patch fixing various usages of snprintf in my recent > commits. I'm inclined to leave this as is for this commit, as it's not > the purpose of this fix. > > -- > Thanks, > Anatoly >
Re: [dpdk-dev] [PATCH] kni: optimize the kni release speed
On Tue, Mar 27, 2018 at 12:44 AM Ferruh Yigit wrote: > On 2/6/2018 10:33 AM, zhouyangchao wrote: > > Physical addresses in the fifo named alloc_q need to be traversed to > > release in user space. The physical address to the virtual address > > conversion in kernel space is much better. > > Yes current approach should be slower but this is not in data path, this > is when > a kni interface released, I expect no recognizable difference. > > I changed the number of pre-allocation mbufs to 512 to improve performance. It cost nearly 3 seconds to release mbufs with a mbuf pool that has more than 131072 mbufs. I need to lock the forwarding threads for some reason. > > > > Signed-off-by: Yangchao Zhou > > --- > > lib/librte_eal/linuxapp/kni/kni_dev.h | 1 + > > lib/librte_eal/linuxapp/kni/kni_misc.c | 1 + > > lib/librte_eal/linuxapp/kni/kni_net.c | 15 +++ > > lib/librte_kni/rte_kni.c | 26 +- > > 4 files changed, 18 insertions(+), 25 deletions(-) > > > > diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h > b/lib/librte_eal/linuxapp/kni/kni_dev.h > > index c9393d8..7cd9bf8 100644 > > --- a/lib/librte_eal/linuxapp/kni/kni_dev.h > > +++ b/lib/librte_eal/linuxapp/kni/kni_dev.h > > @@ -92,6 +92,7 @@ struct kni_dev { > > void *alloc_va[MBUF_BURST_SZ]; > > }; > > > > +void kni_net_fifo_pa2va(struct kni_dev *kni); > > void kni_net_rx(struct kni_dev *kni); > > void kni_net_init(struct net_device *dev); > > void kni_net_config_lo_mode(char *lo_str); > > diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c > b/lib/librte_eal/linuxapp/kni/kni_misc.c > > index 01574ec..668488b 100644 > > --- a/lib/librte_eal/linuxapp/kni/kni_misc.c > > +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c > > @@ -507,6 +507,7 @@ kni_ioctl_release(struct net *net, uint32_t > ioctl_num, > > dev->pthread = NULL; > > } > > > > + kni_net_fifo_pa2va(dev); > > kni_dev_remove(dev); > > list_del(&dev->list); > > ret = 0; > > diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c > b/lib/librte_eal/linuxapp/kni/kni_net.c > > index 9f9b798..662a527 100644 > > --- a/lib/librte_eal/linuxapp/kni/kni_net.c > > +++ b/lib/librte_eal/linuxapp/kni/kni_net.c > > @@ -73,6 +73,21 @@ va2pa(void *va, struct rte_kni_mbuf *m) > > return pa; > > } > > > > +/* convert physical addresses to virtual addresses in fifo for kni > release */ > > +void > > +kni_net_fifo_pa2va(struct kni_dev *kni) > > +{ > > + void *fifo = kni->alloc_q; > > + int i, count = kni_fifo_count(fifo); > > + void *pa = NULL, *kva, *va; > > + for (i = 0; i < count; ++i) { > > + (void)kni_fifo_get(fifo, &pa, 1); > > + kva = pa2kva(pa); > > + va = pa2va(pa, kva); > > + (void)kni_fifo_put(fifo, &va, 1); > > kni fifo are single producer, single consumer. For alloc_q kernel side is > consumer, I aware at this stage applications should stop the traffic, but > still > I am not comfortable mixing producer/consumer roles here. > > Also alloc_q should have physical addresses this logic stores virtual > addresses > in it and not sure about this either to mix addressing logic in the queue. > > Instead of this conversion, what about moving from alloc_q to free_q? > free_q > already has virtual addresses and freed by userspace, so this will be safe. > I suggest keeping alloc_q free logic in the userspace in any case, if > alloc_q is > free it won't cost anyway. > > > This is a very valuable suggestion. My implementation is not compatible and needs to upgrade rte_kni.ko and application at the same time. > And while checking for this I may found something else. We have same > problem > with rx_q, it has physical addresses which makes hard to free in > userspace. The > existing intention is to give some time to kernel to consume the rx_q so > that it > won't be an issue for userspace. But that logic can be wrong. > During the time userspace waits the netdev may be already destroyed and > there is > nothing to receive the packet, perhaps we should move wait above the ioctl. > Since you are already checking these parts perhaps you would like to > comment :) > > In the actual scene, its impact on time is small. The mbuf leak in kni_release does not occur in single-threaded mode, but in multi-threaded mode. I didn't realize this leak before because I've been using single-threaded mode. I suggest mov
Re: [dpdk-dev] [PATCH] net/bnx2x: reserve enough headroom for mbuf prepend
When allocating a new mbuf for Rx, the value of m->data_off should be reset to its default value (RTE_PKTMBUF_HEADROOM), instead of reusing the previous undefined value, which could cause the packet to have a too small or too high headroom. On Mon, Mar 5, 2018 at 11:28 PM Ferruh Yigit wrote: > On 2/6/2018 11:21 AM, zhouyangchao wrote: > > Can you please provide more information why this patch is needed? > > > Signed-off-by: Yangchao Zhou > > --- > > drivers/net/bnx2x/bnx2x_rxtx.c | 8 +--- > > 1 file changed, 5 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c > b/drivers/net/bnx2x/bnx2x_rxtx.c > > index a0d4ac9..d8a3225 100644 > > --- a/drivers/net/bnx2x/bnx2x_rxtx.c > > +++ b/drivers/net/bnx2x/bnx2x_rxtx.c > > @@ -140,7 +140,8 @@ bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev, > > return -ENOMEM; > > } > > rxq->sw_ring[idx] = mbuf; > > - rxq->rx_ring[idx] = mbuf->buf_iova; > > + rxq->rx_ring[idx] = > > + rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf)); > > } > > rxq->pkt_first_seg = NULL; > > rxq->pkt_last_seg = NULL; > > @@ -400,7 +401,8 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf > **rx_pkts, uint16_t nb_pkts) > > > > rx_mb = rxq->sw_ring[bd_cons]; > > rxq->sw_ring[bd_cons] = new_mb; > > - rxq->rx_ring[bd_prod] = new_mb->buf_iova; > > + rxq->rx_ring[bd_prod] = > > + > rte_cpu_to_le_64(rte_mbuf_data_iova_default(new_mb)); > > > > rx_pref = NEXT_RX_BD(bd_cons) & MAX_RX_BD(rxq); > > rte_prefetch0(rxq->sw_ring[rx_pref]); > > @@ -409,7 +411,7 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf > **rx_pkts, uint16_t nb_pkts) > > rte_prefetch0(&rxq->sw_ring[rx_pref]); > > } > > > > - rx_mb->data_off = pad; > > + rx_mb->data_off = pad + RTE_PKTMBUF_HEADROOM; > > rx_mb->nb_segs = 1; > > rx_mb->next = NULL; > > rx_mb->pkt_len = rx_mb->data_len = len; > > > >
[dpdk-dev] [PATCH] net/bnx2x: reserve enough headroom for mbuf prepend
Signed-off-by: Yangchao Zhou --- drivers/net/bnx2x/bnx2x_rxtx.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c index a0d4ac9..d8a3225 100644 --- a/drivers/net/bnx2x/bnx2x_rxtx.c +++ b/drivers/net/bnx2x/bnx2x_rxtx.c @@ -140,7 +140,8 @@ bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev, return -ENOMEM; } rxq->sw_ring[idx] = mbuf; - rxq->rx_ring[idx] = mbuf->buf_iova; + rxq->rx_ring[idx] = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf)); } rxq->pkt_first_seg = NULL; rxq->pkt_last_seg = NULL; @@ -400,7 +401,8 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rx_mb = rxq->sw_ring[bd_cons]; rxq->sw_ring[bd_cons] = new_mb; - rxq->rx_ring[bd_prod] = new_mb->buf_iova; + rxq->rx_ring[bd_prod] = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(new_mb)); rx_pref = NEXT_RX_BD(bd_cons) & MAX_RX_BD(rxq); rte_prefetch0(rxq->sw_ring[rx_pref]); @@ -409,7 +411,7 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rte_prefetch0(&rxq->sw_ring[rx_pref]); } - rx_mb->data_off = pad; + rx_mb->data_off = pad + RTE_PKTMBUF_HEADROOM; rx_mb->nb_segs = 1; rx_mb->next = NULL; rx_mb->pkt_len = rx_mb->data_len = len; -- 2.9.0.windows.1
[dpdk-dev] [PATCH] net/bnx2x: reserve enough headroom for mbuf prepend
Signed-off-by: Yangchao Zhou --- drivers/net/bnx2x/bnx2x_rxtx.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c index a0d4ac9..d8a3225 100644 --- a/drivers/net/bnx2x/bnx2x_rxtx.c +++ b/drivers/net/bnx2x/bnx2x_rxtx.c @@ -140,7 +140,8 @@ bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev, return -ENOMEM; } rxq->sw_ring[idx] = mbuf; - rxq->rx_ring[idx] = mbuf->buf_iova; + rxq->rx_ring[idx] = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf)); } rxq->pkt_first_seg = NULL; rxq->pkt_last_seg = NULL; @@ -400,7 +401,8 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rx_mb = rxq->sw_ring[bd_cons]; rxq->sw_ring[bd_cons] = new_mb; - rxq->rx_ring[bd_prod] = new_mb->buf_iova; + rxq->rx_ring[bd_prod] = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(new_mb)); rx_pref = NEXT_RX_BD(bd_cons) & MAX_RX_BD(rxq); rte_prefetch0(rxq->sw_ring[rx_pref]); @@ -409,7 +411,7 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rte_prefetch0(&rxq->sw_ring[rx_pref]); } - rx_mb->data_off = pad; + rx_mb->data_off = pad + RTE_PKTMBUF_HEADROOM; rx_mb->nb_segs = 1; rx_mb->next = NULL; rx_mb->pkt_len = rx_mb->data_len = len; -- 2.9.0.windows.1
[dpdk-dev] [PATCH] net/bnx2x: reserve enough headroom for mbuf prepend
Signed-off-by: Yangchao Zhou --- drivers/net/bnx2x/bnx2x_rxtx.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c index a0d4ac9..d8a3225 100644 --- a/drivers/net/bnx2x/bnx2x_rxtx.c +++ b/drivers/net/bnx2x/bnx2x_rxtx.c @@ -140,7 +140,8 @@ bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev, return -ENOMEM; } rxq->sw_ring[idx] = mbuf; - rxq->rx_ring[idx] = mbuf->buf_iova; + rxq->rx_ring[idx] = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf)); } rxq->pkt_first_seg = NULL; rxq->pkt_last_seg = NULL; @@ -400,7 +401,8 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rx_mb = rxq->sw_ring[bd_cons]; rxq->sw_ring[bd_cons] = new_mb; - rxq->rx_ring[bd_prod] = new_mb->buf_iova; + rxq->rx_ring[bd_prod] = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(new_mb)); rx_pref = NEXT_RX_BD(bd_cons) & MAX_RX_BD(rxq); rte_prefetch0(rxq->sw_ring[rx_pref]); @@ -409,7 +411,7 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rte_prefetch0(&rxq->sw_ring[rx_pref]); } - rx_mb->data_off = pad; + rx_mb->data_off = pad + RTE_PKTMBUF_HEADROOM; rx_mb->nb_segs = 1; rx_mb->next = NULL; rx_mb->pkt_len = rx_mb->data_len = len; -- 2.9.0.windows.1
[dpdk-dev] [PATCH] net/bnx2x: reserve enough headroom for mbuf prepend
Signed-off-by: Yangchao Zhou --- drivers/net/bnx2x/bnx2x_rxtx.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c index a0d4ac9..d8a3225 100644 --- a/drivers/net/bnx2x/bnx2x_rxtx.c +++ b/drivers/net/bnx2x/bnx2x_rxtx.c @@ -140,7 +140,8 @@ bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev, return -ENOMEM; } rxq->sw_ring[idx] = mbuf; - rxq->rx_ring[idx] = mbuf->buf_iova; + rxq->rx_ring[idx] = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf)); } rxq->pkt_first_seg = NULL; rxq->pkt_last_seg = NULL; @@ -400,7 +401,8 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rx_mb = rxq->sw_ring[bd_cons]; rxq->sw_ring[bd_cons] = new_mb; - rxq->rx_ring[bd_prod] = new_mb->buf_iova; + rxq->rx_ring[bd_prod] = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(new_mb)); rx_pref = NEXT_RX_BD(bd_cons) & MAX_RX_BD(rxq); rte_prefetch0(rxq->sw_ring[rx_pref]); @@ -409,7 +411,7 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rte_prefetch0(&rxq->sw_ring[rx_pref]); } - rx_mb->data_off = pad; + rx_mb->data_off = pad + RTE_PKTMBUF_HEADROOM; rx_mb->nb_segs = 1; rx_mb->next = NULL; rx_mb->pkt_len = rx_mb->data_len = len; -- 2.9.0.windows.1
[dpdk-dev] [PATCH] net/bnx2x: reserve enough headroom for mbuf prepend
Signed-off-by: Yangchao Zhou --- drivers/net/bnx2x/bnx2x_rxtx.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c index a0d4ac9..d8a3225 100644 --- a/drivers/net/bnx2x/bnx2x_rxtx.c +++ b/drivers/net/bnx2x/bnx2x_rxtx.c @@ -140,7 +140,8 @@ bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev, return -ENOMEM; } rxq->sw_ring[idx] = mbuf; - rxq->rx_ring[idx] = mbuf->buf_iova; + rxq->rx_ring[idx] = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf)); } rxq->pkt_first_seg = NULL; rxq->pkt_last_seg = NULL; @@ -400,7 +401,8 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rx_mb = rxq->sw_ring[bd_cons]; rxq->sw_ring[bd_cons] = new_mb; - rxq->rx_ring[bd_prod] = new_mb->buf_iova; + rxq->rx_ring[bd_prod] = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(new_mb)); rx_pref = NEXT_RX_BD(bd_cons) & MAX_RX_BD(rxq); rte_prefetch0(rxq->sw_ring[rx_pref]); @@ -409,7 +411,7 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rte_prefetch0(&rxq->sw_ring[rx_pref]); } - rx_mb->data_off = pad; + rx_mb->data_off = pad + RTE_PKTMBUF_HEADROOM; rx_mb->nb_segs = 1; rx_mb->next = NULL; rx_mb->pkt_len = rx_mb->data_len = len; -- 2.9.0.windows.1
[dpdk-dev] [PATCH] net/bnx2x: reserve enough headroom for mbuf prepend
Signed-off-by: Yangchao Zhou --- drivers/net/bnx2x/bnx2x_rxtx.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c index a0d4ac9..d8a3225 100644 --- a/drivers/net/bnx2x/bnx2x_rxtx.c +++ b/drivers/net/bnx2x/bnx2x_rxtx.c @@ -140,7 +140,8 @@ bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev, return -ENOMEM; } rxq->sw_ring[idx] = mbuf; - rxq->rx_ring[idx] = mbuf->buf_iova; + rxq->rx_ring[idx] = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf)); } rxq->pkt_first_seg = NULL; rxq->pkt_last_seg = NULL; @@ -400,7 +401,8 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rx_mb = rxq->sw_ring[bd_cons]; rxq->sw_ring[bd_cons] = new_mb; - rxq->rx_ring[bd_prod] = new_mb->buf_iova; + rxq->rx_ring[bd_prod] = + rte_cpu_to_le_64(rte_mbuf_data_iova_default(new_mb)); rx_pref = NEXT_RX_BD(bd_cons) & MAX_RX_BD(rxq); rte_prefetch0(rxq->sw_ring[rx_pref]); @@ -409,7 +411,7 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rte_prefetch0(&rxq->sw_ring[rx_pref]); } - rx_mb->data_off = pad; + rx_mb->data_off = pad + RTE_PKTMBUF_HEADROOM; rx_mb->nb_segs = 1; rx_mb->next = NULL; rx_mb->pkt_len = rx_mb->data_len = len; -- 2.9.0.windows.1
[dpdk-dev] [PATCH] kni: optimize the kni release speed
Physical addresses in the fifo named alloc_q need to be traversed to release in user space. The physical address to the virtual address conversion in kernel space is much better. Signed-off-by: Yangchao Zhou --- lib/librte_eal/linuxapp/kni/kni_dev.h | 1 + lib/librte_eal/linuxapp/kni/kni_misc.c | 1 + lib/librte_eal/linuxapp/kni/kni_net.c | 15 +++ lib/librte_kni/rte_kni.c | 26 +- 4 files changed, 18 insertions(+), 25 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h index c9393d8..7cd9bf8 100644 --- a/lib/librte_eal/linuxapp/kni/kni_dev.h +++ b/lib/librte_eal/linuxapp/kni/kni_dev.h @@ -92,6 +92,7 @@ struct kni_dev { void *alloc_va[MBUF_BURST_SZ]; }; +void kni_net_fifo_pa2va(struct kni_dev *kni); void kni_net_rx(struct kni_dev *kni); void kni_net_init(struct net_device *dev); void kni_net_config_lo_mode(char *lo_str); diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 01574ec..668488b 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -507,6 +507,7 @@ kni_ioctl_release(struct net *net, uint32_t ioctl_num, dev->pthread = NULL; } + kni_net_fifo_pa2va(dev); kni_dev_remove(dev); list_del(&dev->list); ret = 0; diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c index 9f9b798..662a527 100644 --- a/lib/librte_eal/linuxapp/kni/kni_net.c +++ b/lib/librte_eal/linuxapp/kni/kni_net.c @@ -73,6 +73,21 @@ va2pa(void *va, struct rte_kni_mbuf *m) return pa; } +/* convert physical addresses to virtual addresses in fifo for kni release */ +void +kni_net_fifo_pa2va(struct kni_dev *kni) +{ + void *fifo = kni->alloc_q; + int i, count = kni_fifo_count(fifo); + void *pa = NULL, *kva, *va; + for (i = 0; i < count; ++i) { + (void)kni_fifo_get(fifo, &pa, 1); + kva = pa2kva(pa); + va = pa2va(pa, kva); + (void)kni_fifo_put(fifo, &va, 1); + } +} + /* * It can be called to process the request. */ diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index 2867411..f8398a9 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -435,30 +435,6 @@ va2pa(struct rte_mbuf *m) (unsigned long)m->buf_iova)); } -static void -obj_free(struct rte_mempool *mp __rte_unused, void *opaque, void *obj, - unsigned obj_idx __rte_unused) -{ - struct rte_mbuf *m = obj; - void *mbuf_phys = opaque; - - if (va2pa(m) == mbuf_phys) - rte_pktmbuf_free(m); -} - -static void -kni_free_fifo_phy(struct rte_mempool *mp, struct rte_kni_fifo *fifo) -{ - void *mbuf_phys; - int ret; - - do { - ret = kni_fifo_get(fifo, &mbuf_phys, 1); - if (ret) - rte_mempool_obj_iter(mp, obj_free, mbuf_phys); - } while (ret); -} - int rte_kni_release(struct rte_kni *kni) { @@ -484,7 +460,7 @@ rte_kni_release(struct rte_kni *kni) if (kni_fifo_count(kni->rx_q)) RTE_LOG(ERR, KNI, "Fail to free all Rx-q items\n"); - kni_free_fifo_phy(kni->pktmbuf_pool, kni->alloc_q); + kni_free_fifo(kni->alloc_q); kni_free_fifo(kni->tx_q); kni_free_fifo(kni->free_q); -- 2.9.0.windows.1
[dpdk-dev] [PATCH] kni: optimize the kni release speed
Physical addresses in the fifo named alloc_q need to be traversed to release in user space. The physical address to the virtual address conversion in kernel space is much better. Signed-off-by: Yangchao Zhou --- lib/librte_eal/linuxapp/kni/kni_dev.h | 1 + lib/librte_eal/linuxapp/kni/kni_misc.c | 1 + lib/librte_eal/linuxapp/kni/kni_net.c | 15 +++ lib/librte_kni/rte_kni.c | 26 +- 4 files changed, 18 insertions(+), 25 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h index c9393d8..7cd9bf8 100644 --- a/lib/librte_eal/linuxapp/kni/kni_dev.h +++ b/lib/librte_eal/linuxapp/kni/kni_dev.h @@ -92,6 +92,7 @@ struct kni_dev { void *alloc_va[MBUF_BURST_SZ]; }; +void kni_net_fifo_pa2va(struct kni_dev *kni); void kni_net_rx(struct kni_dev *kni); void kni_net_init(struct net_device *dev); void kni_net_config_lo_mode(char *lo_str); diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 01574ec..668488b 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -507,6 +507,7 @@ kni_ioctl_release(struct net *net, uint32_t ioctl_num, dev->pthread = NULL; } + kni_net_fifo_pa2va(dev); kni_dev_remove(dev); list_del(&dev->list); ret = 0; diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c index 9f9b798..662a527 100644 --- a/lib/librte_eal/linuxapp/kni/kni_net.c +++ b/lib/librte_eal/linuxapp/kni/kni_net.c @@ -73,6 +73,21 @@ va2pa(void *va, struct rte_kni_mbuf *m) return pa; } +/* convert physical addresses to virtual addresses in fifo for kni release */ +void +kni_net_fifo_pa2va(struct kni_dev *kni) +{ + void *fifo = kni->alloc_q; + int i, count = kni_fifo_count(fifo); + void *pa = NULL, *kva, *va; + for (i = 0; i < count; ++i) { + (void)kni_fifo_get(fifo, &pa, 1); + kva = pa2kva(pa); + va = pa2va(pa, kva); + (void)kni_fifo_put(fifo, &va, 1); + } +} + /* * It can be called to process the request. */ diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index 2867411..f8398a9 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -435,30 +435,6 @@ va2pa(struct rte_mbuf *m) (unsigned long)m->buf_iova)); } -static void -obj_free(struct rte_mempool *mp __rte_unused, void *opaque, void *obj, - unsigned obj_idx __rte_unused) -{ - struct rte_mbuf *m = obj; - void *mbuf_phys = opaque; - - if (va2pa(m) == mbuf_phys) - rte_pktmbuf_free(m); -} - -static void -kni_free_fifo_phy(struct rte_mempool *mp, struct rte_kni_fifo *fifo) -{ - void *mbuf_phys; - int ret; - - do { - ret = kni_fifo_get(fifo, &mbuf_phys, 1); - if (ret) - rte_mempool_obj_iter(mp, obj_free, mbuf_phys); - } while (ret); -} - int rte_kni_release(struct rte_kni *kni) { @@ -484,7 +460,7 @@ rte_kni_release(struct rte_kni *kni) if (kni_fifo_count(kni->rx_q)) RTE_LOG(ERR, KNI, "Fail to free all Rx-q items\n"); - kni_free_fifo_phy(kni->pktmbuf_pool, kni->alloc_q); + kni_free_fifo(kni->alloc_q); kni_free_fifo(kni->tx_q); kni_free_fifo(kni->free_q); -- 2.9.0.windows.1
[dpdk-dev] [PATCH] net/fm10k: remove RSS restriction with num of queues
FM10K HW does not have such restrictions. Enabling RSS with single queue is not used to distribute flow but to compute a RSS hash value. It can reduce cpu cycles of computing a hash value with five tuples. In addition, there is an explicit method to disable RSS instead of an obscure way. Signed-off-by: Yangchao Zhou --- drivers/net/fm10k/fm10k_ethdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 2d05a46..403f6c5 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -533,9 +533,8 @@ fm10k_dev_rss_configure(struct rte_eth_dev *dev) 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA, }; - if (dev->data->nb_rx_queues == 1 || - dev_conf->rxmode.mq_mode != ETH_MQ_RX_RSS || - dev_conf->rx_adv_conf.rss_conf.rss_hf == 0) { + if (dev_conf->rxmode.mq_mode != ETH_MQ_RX_RSS || + dev_conf->rx_adv_conf.rss_conf.rss_hf == 0) { FM10K_WRITE_REG(hw, FM10K_MRQC(0), 0); return; } -- 2.9.0.windows.1
[dpdk-dev] [PATCH] net/fm10k: remove RSS restriction with num of queues
FM10K HW does not have such restrictions. Signed-off-by: Yangchao Zhou --- drivers/net/fm10k/fm10k_ethdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 2d05a46..403f6c5 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -533,9 +533,8 @@ fm10k_dev_rss_configure(struct rte_eth_dev *dev) 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA, }; - if (dev->data->nb_rx_queues == 1 || - dev_conf->rxmode.mq_mode != ETH_MQ_RX_RSS || - dev_conf->rx_adv_conf.rss_conf.rss_hf == 0) { + if (dev_conf->rxmode.mq_mode != ETH_MQ_RX_RSS || + dev_conf->rx_adv_conf.rss_conf.rss_hf == 0) { FM10K_WRITE_REG(hw, FM10K_MRQC(0), 0); return; } -- 2.9.0.windows.1
[dpdk-dev] [PATCH] igb: fix Tx queue number
Internal variable containing the number of TX queues for a device, was being incorrectly assigned the number of RX queues, instead of TX. Fixes: 27b609cbd1c6 ("ethdev: move the multi-queue mode check to specific drivers") Signed-off-by: Yangchao Zhou --- drivers/net/e1000/igb_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index fdc139f..a600fba 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -1212,7 +1212,7 @@ igb_check_mq_mode(struct rte_eth_dev *dev) enum rte_eth_rx_mq_mode rx_mq_mode = dev->data->dev_conf.rxmode.mq_mode; enum rte_eth_tx_mq_mode tx_mq_mode = dev->data->dev_conf.txmode.mq_mode; uint16_t nb_rx_q = dev->data->nb_rx_queues; - uint16_t nb_tx_q = dev->data->nb_rx_queues; + uint16_t nb_tx_q = dev->data->nb_tx_queues; if ((rx_mq_mode & ETH_MQ_RX_DCB_FLAG) || tx_mq_mode == ETH_MQ_TX_DCB || -- 2.9.0.windows.1
[dpdk-dev] [PATCH] pci:fix missing free
Signed-off-by: zhouyangchao --- lib/librte_eal/common/eal_common_pci.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 7248c38..eb44998 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -378,6 +378,7 @@ rte_eal_pci_detach(const struct rte_pci_addr *addr) goto err_return; TAILQ_REMOVE(&pci_device_list, dev, next); + free(dev); return 0; } return -1; -- 1.7.1
[dpdk-dev] [PATCH] kni: unregister an unregisterd net_device could cause a kernel crash
Signed-off-by: zhouyangchao --- lib/librte_eal/linuxapp/kni/kni_misc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 67e9b7d..5c58a83 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -545,7 +545,9 @@ kni_ioctl_create(struct net *net, if (ret) { KNI_ERR("error %i registering device \"%s\"\n", ret, dev_info.name); + kni->net_dev = NULL; kni_dev_remove(kni); + free_netdev(net_dev); return -ENODEV; } -- 2.10.0
[dpdk-dev] [PATCH] kni: unregister an unregisterd net_device could cause a kernel crash
Signed-off-by: zhouyangchao --- lib/librte_eal/linuxapp/kni/kni_misc.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 67e9b7d..ad4e603 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -361,7 +361,9 @@ kni_dev_remove(struct kni_dev *dev) igb_kni_remove(dev->pci_dev); if (dev->net_dev) { - unregister_netdev(dev->net_dev); + if (dev->netdev->reg_state == NETREG_REGISTERED){ + unregister_netdev(dev->net_dev); + } free_netdev(dev->net_dev); } -- 1.7.1
[dpdk-dev] [PATCH] kni: unregister an unregisterd net_device could cause a kernel crash
Signed-off-by: zhouyangchao --- lib/librte_eal/linuxapp/kni/kni_misc.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 67e9b7d..17b6d7a 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -361,6 +361,9 @@ kni_dev_remove(struct kni_dev *dev) igb_kni_remove(dev->pci_dev); if (dev->net_dev) { + if (dev->net_dev->state == NETREG_REGISTERED) { + unregister_netdev(dev->net_dev); + } unregister_netdev(dev->net_dev); free_netdev(dev->net_dev); } -- 1.7.1