lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20080311103517.5b6dc23f.akpm@linux-foundation.org>
Date:	Tue, 11 Mar 2008 10:35:17 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	"Akinobu Mita" <akinobu.mita@...il.com>
Cc:	nickpiggin@...oo.com.au, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/5] lib: introduce call_once()

On Tue, 11 Mar 2008 21:27:30 +0900
"Akinobu Mita" <akinobu.mita@...il.com> wrote:

> 2008/3/11, Andrew Morton <akpm@...ux-foundation.org>:
> > On Tue, 11 Mar 2008 15:10:52 +1100 Nick Piggin <nickpiggin@...oo.com.au> wrote:
> >
> >  > > #define ONCE()                                              \
> >  > >     ({                                              \
> >  > >             static long flag;                       \
> >  > >                                                     \
> >  > >             return !test_and_set_bit(0, flag);      \
> >  > >     })
> >  > >
> >  > > and then callers can do
> >  > >
> >  > >     if (ONCE())
> >  > >             do_something();
> >  > >
> >  > > ?
> 
> This cannot be used directly in the conversions of patch 2 - 5.
> Because the callers of call_once() in patch 2 - 5 need to wait for the
> complition of "init_routine". Some blocking mechanism is needed.

Of course it can be used in those places.  Here's the idr.c conversion:

--- a/lib/idr.c~a
+++ a/lib/idr.c
@@ -585,14 +585,6 @@ static void idr_cache_ctor(struct kmem_c
 	memset(idr_layer, 0, sizeof(struct idr_layer));
 }
 
-static  int init_id_cache(void)
-{
-	if (!idr_layer_cache)
-		idr_layer_cache = kmem_cache_create("idr_layer_cache",
-			sizeof(struct idr_layer), 0, 0, idr_cache_ctor);
-	return 0;
-}
-
 /**
  * idr_init - initialize idr handle
  * @idp:	idr handle
@@ -602,7 +594,9 @@ static  int init_id_cache(void)
  */
 void idr_init(struct idr *idp)
 {
-	init_id_cache();
+	if (ONCE())
+		idr_layer_cache = kmem_cache_create("idr_layer_cache",
+			sizeof(struct idr_layer), 0, 0, idr_cache_ctor);
 	memset(idp, 0, sizeof(struct idr));
 	spin_lock_init(&idp->lock);
 }


--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