From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org,
Eric Dumazet <erdnetdev@gmail.com>
Subject: Re: [PATCH V3 1/2] virtio-net: fix the set affinity bug when CPU IDs are not consecutive
Date: Wed, 09 Jan 2013 09:54:59 +0800 [thread overview]
Message-ID: <50ECCDF3.9050403@cn.fujitsu.com> (raw)
In-Reply-To: <87k3rn2qwb.fsf@rustcorp.com.au>
On 01/09/2013 07:31 AM, Rusty Russell wrote:
> 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;
> }
Got it, thank you.
>
> Now, just to confirm, I assume this can happen even if we use vq_index,
> right, because of races with virtnet_set_channels?
I still can't understand this race, could you explain more? thank you.
Regards,
Wanlong Gao
>
> while (unlikely(txq >= dev->real_num_tx_queues))
> txq -= dev->real_num_tx_queues;
>
>
> Thanks,
> Rusty.
>
next prev parent reply other threads:[~2013-01-09 1:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-08 10:07 [PATCH V3 1/2] virtio-net: fix the set affinity bug when CPU IDs are not consecutive Wanlong Gao
2013-01-08 10:07 ` [PATCH V3 2/2] virtio-net: reset virtqueue affinity when doing cpu hotplug Wanlong Gao
2013-01-08 10:26 ` [PATCH V3 1/2] virtio-net: fix the set affinity bug when CPU IDs are not consecutive Jason Wang
2013-01-09 1:52 ` Wanlong Gao
2013-01-09 3:06 ` Jason Wang
2013-01-08 23:31 ` Rusty Russell
2013-01-09 1:54 ` Wanlong Gao [this message]
2013-01-10 0:49 ` Rusty Russell
2013-01-10 9:26 ` Wanlong Gao
2013-01-10 19:12 ` Ben Hutchings
2013-01-11 8:37 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50ECCDF3.9050403@cn.fujitsu.com \
--to=gaowanlong@cn.fujitsu.com \
--cc=erdnetdev@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).