LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "Ed L. Cashin" <ecashin@coraid.com>
Cc: linux-kernel@vger.kernel.org, Greg K-H <greg@kroah.com>
Subject: Re: [PATCH 09/12] remove race between use and initialization of locks
Date: Mon, 2 Jul 2007 21:38:32 -0700 [thread overview]
Message-ID: <20070702213832.8864656c.akpm@linux-foundation.org> (raw)
In-Reply-To: <2823ea0d22cb0a4aea5a5c22bb8e6b63b2b07441.1182883861.git.ecashin@coraid.com>
On Tue, 26 Jun 2007 14:50:12 -0400 "Ed L. Cashin" <ecashin@coraid.com> wrote:
> This change was originally submitted by Alexey Dobriyan in an email
> with ...
>
> Message-ID: <20070325190221.GA5308@martell.zuzino.mipt.ru>
>
> and the comment,
>
> Some drivers do register_chrdev() before lock or semaphore used in
> corresponding file_operations is initialized.
>
> Andrew Morton commented that these locks should be initialized at
> compile time, but Alexey Debriyan pointed out that the Documentation
> tells us to use dynamic initialization whenever possible, and then the
> discussion petered out.
>
> http://preview.tinyurl.com/2pxq6p
>
> I believe we made these locks dynamic because of the notice in
> Documentation/spinlocks.txt, which says that static initializers are
> deprecated:
>
> UPDATE March 21 2005 Amit Gud <gud@eth.net>
>
> Macros SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED are deprecated and will be
> removed soon. So for any new code dynamic initialization should be used:
The document is inaccurate.
Yes, the use of SPIN_LOCK_UNLOCKED should be avoided because it breaks
lockdep. But it can be replaced with DEFINE_SPINLOCK: there is no need to
switch to runtime initialisation.
> ...
>
> In any case, the patch below makes the code correct and in keeping
> with the existing documentation. If the existing docs are wrong, I'd
> be happy to follow up with a patch that corrects them and makes these
> aoechr.c locks static.
>
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> Signed-off-by: Ed L. Cashin <ecashin@coraid.com>
> ---
> drivers/block/aoe/aoechr.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
> index 10b38a7..2b4f873 100644
> --- a/drivers/block/aoe/aoechr.c
> +++ b/drivers/block/aoe/aoechr.c
> @@ -256,13 +256,13 @@ aoechr_init(void)
> {
> int n, i;
>
> + sema_init(&emsgs_sema, 0);
> + spin_lock_init(&emsgs_lock);
> n = register_chrdev(AOE_MAJOR, "aoechr", &aoe_fops);
> if (n < 0) {
> printk(KERN_ERR "aoe: can't register char device\n");
> return n;
> }
> - sema_init(&emsgs_sema, 0);
> - spin_lock_init(&emsgs_lock);
> aoe_class = class_create(THIS_MODULE, "aoe");
> if (IS_ERR(aoe_class)) {
> unregister_chrdev(AOE_MAJOR, "aoechr");
> --
> 1.5.2.1
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2007-07-03 4:38 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-26 18:50 [PATCH 01/12] bring driver version number to 47 Ed L. Cashin
2007-06-26 18:50 ` [PATCH 03/12] mac_addr: avoid 64-bit arch compiler warnings Ed L. Cashin
2007-06-26 18:50 ` [PATCH 02/12] handle multiple network paths to AoE device Ed L. Cashin
2007-07-03 4:29 ` Andrew Morton
2007-07-11 14:46 ` Ed L. Cashin
2007-07-16 22:17 ` [PATCH] stacked ifs (was Re: [PATCH 02/12] handle multiple network paths to AoE device) Ed L. Cashin
2007-07-16 22:31 ` Andrew Morton
2007-07-17 0:01 ` Greg KH
2007-07-18 15:24 ` Jan Engelhardt
2007-06-26 18:50 ` [PATCH 05/12] eliminate goto and improve readability Ed L. Cashin
2007-06-26 18:50 ` [PATCH 07/12] use a dynamic pool of sk_buffs to keep up with fast targets Ed L. Cashin
2007-07-03 4:36 ` Andrew Morton
2007-07-03 4:40 ` David Miller
2007-07-03 18:45 ` Matt Mackall
2007-07-03 19:18 ` Stephen Hemminger
2007-07-06 17:09 ` Ed L. Cashin
2007-06-26 18:50 ` [PATCH 06/12] user can ask driver to forget previously detected devices Ed L. Cashin
2007-06-26 18:50 ` [PATCH 04/12] clean up udev configuration example Ed L. Cashin
2007-06-26 18:50 ` [PATCH 12/12] the aoeminor doesn't need a long format Ed L. Cashin
2007-06-26 19:51 ` Randy Dunlap
2007-06-26 19:59 ` Ed L. Cashin
2007-06-26 18:50 ` [PATCH 10/12] add module parameter for users who need more outstanding I/O Ed L. Cashin
2007-07-03 4:41 ` Andrew Morton
2007-06-26 18:50 ` [PATCH 11/12] remove extra space in prototypes for consistency Ed L. Cashin
2007-06-26 18:50 ` [PATCH 09/12] remove race between use and initialization of locks Ed L. Cashin
2007-07-03 4:38 ` Andrew Morton [this message]
2007-06-26 18:50 ` [PATCH 08/12] only schedule work once Ed L. Cashin
2007-07-03 4:37 ` Andrew Morton
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=20070702213832.8864656c.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=ecashin@coraid.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: [PATCH 09/12] remove race between use and initialization of locks' \
/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
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).