2012-05-17 10:15:27

by Yong Zhang

[permalink] [raw]
Subject: [PATCH -rt] MIPS: Octeon: convert smp_reserve_lock to raw spinlock

From: Yong Zhang <[email protected]>

Because __cpu_disable is called in atomic context and spinlock
is a mutex on -rt.

Signed-off-by: Yong Zhang <[email protected]>
---
arch/mips/cavium-octeon/smp.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c
index ef9c34a..473c72b 100644
--- a/arch/mips/cavium-octeon/smp.c
+++ b/arch/mips/cavium-octeon/smp.c
@@ -257,7 +257,7 @@ DEFINE_PER_CPU(int, cpu_state);

extern void fixup_irqs(void);

-static DEFINE_SPINLOCK(smp_reserve_lock);
+static DEFINE_RAW_SPINLOCK(smp_reserve_lock);

static int octeon_cpu_disable(void)
{
@@ -266,7 +266,7 @@ static int octeon_cpu_disable(void)
if (cpu == 0)
return -EBUSY;

- spin_lock(&smp_reserve_lock);
+ raw_spin_lock(&smp_reserve_lock);

set_cpu_online(cpu, false);
cpu_clear(cpu, cpu_callin_map);
@@ -277,7 +277,7 @@ static int octeon_cpu_disable(void)
flush_cache_all();
local_flush_tlb_all();

- spin_unlock(&smp_reserve_lock);
+ raw_spin_unlock(&smp_reserve_lock);

return 0;
}
--
1.7.1


2012-05-17 16:30:52

by David Daney

[permalink] [raw]
Subject: Re: [PATCH -rt] MIPS: Octeon: convert smp_reserve_lock to raw spinlock

On 05/17/2012 03:15 AM, Yong Zhang wrote:
> From: Yong Zhang<[email protected]>
>
> Because __cpu_disable is called in atomic context and spinlock
> is a mutex on -rt.
>
> Signed-off-by: Yong Zhang<[email protected]>
> ---
> arch/mips/cavium-octeon/smp.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c
> index ef9c34a..473c72b 100644
> --- a/arch/mips/cavium-octeon/smp.c
> +++ b/arch/mips/cavium-octeon/smp.c
> @@ -257,7 +257,7 @@ DEFINE_PER_CPU(int, cpu_state);
>
> extern void fixup_irqs(void);
>
> -static DEFINE_SPINLOCK(smp_reserve_lock);
> +static DEFINE_RAW_SPINLOCK(smp_reserve_lock);
>

Ralf added this in 773cb77d (MIPS: Cavium: Add CPU hotplugging code.)

I'm not even sure what this lock is supposed to be protecting, so I
would like Ralf to take a look.

You can add an Acked-by: from me for either this patch as is, or if Ralf
thinks it is OK, removing the lock entirely.

In any event we can merge this via Ralf's tree.

Thanks,
David Daney


> static int octeon_cpu_disable(void)
> {
> @@ -266,7 +266,7 @@ static int octeon_cpu_disable(void)
> if (cpu == 0)
> return -EBUSY;
>
> - spin_lock(&smp_reserve_lock);
> + raw_spin_lock(&smp_reserve_lock);
>
> set_cpu_online(cpu, false);
> cpu_clear(cpu, cpu_callin_map);
> @@ -277,7 +277,7 @@ static int octeon_cpu_disable(void)
> flush_cache_all();
> local_flush_tlb_all();
>
> - spin_unlock(&smp_reserve_lock);
> + raw_spin_unlock(&smp_reserve_lock);
>
> return 0;
> }

2012-05-17 20:50:16

by Ralf Baechle

[permalink] [raw]
Subject: Re: [PATCH -rt] MIPS: Octeon: convert smp_reserve_lock to raw spinlock

