2007-06-20 20:12:55

by Jack Stone

[permalink] [raw]
Subject: Spinlock init

Dear list,

can rwlock_init and spin_lock_init be used outside of functions declared
__init. The spinlock documentation suggests that it can't but I'd like
someone to confirm that.

Sorry if this has already been answered but I couldn't find anything on it.

Jack


2007-06-20 20:29:35

by Roland Dreier

[permalink] [raw]
Subject: Re: Spinlock init

> can rwlock_init and spin_lock_init be used outside of functions declared
> __init. The spinlock documentation suggests that it can't but I'd like
> someone to confirm that.

Those function can be used in any function. A function is declared
__init if it only runs during the kernel startup, so that the memory
holding the code for __init functions can be freed once startup is
done. However, spin_lock_init() is just used to initialize a freshly
allocated spinlock, and spinlocks may be allocated at any time, even
long after the kernel is done starting up. A quick look throught
kernel source code will show many, many examples where
spin_lock_init(), rwlock_init(), mutex_init(), etc. are called from
non-__init functions.


- R.

2007-06-20 20:31:47

by Jack Stone

[permalink] [raw]
Subject: Re: Spinlock init

Roland Dreier wrote:
> > can rwlock_init and spin_lock_init be used outside of functions declared
> > __init. The spinlock documentation suggests that it can't but I'd like
> > someone to confirm that.
>
> Those function can be used in any function. A function is declared
> __init if it only runs during the kernel startup, so that the memory
> holding the code for __init functions can be freed once startup is
> done. However, spin_lock_init() is just used to initialize a freshly
> allocated spinlock, and spinlocks may be allocated at any time, even
> long after the kernel is done starting up. A quick look throught
> kernel source code will show many, many examples where
> spin_lock_init(), rwlock_init(), mutex_init(), etc. are called from
> non-__init functions.

Exactly what I wanted to hear. Thank you very much.

Jack