[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.00.0910092033560.9428@localhost.localdomain>
Date: Fri, 9 Oct 2009 20:34:32 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: Frederic Weisbecker <fweisbec@...il.com>
cc: Greg Kroah-Hartman <gregkh@...e.de>,
LKML <linux-kernel@...r.kernel.org>, Ingo Molnar <mingo@...e.hu>,
John Kacur <jkacur@...hat.com>,
Sven-Thorsten Dietrich <sven@...bigcorporation.com>,
Jonathan Corbet <corbet@....net>,
Alessio Igor Bogani <abogani@...ware.it>
Subject: Re: [PATCH] mem_class: Drop the bkl from memory_open()
On Fri, 9 Oct 2009, Frederic Weisbecker wrote:
> The generic open callback for the mem class devices is "protected" by
> the bkl.
>
> Let's look at the datas manipulated inside memory_open:
>
> - inode and file: safe
> - the devlist: safe because it is constant
> - the memdev classes inside this array are safe too (constant)
>
> After we find out which memdev file operation we need to use, we call
> its open callback. Depending on the targeted memdev, we call either
> open_port() that doesn't manipulate any racy data (just a capable()
> check), or we call nothing.
>
> So it's safe to remove the big kernel lock there.
Thanks, queued.
tglx
> Signed-off-by: Frederic Weisbecker <fweisbec@...il.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Ingo Molnar <mingo@...e.hu>
> Cc: John Kacur <jkacur@...hat.com>
> Cc: Sven-Thorsten Dietrich <sven@...bigcorporation.com>
> Cc: Jonathan Corbet <corbet@....net>
> Cc: Alessio Igor Bogani <abogani@...ware.it>
> ---
> drivers/char/mem.c | 16 +++++-----------
> 1 files changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/char/mem.c b/drivers/char/mem.c
> index a074fce..599846a 100644
> --- a/drivers/char/mem.c
> +++ b/drivers/char/mem.c
> @@ -892,29 +892,23 @@ static int memory_open(struct inode *inode, struct file *filp)
> {
> int minor;
> const struct memdev *dev;
> - int ret = -ENXIO;
> -
> - lock_kernel();
>
> minor = iminor(inode);
> if (minor >= ARRAY_SIZE(devlist))
> - goto out;
> + return -ENXIO;
>
> dev = &devlist[minor];
> if (!dev->fops)
> - goto out;
> + return -ENXIO;
>
> filp->f_op = dev->fops;
> if (dev->dev_info)
> filp->f_mapping->backing_dev_info = dev->dev_info;
>
> if (dev->fops->open)
> - ret = dev->fops->open(inode, filp);
> - else
> - ret = 0;
> -out:
> - unlock_kernel();
> - return ret;
> + return dev->fops->open(inode, filp);
> +
> + return 0;
> }
>
> static const struct file_operations memory_fops = {
> --
> 1.6.2.3
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists