From: Vlad Yasevich <vyasevic@redhat.com>
To: arnd@arndb.de
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
netdev@vger.kernel.org, davem@davemloft.net, mst@redhat.com,
jasowang@redhat.com
Subject: Re: [PATCH net-next 1/2] macvtap: Let TUNSETOFFLOAD actually controll offload features.
Date: Wed, 19 Jun 2013 14:59:07 -0400 [thread overview]
Message-ID: <51C1FF7B.9050502@redhat.com> (raw)
In-Reply-To: <51C1DA58.4010204@redhat.com>
Arnd
MST suggested I add you. Do you remember the reason
why macvtap uses rcu_read_lock_bh() instead of plain
rcu_read_lock()? Additionally it seems to use
synchronize_rcu(), not the _bh() version.
Thanks
-vlad
On 06/19/2013 12:20 PM, Vlad Yasevich wrote:
> On 06/19/2013 11:46 AM, Eric Dumazet wrote:
>> On Wed, 2013-06-19 at 11:26 -0400, Vlad Yasevich wrote:
>>
>>> I think I do since vlan pointer may change even when I am holding
>>> rtnl. rtnl is needed to change features. rcu is needed to get
>>> the vlan pointer.
>>>
>>>> (A BH handler will not change q->vlan )
>>>
>>> No, but the _bh rcu calls seem to be used when dereferencing q->vlan.
>>> I am not sure the reason for that...
>>
>> You mix the reader/fast path, properly using RCU,
>> and the writer path, using macvtap_lock ( a spinlock ).
>>
>> That's clear sign you missed something.
>>
>
> I don't think I need macvtap_lock as I am not modifying the relationship
> between q and vlan. I am attempting to modify the macvlan device
> features. So macvtap_lock does not apply, and _rcu is used.
>
> Looking at the entire macvtap driver, only the _bh variants of rcu
> are used throughout the driver, including in the ioctl() function. I
> am not sure why the driver requires BH to be disabled, but that
> seems to be the case.
>
>>>
>>>>
>>>> BTW, it looks like ->vlan is protected by macvtap_lock
>>>
>>> Right. This is why I use rcu to get vlan. rtnl is needed to avoid
>>> asserts in the feature change code.
>>
>> The management should be allowed to sleep, and rcu_read_lock_bh()
>> disallows that.
>>
>> Maybe some driver callback will really sleep and crash after your patch.
>>
>> vi +69 drivers/net/macvtap.c
>>
>> /*
>> * RCU usage:
>> * The macvtap_queue and the macvlan_dev are loosely coupled, the
>> * pointers from one to the other can only be read while rcu_read_lock
>> * or macvtap_lock is held.
>>
>> Your patch does not respect the rules of this driver.
>
> Why not? It uses rcu to acquire the pointer thus following the rules.
> The use of the pointer is within the critical section so we are
> guaranteed to have a valid pointer.
>
>>
>> macvtap_lock is always acquired from process context, without any need
>> for _bh variant.
>>
>
> No, the lock is acquired only when modifying the relationship between
> the macvtap_queue and macvtap_dev.
>
>
>> Quite frankly, I would switch this driver to use a mutex for
>> macvtap_lock.
>>
>> And simply remove it, as RTNL is most probably already owned.
>>
>
> That's the issue. RTNL is not owned in the ioctl case. In fact
> rtnl_lock was added to the patch because RTNL asserts were triggered
> when changing device features.
>
> -vlad
>
>
>>
>>
>>
>>
>
next prev parent reply other threads:[~2013-06-19 18:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-19 14:47 [PATCH net-next 0/2] macvtap: Add support for offload control Vlad Yasevich
2013-06-19 14:47 ` [PATCH net-next 1/2] macvtap: Let TUNSETOFFLOAD actually controll offload features Vlad Yasevich
2013-06-19 15:16 ` Michael S. Tsirkin
2013-06-19 15:47 ` Vlad Yasevich
2013-06-19 15:55 ` Michael S. Tsirkin
2013-06-19 17:05 ` Vlad Yasevich
2013-06-19 18:17 ` Michael S. Tsirkin
2013-06-19 15:17 ` Eric Dumazet
2013-06-19 15:26 ` Vlad Yasevich
2013-06-19 15:46 ` Eric Dumazet
2013-06-19 16:20 ` Vlad Yasevich
2013-06-19 16:34 ` Eric Dumazet
2013-06-19 18:59 ` Vlad Yasevich [this message]
2013-06-19 22:38 ` Arnd Bergmann
2013-06-19 14:47 ` [PATCH net-next 2/2] macvtap: Perform GSO on forwarding path Vlad Yasevich
2013-06-19 15:30 ` Michael S. Tsirkin
2013-06-19 16:27 ` Vlad Yasevich
2013-06-19 16:22 ` Vlad Yasevich
2013-06-19 18:09 ` Sergei Shtylyov
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=51C1FF7B.9050502@redhat.com \
--to=vyasevic@redhat.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=jasowang@redhat.com \
--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 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).