On Mon, Jun 30, 2014 at 9:58 AM, Daniele Di Proietto
<ddiproie...@vmware.com> wrote:
> This makes a lot of sense, thanks!
>
> Acked-by: Daniele Di Proietto <ddiproie...@vmware.com>
>
> On Jun 26, 2014, at 6:16 PM, Ryan Wilson <wr...@nicira.com> wrote:
>
>> This patch fixes a bug where rte_pktmbuf_alloc() would fail and
>> packets which succeeded to allocate memory with rte_pktmbuf_alloc()
>> would not be sent and leak memory.
>>
>> Also, as a byproduct of using a local variable to record dropped
>> packets, this reduces the locking of the netdev's mutex when
>> multiple packets are dropped in dpdk_do_tx_copy().
>>
>> Signed-off-by: Ryan Wilson <wr...@nicira.com>

Thanks, I pushed this patch.

>> ---
>> lib/netdev-dpdk.c |   21 ++++++++++++---------
>> 1 file changed, 12 insertions(+), 9 deletions(-)
>>
>> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>> index 6e1d293..dfa7d77 100644
>> --- a/lib/netdev-dpdk.c
>> +++ b/lib/netdev-dpdk.c
>> @@ -658,7 +658,9 @@ dpdk_do_tx_copy(struct netdev *netdev, struct 
>> dpif_packet ** pkts, int cnt)
>> {
>>     struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
>>     struct rte_mbuf *mbufs[cnt];
>> -    int i, newcnt = 0;
>> +    int dropped = 0;
>> +    int newcnt = 0;
>> +    int i;
>>
>>     for (i = 0; i < cnt; i++) {
>>         int size = ofpbuf_size(&pkts[i]->ofpbuf);
>> @@ -666,20 +668,15 @@ dpdk_do_tx_copy(struct netdev *netdev, struct 
>> dpif_packet ** pkts, int cnt)
>>             VLOG_WARN_RL(&rl, "Too big size %d max_packet_len %d",
>>                          (int)size , dev->max_packet_len);
>>
>> -            ovs_mutex_lock(&dev->mutex);
>> -            dev->stats.tx_dropped++;
>> -            ovs_mutex_unlock(&dev->mutex);
>> -
>> +            dropped++;
>>             continue;
>>         }
>>
>>         mbufs[newcnt] = rte_pktmbuf_alloc(dev->dpdk_mp->mp);
>>
>>         if (!mbufs[newcnt]) {
>> -            ovs_mutex_lock(&dev->mutex);
>> -            dev->stats.tx_dropped++;
>> -            ovs_mutex_unlock(&dev->mutex);
>> -            return;
>> +            dropped += cnt - i;
>> +            break;
>>         }
>>
>>         /* We have to do a copy for now */
>> @@ -691,6 +688,12 @@ dpdk_do_tx_copy(struct netdev *netdev, struct 
>> dpif_packet ** pkts, int cnt)
>>         newcnt++;
>>     }
>>
>> +    if (dropped) {
>> +        ovs_mutex_lock(&dev->mutex);
>> +        dev->stats.tx_dropped += dropped;
>> +        ovs_mutex_unlock(&dev->mutex);
>> +    }
>> +
>>     dpdk_queue_pkts(dev, NON_PMD_THREAD_TX_QUEUE, mbufs, newcnt);
>>     dpdk_queue_flush(dev, NON_PMD_THREAD_TX_QUEUE);
>> }
>> --
>> 1.7.9.5
>>
>> _______________________________________________
>> dev mailing list
>> dev@openvswitch.org
>> https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman/listinfo/dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=MV9BdLjtFIdhBDBaw5z%2BU6SSA2gAfY4L%2F1HCy3VjlKU%3D%0A&m=6%2B4tv0AbPyF0uKRnYodtwmIozhXz12n0gVxcqeCNwnc%3D%0A&s=76f09a325490da90920fb7c2779217df1d2ae204f95b6ce2fb7b015c8814c68e
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to