On Thu, May 17, 2012 at 09:30:42AM -0700, David Daney wrote:
> Date: Thu, 17 May 2012 09:30:42 -0700
> From: David Daney <[email protected]>
> To: Yong Zhang <[email protected]>, [email protected]
> CC: [email protected], [email protected],
> [email protected], [email protected]
> Subject: Re: [PATCH -rt] MIPS: Octeon: convert smp_reserve_lock to raw
> spinlock
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 05/17/2012 03:15 AM, Yong Zhang wrote:
> >From: Yong Zhang<[email protected]>
> >
> >Because __cpu_disable is called in atomic context and spinlock
> >is a mutex on -rt.
> >
> >Signed-off-by: Yong Zhang<[email protected]>
> >---
> > arch/mips/cavium-octeon/smp.c | 6 +++---
> > 1 files changed, 3 insertions(+), 3 deletions(-)
> >
> >diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c
> >index ef9c34a..473c72b 100644
> >--- a/arch/mips/cavium-octeon/smp.c
> >+++ b/arch/mips/cavium-octeon/smp.c
> >@@ -257,7 +257,7 @@ DEFINE_PER_CPU(int, cpu_state);
> >
> > extern void fixup_irqs(void);
> >
> >-static DEFINE_SPINLOCK(smp_reserve_lock);
> >+static DEFINE_RAW_SPINLOCK(smp_reserve_lock);
> >
>
> Ralf added this in 773cb77d (MIPS: Cavium: Add CPU hotplugging code.)
>
> I'm not even sure what this lock is supposed to be protecting, so I
> would like Ralf to take a look.
>
> You can add an Acked-by: from me for either this patch as is, or if
> Ralf thinks it is OK, removing the lock entirely.
>
> In any event we can merge this via Ralf's tree.

The 773cb77d patch has a long history but I think I first worked on it for
Wind River Linux 2.0 which was 2.6.21-based, then broke it out and pushed
it upstream. In 2.6.21 it was probably infected by the the smp_reserve_lock
virus in the s390 code for no good reason. So I agree, the lock can
be dropped and I'm queueing a patch to do so for 3.5.

Ralf

2012-05-18 02:29:47

by Yong Zhang

[permalink] [raw]
Subject: Re: [PATCH -rt] MIPS: Octeon: convert smp_reserve_lock to raw spinlock

On Thu, May 17, 2012 at 10:50:03PM +0200, Ralf Baechle wrote:
> On Thu, May 17, 2012 at 09:30:42AM -0700, David Daney wrote:
> > Date: Thu, 17 May 2012 09:30:42 -0700
> > From: David Daney <[email protected]>
> > To: Yong Zhang <[email protected]>, [email protected]
> > CC: [email protected], [email protected],
> > [email protected], [email protected]
> > Subject: Re: [PATCH -rt] MIPS: Octeon: convert smp_reserve_lock to raw
> > spinlock
> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> >
> > On 05/17/2012 03:15 AM, Yong Zhang wrote:
> > >From: Yong Zhang<[email protected]>
> > >
> > >Because __cpu_disable is called in atomic context and spinlock
> > >is a mutex on -rt.
> > >
> > >Signed-off-by: Yong Zhang<[email protected]>
> > >---
> > > arch/mips/cavium-octeon/smp.c | 6 +++---
> > > 1 files changed, 3 insertions(+), 3 deletions(-)
> > >
> > >diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c
> > >index ef9c34a..473c72b 100644
> > >--- a/arch/mips/cavium-octeon/smp.c
> > >+++ b/arch/mips/cavium-octeon/smp.c
> > >@@ -257,7 +257,7 @@ DEFINE_PER_CPU(int, cpu_state);
> > >
> > > extern void fixup_irqs(void);
> > >
> > >-static DEFINE_SPINLOCK(smp_reserve_lock);
> > >+static DEFINE_RAW_SPINLOCK(smp_reserve_lock);
> > >
> >
> > Ralf added this in 773cb77d (MIPS: Cavium: Add CPU hotplugging code.)
> >
> > I'm not even sure what this lock is supposed to be protecting, so I
> > would like Ralf to take a look.
> >
> > You can add an Acked-by: from me for either this patch as is, or if
> > Ralf thinks it is OK, removing the lock entirely.
> >
> > In any event we can merge this via Ralf's tree.
>
> The 773cb77d patch has a long history but I think I first worked on it for
> Wind River Linux 2.0 which was 2.6.21-based, then broke it out and pushed
> it upstream. In 2.6.21 it was probably infected by the the smp_reserve_lock
> virus in the s390 code for no good reason. So I agree, the lock can
> be dropped and I'm queueing a patch to do so for 3.5.

I'm OK with dropping it ;-)

Thanks,
Yong