lkml.org 
[lkml]   [2013]   [Jan]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH V3 1/2] virtio-net: fix the set affinity bug when CPU IDs are not consecutive
    Date
    Wanlong Gao <gaowanlong@cn.fujitsu.com> writes:
    > */
    > static u16 virtnet_select_queue(struct net_device *dev, struct sk_buff *skb)
    > {
    > - int txq = skb_rx_queue_recorded(skb) ? skb_get_rx_queue(skb) :
    > - smp_processor_id();
    > + int txq = 0;
    > +
    > + if (skb_rx_queue_recorded(skb))
    > + txq = skb_get_rx_queue(skb);
    > + else if ((txq = per_cpu(vq_index, smp_processor_id())) == -1)
    > + txq = 0;

    You should use __get_cpu_var() instead of smp_processor_id() here, ie:

    else if ((txq = __get_cpu_var(vq_index)) == -1)

    And AFAICT, no reason to initialize txq to 0 to start with.

    So:

    int txq;

    if (skb_rx_queue_recorded(skb))
    txq = skb_get_rx_queue(skb);
    else {
    txq = __get_cpu_var(vq_index);
    if (txq == -1)
    txq = 0;
    }

    Now, just to confirm, I assume this can happen even if we use vq_index,
    right, because of races with virtnet_set_channels?

    while (unlikely(txq >= dev->real_num_tx_queues))
    txq -= dev->real_num_tx_queues;


    Thanks,
    Rusty.


    \
     
     \ /
      Last update: 2013-01-09 04:21    [W:3.162 / U:0.368 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site