netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>,
	borntraeger@de.ibm.com,
	Sainath Grandhi <sainath.grandhi@intel.com>
Subject: Re: [Patch net] tap: convert a mutex to a spinlock
Date: Thu, 6 Jul 2017 10:56:07 -0700	[thread overview]
Message-ID: <CAM_iQpVbe=iSoAND1hyEmpEcxuTCguXLbPkyHHhTS0s1=9A69Q@mail.gmail.com> (raw)
In-Reply-To: <1499329462.16045.11.camel@edumazet-glaptop3.roam.corp.google.com>

On Thu, Jul 6, 2017 at 1:24 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Wed, 2017-07-05 at 13:50 -0700, Cong Wang wrote:
>> We are not allowed to block on the RCU reader side, so can't
>> just hold the mutex as before. As a quick fix, convert it to
>> a spinlock.
>>
>> Fixes: d9f1f61c0801 ("tap: Extending tap device create/destroy APIs")
>> Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
>> Cc: Sainath Grandhi <sainath.grandhi@intel.com>
>> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
>> ---
>>  drivers/net/tap.c | 18 +++++++++---------
>>  1 file changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/net/tap.c b/drivers/net/tap.c
>> index 4d4173d..d88ae3c 100644
>> --- a/drivers/net/tap.c
>> +++ b/drivers/net/tap.c
>> @@ -106,7 +106,7 @@ struct major_info {
>>       struct rcu_head rcu;
>>       dev_t major;
>>       struct idr minor_idr;
>> -     struct mutex minor_lock;
>> +     spinlock_t minor_lock;
>>       const char *device_name;
>>       struct list_head next;
>>  };
>> @@ -416,15 +416,15 @@ int tap_get_minor(dev_t major, struct tap_dev *tap)
>>               goto unlock;
>>       }
>>
>> -     mutex_lock(&tap_major->minor_lock);
>> -     retval = idr_alloc(&tap_major->minor_idr, tap, 1, TAP_NUM_DEVS, GFP_KERNEL);
>
>         idr_preload(GFP_KERNEL);


Are you sure we can use GFP_KERNEL? RCU read lock is already taken
at this point, so I am afraid we can't do preload here.

  reply	other threads:[~2017-07-06 17:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05 20:50 [Patch net] tap: convert a mutex to a spinlock Cong Wang
2017-07-06  7:14 ` Christian Borntraeger
2017-07-06  8:24 ` Eric Dumazet
2017-07-06 17:56   ` Cong Wang [this message]
2017-07-06  9:52 ` David Miller

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='CAM_iQpVbe=iSoAND1hyEmpEcxuTCguXLbPkyHHhTS0s1=9A69Q@mail.gmail.com' \
    --to=xiyou.wangcong@gmail.com \
    --cc=borntraeger@de.ibm.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=sainath.grandhi@intel.com \
    /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).