[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1499329462.16045.11.camel@edumazet-glaptop3.roam.corp.google.com>
Date: Thu, 06 Jul 2017 01:24:22 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: Cong Wang <xiyou.wangcong@...il.com>
Cc: netdev@...r.kernel.org, borntraeger@...ibm.com,
Sainath Grandhi <sainath.grandhi@...el.com>
Subject: Re: [Patch net] tap: convert a mutex to a spinlock
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@...ibm.com>
> Cc: Sainath Grandhi <sainath.grandhi@...el.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@...il.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);
> + spin_lock(&tap_major->minor_lock);
> + retval = idr_alloc(&tap_major->minor_idr, tap, 1, TAP_NUM_DEVS, GFP_ATOMIC);
> if (retval >= 0) {
> tap->minor = retval;
> } else if (retval == -ENOSPC) {
> netdev_err(tap->dev, "Too many tap devices\n");
> retval = -EINVAL;
> }
> - mutex_unlock(&tap_major->minor_lock);
> + spin_unlock(&tap_major->minor_lock);
idr_preload_end();
>
> unlock:
Thanks.
Powered by blists - more mailing lists