mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
To: xiaomin1 <xiaoming.wang@intel.com>
Cc: arnd@arndb.de, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, chuansheng.liu@intel.com,
	Zhang Dongxing <dongxing.zhang@intel.com>
Subject: Re: [PATCH] move file->f_op->open out of mutex (misc_mtx) in misc_open
Date: Mon, 5 Jan 2015 13:58:27 +0000	[thread overview]
Message-ID: <20150105135827.31dd0201@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <1420504447-9670-1-git-send-email-xiaoming.wang@intel.com>

On Tue,  6 Jan 2015 08:34:07 +0800
xiaomin1 <xiaoming.wang@intel.com> wrote:

> misc_mtx was used to mutex misc_list.
> But file->f_op->open may be blocked by downloading
> firmware in some devices' open.
> So move file->f_op->open out of mutex (misc_mtx)
> in misc_open to avoid this block.
> It also make code more efficiency.
> 
> Signed-off-by: Zhang Dongxing <dongxing.zhang@intel.com>
> Signed-off-by: xiaoming wang <xiaoming.wang@intel.com>
> ---
>  drivers/char/misc.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/misc.c b/drivers/char/misc.c
> index ffa97d2..289c59e 100644
> --- a/drivers/char/misc.c
> +++ b/drivers/char/misc.c
> @@ -144,7 +144,8 @@ static int misc_open(struct inode * inode, struct file * file)
>  	replace_fops(file, new_fops);
>  	if (file->f_op->open) {
>  		file->private_data = c;
> -		err = file->f_op->open(inode,file);
> +		mutex_unlock(&misc_mtx);
> +		return file->f_op->open(inode,file);
>  	}

This changes all the users of misc device open from singlethreaded to
multi-threaded. Having read through the users I can find this seems safe
and they all seem to have the right checks in place and to assume they
are multi-threaded.

Reviewed-by: Alan Cox <alan@linux.intel.com>

  reply	other threads:[~2015-01-05 13:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-06  0:34 xiaomin1
2015-01-05 13:58 ` One Thousand Gnomes [this message]
2015-01-09 22:47 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2015-01-05  9:14 Hillf Danton

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=20150105135827.31dd0201@lxorguk.ukuu.org.uk \
    --to=gnomes@lxorguk.ukuu.org.uk \
    --cc=arnd@arndb.de \
    --cc=chuansheng.liu@intel.com \
    --cc=dongxing.zhang@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiaoming.wang@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

all inboxes | Powered by JetHome®