From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [net-next rfc V2 7/8] macvtap: add TUNSETQUEUE ioctl
Date: Wed, 05 Jun 2013 11:01:46 +0800 [thread overview]
Message-ID: <51AEAA1A.7060202@redhat.com> (raw)
In-Reply-To: <20130604070519.GE19433@redhat.com>
On 06/04/2013 03:05 PM, Michael S. Tsirkin wrote:
> On Tue, Jun 04, 2013 at 01:54:56PM +0800, Jason Wang wrote:
>> On 06/03/2013 07:09 PM, Michael S. Tsirkin wrote:
>>> On Mon, Jun 03, 2013 at 01:20:58PM +0800, Jason Wang wrote:
>>>> On 06/02/2013 07:22 PM, Michael S. Tsirkin wrote:
>>>>> On Fri, May 31, 2013 at 05:53:24PM +0800, Jason Wang wrote:
>>>>>> This patch adds TUNSETQUEUE ioctl to let userspace can temporarily disable or
>>>>>> enable a queue of macvtap. This is used to be compatible at API layer of tuntap
>>>>>> to simplify the userspace to manage the queues.
>>>>>>
>>>>>> This is done by split the taps array into three different areas:
>>>>>>
>>>>>> - [0, numvtaps) : enabled taps
>>>>>> - [numvtaps, numvtaps + numdisabled) : disabled taps
>>>>>> - [numvtaps + numdisabled, MAX_MAXVTAP_QUEUES) : unused slots
>>>>>>
>>>>>> When a tap were enabled and disabled, it was moved to another area.
>>>>>>
>>>>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
[...]
>>>>> +static int macvtap_disable_queue(struct macvtap_queue *q)
>>>>> +{
>>>>> + struct macvlan_dev *vlan;
>>>>> + int err = -EINVAL;
>>>>> +
>>>>> + spin_lock(&macvtap_lock);
>>>>> + vlan = rcu_dereference_protected(q->vlan,
>>>>> + lockdep_is_held(&macvtap_lock));
>>>>> +
>>>>> + if (vlan) {
>>>>> + int total = vlan->numvtaps + vlan->numdisabled;
>>>>> + int index = q->queue_index;
>>>>> +
>>>>> + BUG_ON(q->queue_index >= total);
>>>>> + if (q->queue_index >= vlan->numvtaps)
>>>>> + goto out;
>>>>> +
>>>>> + err = 0;
>>>>> + macvtap_swap_slot(vlan, index, total - 1);
>>>>> + if (vlan->numdisabled)
>>>>> + /* If there's disabled taps, the above swap will cause
>>>>> + * a disabled tap to be moved to enabled area. So
>>>>> + * another swap is needed to keep the right order.
>>>>> + */
>>>>> + macvtap_swap_slot(vlan, index, vlan->numvtaps - 1);
>>>>> +
>>>>> + /* make sure the pointers were seen before indices */
>>>>> + wmb();
>>>>> Hmm this looks questionable. The code near rmb first
>>>>> checks numvtaps then dereferences the queue.
>>>>> So it might see a new queue but old value of numvtaps.
>>>> Right, barriers here were just best effort to reduce the possibility of
>>>> wrong queue selection when changing the number of queues.
>>> If this is an optimization, I'd say benchmark it and
>>> see if it helps performance.
>>>
>>> I don't expect it to have any effect really.
>>> In fact, the re-ordering of queues that this patch does
>>> is likely to cause packet reorering and hurt performance
>>> more.
>> Yes, so I will remove the barriers.
>>
>> The re-ordering seems to be the easiest way to do fast lookup of active
>> queues. We could use indirection to avoid the re-ordering of queues,
>> it's hard to eliminate OOO packets. If we don't depends on changing the
>> number of queues frequently, we're ok.
>>> I'm guessing the only thing we need for correctness
>>> is ACCESS_ONCE on numvtaps?
>> Did't see how it help.
> For this loop:
> while (unlikely(rxq >= numvtaps))
> rxq -= numvtaps;
>
> you better read numvtaps with ACCESS_ONCE otherwise
> compiler can re-read numvtaps and it would
> change during loop execution.
> rxq can then become negative.
>
I get your meaning, looks like tun should be fixed as well.
Thanks
next prev parent reply other threads:[~2013-06-05 3:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-31 9:53 [net-next rfc V2 0/8] Multiqueue API for macvtap Jason Wang
2013-05-31 9:53 ` [net-next rfc V2 1/8] macvtap: do not add self to waitqueue if doing a nonblock read Jason Wang
2013-05-31 9:53 ` [net-next rfc V2 2/8] macvlan: switch to use IS_ENABLED() Jason Wang
2013-05-31 9:53 ` [net-next rfc V2 3/8] macvtap: introduce macvtap_get_vlan() Jason Wang
2013-05-31 9:53 ` [net-next rfc V2 4/8] macvlan: change the max number of queues to 16 Jason Wang
2013-05-31 9:53 ` [net-next rfc V2 5/8] macvtap: eliminate linear search Jason Wang
2013-05-31 9:53 ` [net-next rfc V2 6/8] macvtap: allow TUNSETIFF to create multiqueue device Jason Wang
2013-05-31 14:48 ` Sergei Shtylyov
2013-06-03 3:05 ` Jason Wang
2013-05-31 9:53 ` [net-next rfc V2 7/8] macvtap: add TUNSETQUEUE ioctl Jason Wang
2013-06-02 11:22 ` Michael S. Tsirkin
2013-06-03 5:20 ` Jason Wang
2013-06-03 11:09 ` Michael S. Tsirkin
2013-06-04 5:54 ` Jason Wang
2013-06-04 7:05 ` Michael S. Tsirkin
2013-06-05 3:01 ` Jason Wang [this message]
2013-05-31 9:53 ` [net-next rfc V2 8/8] macvtap: enable multiqueue flag 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=51AEAA1A.7060202@redhat.com \
--to=jasowang@redhat.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.