* [KJ]remove SPIN_LOCK_UNLOCKED
@ 2007-04-10 18:16 Milind Arun Choudhary
2007-04-10 20:50 ` Jan Engelhardt
0 siblings, 1 reply; 11+ messages in thread
From: Milind Arun Choudhary @ 2007-04-10 18:16 UTC (permalink / raw)
To: kernel-janitors; +Cc: kernelnewbies, linux-kernel
"use spin_lock_init instead of SPIN_LOCK_UNLOCKED"
i'm a bit confused with SPIN_LOCK_UNLOCKED removal
I just did the below mentioned change
but then came to know that spin_lock_init is defined as
# define spin_lock_init(lock) \
do { *(lock) = SPIN_LOCK_UNLOCKED; } while (0)
so what difference does it make..
eventually replacing SPIN_LOCK_UNLOCKED with itself
or is it just that this one [SPIN_LOCK_UNLOCKED] also needs
to be replaced with __SPIN_LOCK_UNLOCKED?
after thought with CONFIG_DEBUG_SPINLOCK does make a diff
let me know if this is fine ..
aerdrv.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
index db6ad8e..6846fb4 100644
--- a/drivers/pci/pcie/aer/aerdrv.c
+++ b/drivers/pci/pcie/aer/aerdrv.c
@@ -157,7 +157,7 @@ static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev)
* Initialize Root lock access, e_lock, to Root Error Status Reg,
* Root Error ID Reg, and Root error producer/consumer index.
*/
- rpc->e_lock = SPIN_LOCK_UNLOCKED;
+ spin_lock_init(&rpc->e_lock);
rpc->rpd = dev;
INIT_WORK(&rpc->dpc_handler, aer_isr);
--
Milind Arun Choudhary
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [KJ]remove SPIN_LOCK_UNLOCKED
2007-04-10 18:16 [KJ]remove SPIN_LOCK_UNLOCKED Milind Arun Choudhary
@ 2007-04-10 20:50 ` Jan Engelhardt
2007-04-10 21:13 ` Roland Dreier
2007-04-10 21:25 ` Robert P. J. Day
0 siblings, 2 replies; 11+ messages in thread
From: Jan Engelhardt @ 2007-04-10 20:50 UTC (permalink / raw)
To: Milind Arun Choudhary; +Cc: kernel-janitors, kernelnewbies, linux-kernel
On Apr 10 2007 23:46, Milind Arun Choudhary wrote:
>"use spin_lock_init instead of SPIN_LOCK_UNLOCKED"
Fact is, we cannot remove SPIN_LOCK_UNLOCKED. It's needed for
variables outside functions:
static spinlock_t foobar = SPIN_LOCK_UNLOCKED;
>let me know if this is fine ..
not for me to comment :)
> aerdrv.c | 2 +-
> 1 files changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
>index db6ad8e..6846fb4 100644
>--- a/drivers/pci/pcie/aer/aerdrv.c
>+++ b/drivers/pci/pcie/aer/aerdrv.c
>@@ -157,7 +157,7 @@ static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev)
> * Initialize Root lock access, e_lock, to Root Error Status Reg,
> * Root Error ID Reg, and Root error producer/consumer index.
> */
>- rpc->e_lock = SPIN_LOCK_UNLOCKED;
>+ spin_lock_init(&rpc->e_lock);
>
> rpc->rpd = dev;
> INIT_WORK(&rpc->dpc_handler, aer_isr);
>
>
>--
>Milind Arun Choudhary
>-
>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/
>
Jan
--
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [KJ]remove SPIN_LOCK_UNLOCKED
2007-04-10 20:50 ` Jan Engelhardt
@ 2007-04-10 21:13 ` Roland Dreier
2007-04-10 21:25 ` Robert P. J. Day
1 sibling, 0 replies; 11+ messages in thread
From: Roland Dreier @ 2007-04-10 21:13 UTC (permalink / raw)
To: Jan Engelhardt
Cc: Milind Arun Choudhary, kernel-janitors, kernelnewbies,
linux-kernel
> Fact is, we cannot remove SPIN_LOCK_UNLOCKED. It's needed for
> variables outside functions:
>
> static spinlock_t foobar = SPIN_LOCK_UNLOCKED;
DEFINE_SPINLOCK() is provided to define variables that way.
- R.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [KJ]remove SPIN_LOCK_UNLOCKED
2007-04-10 20:50 ` Jan Engelhardt
2007-04-10 21:13 ` Roland Dreier
@ 2007-04-10 21:25 ` Robert P. J. Day
2007-04-10 21:28 ` Jan Engelhardt
1 sibling, 1 reply; 11+ messages in thread
From: Robert P. J. Day @ 2007-04-10 21:25 UTC (permalink / raw)
To: Jan Engelhardt
Cc: Milind Arun Choudhary, kernel-janitors, kernelnewbies,
linux-kernel
On Tue, 10 Apr 2007, Jan Engelhardt wrote:
>
> On Apr 10 2007 23:46, Milind Arun Choudhary wrote:
>
> >"use spin_lock_init instead of SPIN_LOCK_UNLOCKED"
>
> Fact is, we cannot remove SPIN_LOCK_UNLOCKED. It's needed for
> variables outside functions:
>
> static spinlock_t foobar = SPIN_LOCK_UNLOCKED;
but that's where you would use the more explicit
__RAW_SPIN_LOCK_UNLOCKED, no? AFAIK, you really can remove the macro
SPIN_LOCK_UNLOCKED in its entirety.
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [KJ]remove SPIN_LOCK_UNLOCKED
2007-04-10 21:25 ` Robert P. J. Day
@ 2007-04-10 21:28 ` Jan Engelhardt
2007-04-10 21:42 ` Roland Dreier
0 siblings, 1 reply; 11+ messages in thread
From: Jan Engelhardt @ 2007-04-10 21:28 UTC (permalink / raw)
To: Robert P. J. Day
Cc: Milind Arun Choudhary, kernel-janitors, kernelnewbies,
linux-kernel
On Apr 10 2007 17:25, Robert P. J. Day wrote:
>On Tue, 10 Apr 2007, Jan Engelhardt wrote:
>> On Apr 10 2007 23:46, Milind Arun Choudhary wrote:
>>
>> >"use spin_lock_init instead of SPIN_LOCK_UNLOCKED"
>>
>> Fact is, we cannot remove SPIN_LOCK_UNLOCKED. It's needed for
>> variables outside functions:
>>
>> static spinlock_t foobar = SPIN_LOCK_UNLOCKED;
>
>but that's where you would use the more explicit
>__RAW_SPIN_LOCK_UNLOCKED, no? AFAIK, you really can remove the macro
>SPIN_LOCK_UNLOCKED in its entirety.
I don't remember LDD speaking about __RAW_*. (And other than not
having looked into the code to date, I don't know the difference.)
Jan
--
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [KJ]remove SPIN_LOCK_UNLOCKED
2007-04-10 21:28 ` Jan Engelhardt
@ 2007-04-10 21:42 ` Roland Dreier
2007-04-10 21:45 ` Robert P. J. Day
0 siblings, 1 reply; 11+ messages in thread
From: Roland Dreier @ 2007-04-10 21:42 UTC (permalink / raw)
To: Jan Engelhardt
Cc: Robert P. J. Day, Milind Arun Choudhary, kernel-janitors,
kernelnewbies, linux-kernel
> >but that's where you would use the more explicit
> >__RAW_SPIN_LOCK_UNLOCKED, no? AFAIK, you really can remove the macro
> >SPIN_LOCK_UNLOCKED in its entirety.
>
> I don't remember LDD speaking about __RAW_*. (And other than not
> having looked into the code to date, I don't know the difference.)
Don't worry about the __RAW_SPIN_LOCK_UNLOCKED stuff, that's obviously
not for generic code to use. The right answer (as I said before) is
to use DEFINE_SPINLOCK().
- R.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [KJ]remove SPIN_LOCK_UNLOCKED
2007-04-10 21:42 ` Roland Dreier
@ 2007-04-10 21:45 ` Robert P. J. Day
2007-04-10 21:58 ` Roland Dreier
2007-04-10 22:08 ` [KJ] remove SPIN_LOCK_UNLOCKED Matthew Wilcox
0 siblings, 2 replies; 11+ messages in thread
From: Robert P. J. Day @ 2007-04-10 21:45 UTC (permalink / raw)
To: Roland Dreier
Cc: Jan Engelhardt, Milind Arun Choudhary, kernel-janitors,
kernelnewbies, linux-kernel
On Tue, 10 Apr 2007, Roland Dreier wrote:
> > >but that's where you would use the more explicit
> > >__RAW_SPIN_LOCK_UNLOCKED, no? AFAIK, you really can remove the macro
> > >SPIN_LOCK_UNLOCKED in its entirety.
> >
> > I don't remember LDD speaking about __RAW_*. (And other than not
> > having looked into the code to date, I don't know the difference.)
>
> Don't worry about the __RAW_SPIN_LOCK_UNLOCKED stuff, that's
> obviously not for generic code to use. The right answer (as I said
> before) is to use DEFINE_SPINLOCK().
that works fine if you're defining a single spinlock, but what do you
do in cases like this:
arch/sparc/lib/atomic32.c: [0 ... (ATOMIC_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED
that is, when you're assigning an array of them? you still need some
kind of generic, unnamed spinlock in those circumstances, no?
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [KJ]remove SPIN_LOCK_UNLOCKED
2007-04-10 21:45 ` Robert P. J. Day
@ 2007-04-10 21:58 ` Roland Dreier
2007-04-10 22:08 ` [KJ] remove SPIN_LOCK_UNLOCKED Matthew Wilcox
1 sibling, 0 replies; 11+ messages in thread
From: Roland Dreier @ 2007-04-10 21:58 UTC (permalink / raw)
To: Robert P. J. Day
Cc: Jan Engelhardt, Milind Arun Choudhary, kernel-janitors,
kernelnewbies, linux-kernel
> > Don't worry about the __RAW_SPIN_LOCK_UNLOCKED stuff, that's
> > obviously not for generic code to use. The right answer (as I said
> > before) is to use DEFINE_SPINLOCK().
>
> that works fine if you're defining a single spinlock, but what do you
> do in cases like this:
>
> arch/sparc/lib/atomic32.c: [0 ... (ATOMIC_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED
>
> that is, when you're assigning an array of them? you still need some
> kind of generic, unnamed spinlock in those circumstances, no?
Wow, I didn't realize there was code doing that. I guess for that
handful of cases, you indeed would probably want to convert them to
raw_spinlock_t and use __RAW_SPIN_LOCK_UNLOCKED. But in the vast
majority of cases, DEFINE_SPINLOCK() is the right think to do.
- R.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [KJ] remove SPIN_LOCK_UNLOCKED
2007-04-10 21:45 ` Robert P. J. Day
2007-04-10 21:58 ` Roland Dreier
@ 2007-04-10 22:08 ` Matthew Wilcox
2007-04-11 4:09 ` Milind Arun Choudhary
2007-04-11 5:47 ` Robert P. J. Day
1 sibling, 2 replies; 11+ messages in thread
From: Matthew Wilcox @ 2007-04-10 22:08 UTC (permalink / raw)
To: Robert P. J. Day
Cc: Roland Dreier, kernelnewbies, kernel-janitors, Jan Engelhardt,
linux-kernel
On Tue, Apr 10, 2007 at 05:45:07PM -0400, Robert P. J. Day wrote:
> that works fine if you're defining a single spinlock, but what do you
> do in cases like this:
>
> arch/sparc/lib/atomic32.c: [0 ... (ATOMIC_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED
>
> that is, when you're assigning an array of them? you still need some
> kind of generic, unnamed spinlock in those circumstances, no?
That's a special case for architecture-only code. It's not to be used
by drivers.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [KJ] remove SPIN_LOCK_UNLOCKED
2007-04-10 22:08 ` [KJ] remove SPIN_LOCK_UNLOCKED Matthew Wilcox
@ 2007-04-11 4:09 ` Milind Arun Choudhary
2007-04-11 5:47 ` Robert P. J. Day
1 sibling, 0 replies; 11+ messages in thread
From: Milind Arun Choudhary @ 2007-04-11 4:09 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Robert P. J. Day, kernelnewbies, kernel-janitors, Roland Dreier,
Jan Engelhardt, linux-kernel
On 4/11/07, Matthew Wilcox <matthew@wil.cx> wrote:
> On Tue, Apr 10, 2007 at 05:45:07PM -0400, Robert P. J. Day wrote:
> > that works fine if you're defining a single spinlock, but what do you
> > do in cases like this:
> >
> > arch/sparc/lib/atomic32.c: [0 ... (ATOMIC_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED
> >
> > that is, when you're assigning an array of them? you still need some
> > kind of generic, unnamed spinlock in those circumstances, no?
>
> That's a special case for architecture-only code. It's not to be used
> by drivers.
as per my understanding, [which i should have keyed in earlier]
different places where SPIN_LOCK_UNLOCKED currently appears are
1. static spinlock_t foobar = SPIN_LOCK_UNLOCKED;
needs to be replaced bye DEFINE_SPINLOCK
e.g linux-core/drm_memory_debug.h
-static spinlock_t drm_mem_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(drm_mem_lock);
there are very few occurrences left in the tree i see
2. allocating a data structure dynamically
& initializing the spinlock embedded within
use spin_lock_init()
e.g linux-core/via_dmablit.c
- blitq->blit_lock = SPIN_LOCK_UNLOCKED;
+ spin_lock_init(&blitq->blit_lock);
3. static initialization of structure members
struct foo bar ={
.
.
.
.lock = SPIN_LOCK_UNLOCKED,
.
}
use
struct foo bar ={
.
.
.
.lock = __SPIN_LOCK_UNLOCKED(bar.lock),
.
}
e.g arch/i386/kernel/traps.c
- .lock = SPIN_LOCK_UNLOCKED,
+ .lock = __SPIN_LOCK_UNLOCKED(die.lock),
plenty of these are still there
may be some patches queued
4. arrays of spinlocks
e.g arch/cris/arch-v32/kernel/smp.c
-spinlock_t cris_atomic_locks[] = { [0 ... LOCK_COUNT - 1] =
SPIN_LOCK_UNLOCKED};
+raw_spinlock_t cris_atomic_locks[] = { [0 ... LOCK_COUNT - 1] =
__RAW_SPIN_LOCK_UNLOCKED};
my question is still there in the original post
about spin_lock_init()
CMIIW
Refer:
http://lkml.org/lkml/2005/6/20/47
http://lkml.org/lkml/2007/1/16/90
http://lists.openwall.net/linux-kernel/2007/02/01/258
--
Milind Arun Choudhary
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [KJ] remove SPIN_LOCK_UNLOCKED
2007-04-10 22:08 ` [KJ] remove SPIN_LOCK_UNLOCKED Matthew Wilcox
2007-04-11 4:09 ` Milind Arun Choudhary
@ 2007-04-11 5:47 ` Robert P. J. Day
1 sibling, 0 replies; 11+ messages in thread
From: Robert P. J. Day @ 2007-04-11 5:47 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Roland Dreier, kernelnewbies, kernel-janitors, Jan Engelhardt,
linux-kernel
On Tue, 10 Apr 2007, Matthew Wilcox wrote:
> On Tue, Apr 10, 2007 at 05:45:07PM -0400, Robert P. J. Day wrote:
> > that works fine if you're defining a single spinlock, but what do you
> > do in cases like this:
> >
> > arch/sparc/lib/atomic32.c: [0 ... (ATOMIC_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED
> >
> > that is, when you're assigning an array of them? you still need
> > some kind of generic, unnamed spinlock in those circumstances, no?
>
> That's a special case for architecture-only code. It's not to be
> used by drivers.
be that as it may, it still means you need to take it into account
whenever someone says they want to entirely remove the
SPIN_LOCK_UNLOCKED macro from the source tree, as suggested in
Documentation/spinlocks.txt.
if you do that removal, you can always replace SPIN_LOCK_UNLOCKED with
its current definition of __SPIN_LOCK_UNLOCKED(old_style_spin_init),
or what have you. but you would obviously have to replace it with
*something* that represents an unnamed spinlock if SPIN_LOCK_UNLOCKED
goes away.
rday
p.s. just FYI:
$ grep -r "\.\.\..*SPIN_LOCK_UNLOCKED" *
arch/sparc/lib/atomic32.c: [0 ... (ATOMIC_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED
arch/cris/arch-v32/kernel/smp.c:spinlock_t cris_atomic_locks[] = { [0 ... LOCK_COUNT - 1] = SPIN_LOCK_UNLOCKED};
arch/parisc/lib/bitops.c: [0 ... (ATOMIC_HASH_SIZE-1)] = __RAW_SPIN_LOCK_UNLOCKED
arch/mips/kernel/gdb-stub.c: [0 ... NR_CPUS-1] = __RAW_SPIN_LOCK_UNLOCKED,
arch/powerpc/platforms/iseries/htab.c: { [0 ... 63] = SPIN_LOCK_UNLOCKED};
so, as matthew says, it's clearly not for drivers.
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-04-11 5:48 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-10 18:16 [KJ]remove SPIN_LOCK_UNLOCKED Milind Arun Choudhary
2007-04-10 20:50 ` Jan Engelhardt
2007-04-10 21:13 ` Roland Dreier
2007-04-10 21:25 ` Robert P. J. Day
2007-04-10 21:28 ` Jan Engelhardt
2007-04-10 21:42 ` Roland Dreier
2007-04-10 21:45 ` Robert P. J. Day
2007-04-10 21:58 ` Roland Dreier
2007-04-10 22:08 ` [KJ] remove SPIN_LOCK_UNLOCKED Matthew Wilcox
2007-04-11 4:09 ` Milind Arun Choudhary
2007-04-11 5:47 ` Robert P. J. Day
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox