All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/smp: Do not BUG_ON if invalid CPU during kick
@ 2017-06-24  9:16 Santosh Sivaraj
  2017-06-26 12:49 ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Santosh Sivaraj @ 2017-06-24  9:16 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: arnd, benh, mpe, ego

During secondary start, we do not need to BUG_ON if an invalid CPU number
is passed. We alreay print an error if secondary cannot be started, so
just return an error instead.

Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
 arch/powerpc/kernel/smp.c            | 3 ++-
 arch/powerpc/platforms/cell/smp.c    | 3 ++-
 arch/powerpc/platforms/powernv/smp.c | 3 ++-
 arch/powerpc/platforms/pseries/smp.c | 3 ++-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index df2a416..05bf583 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -112,7 +112,8 @@ int smp_generic_cpu_bootable(unsigned int nr)
 #ifdef CONFIG_PPC64
 int smp_generic_kick_cpu(int nr)
 {
-	BUG_ON(nr < 0 || nr >= NR_CPUS);
+	if (nr < 0 || nr >= NR_CPUS)
+		return -EINVAL;
 
 	/*
 	 * The processor is currently spinning, waiting for the
diff --git a/arch/powerpc/platforms/cell/smp.c b/arch/powerpc/platforms/cell/smp.c
index 895560f..ee8c535 100644
--- a/arch/powerpc/platforms/cell/smp.c
+++ b/arch/powerpc/platforms/cell/smp.c
@@ -115,7 +115,8 @@ static void smp_cell_setup_cpu(int cpu)
 
 static int smp_cell_kick_cpu(int nr)
 {
-	BUG_ON(nr < 0 || nr >= NR_CPUS);
+	if (nr < 0 || nr >= NR_CPUS)
+		return -EINVAL;
 
 	if (!smp_startup_cpu(nr))
 		return -ENOENT;
diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
index c04c87a..292825f 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -63,7 +63,8 @@ static int pnv_smp_kick_cpu(int nr)
 	long rc;
 	uint8_t status;
 
-	BUG_ON(nr < 0 || nr >= NR_CPUS);
+	if (nr < 0 || nr >= NR_CPUS)
+		return -EINVAL;
 
 	/*
 	 * If we already started or OPAL is not supported, we just
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index 52ca6b3..c82182a 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -151,7 +151,8 @@ static void smp_setup_cpu(int cpu)
 
 static int smp_pSeries_kick_cpu(int nr)
 {
-	BUG_ON(nr < 0 || nr >= NR_CPUS);
+	if (nr < 0 || nr >= NR_CPUS)
+		return -EINVAL;
 
 	if (!smp_startup_cpu(nr))
 		return -ENOENT;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] powerpc/smp: Do not BUG_ON if invalid CPU during kick
  2017-06-24  9:16 [PATCH] powerpc/smp: Do not BUG_ON if invalid CPU during kick Santosh Sivaraj
@ 2017-06-26 12:49 ` Michael Ellerman
  2017-06-27  7:00   ` [PATCH 1/2] " Santosh Sivaraj
  2017-06-27  7:00   ` [PATCH 2/2] powerpc/smp: Convert NR_CPUS to nr_cpu_ids Santosh Sivaraj
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Ellerman @ 2017-06-26 12:49 UTC (permalink / raw)
  To: Santosh Sivaraj, linuxppc-dev; +Cc: arnd, benh, ego

Santosh Sivaraj <santosh@fossix.org> writes:

> During secondary start, we do not need to BUG_ON if an invalid CPU number
> is passed. We alreay print an error if secondary cannot be started, so
                    ^
                    d
> just return an error instead.
>
> Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
> ---
>  arch/powerpc/kernel/smp.c            | 3 ++-
>  arch/powerpc/platforms/cell/smp.c    | 3 ++-
>  arch/powerpc/platforms/powernv/smp.c | 3 ++-
>  arch/powerpc/platforms/pseries/smp.c | 3 ++-

This looks good to me ...

> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index df2a416..05bf583 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -112,7 +112,8 @@ int smp_generic_cpu_bootable(unsigned int nr)
>  #ifdef CONFIG_PPC64
>  int smp_generic_kick_cpu(int nr)
>  {
> -	BUG_ON(nr < 0 || nr >= NR_CPUS);
> +	if (nr < 0 || nr >= NR_CPUS)
> +		return -EINVAL;

Except that these checks should all use nr_cpu_ids AFAICS.

I think they were just written before nr_cpu_ids existed.

Can you send me an incremental patch to switch them to nr_cpu_ids?

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] powerpc/smp: Do not BUG_ON if invalid CPU during kick
  2017-06-26 12:49 ` Michael Ellerman
@ 2017-06-27  7:00   ` Santosh Sivaraj
  2017-06-29 12:21     ` [1/2] " Michael Ellerman
  2017-06-27  7:00   ` [PATCH 2/2] powerpc/smp: Convert NR_CPUS to nr_cpu_ids Santosh Sivaraj
  1 sibling, 1 reply; 5+ messages in thread
From: Santosh Sivaraj @ 2017-06-27  7:00 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

During secondary start, we do not need to BUG_ON if an invalid CPU number
is passed. We already print an error if secondary cannot be started, so
just return an error instead.

Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
 arch/powerpc/kernel/smp.c            | 3 ++-
 arch/powerpc/platforms/cell/smp.c    | 3 ++-
 arch/powerpc/platforms/powernv/smp.c | 3 ++-
 arch/powerpc/platforms/pseries/smp.c | 3 ++-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index df2a416..05bf583 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -112,7 +112,8 @@ int smp_generic_cpu_bootable(unsigned int nr)
 #ifdef CONFIG_PPC64
 int smp_generic_kick_cpu(int nr)
 {
-	BUG_ON(nr < 0 || nr >= NR_CPUS);
+	if (nr < 0 || nr >= NR_CPUS)
+		return -EINVAL;
 
 	/*
 	 * The processor is currently spinning, waiting for the
diff --git a/arch/powerpc/platforms/cell/smp.c b/arch/powerpc/platforms/cell/smp.c
index 895560f..ee8c535 100644
--- a/arch/powerpc/platforms/cell/smp.c
+++ b/arch/powerpc/platforms/cell/smp.c
@@ -115,7 +115,8 @@ static void smp_cell_setup_cpu(int cpu)
 
 static int smp_cell_kick_cpu(int nr)
 {
-	BUG_ON(nr < 0 || nr >= NR_CPUS);
+	if (nr < 0 || nr >= NR_CPUS)
+		return -EINVAL;
 
 	if (!smp_startup_cpu(nr))
 		return -ENOENT;
diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
index c04c87a..292825f 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -63,7 +63,8 @@ static int pnv_smp_kick_cpu(int nr)
 	long rc;
 	uint8_t status;
 
-	BUG_ON(nr < 0 || nr >= NR_CPUS);
+	if (nr < 0 || nr >= NR_CPUS)
+		return -EINVAL;
 
 	/*
 	 * If we already started or OPAL is not supported, we just
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index 52ca6b3..c82182a 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -151,7 +151,8 @@ static void smp_setup_cpu(int cpu)
 
 static int smp_pSeries_kick_cpu(int nr)
 {
-	BUG_ON(nr < 0 || nr >= NR_CPUS);
+	if (nr < 0 || nr >= NR_CPUS)
+		return -EINVAL;
 
 	if (!smp_startup_cpu(nr))
 		return -ENOENT;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] powerpc/smp: Convert NR_CPUS to nr_cpu_ids
  2017-06-26 12:49 ` Michael Ellerman
  2017-06-27  7:00   ` [PATCH 1/2] " Santosh Sivaraj
@ 2017-06-27  7:00   ` Santosh Sivaraj
  1 sibling, 0 replies; 5+ messages in thread
From: Santosh Sivaraj @ 2017-06-27  7:00 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

nr_cpu_ids can be limited by nr_cpus boot parameter, whereas NR_CPUS is a
compile time constant, which shouldn't be compared against during cpu kick.

Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
 arch/powerpc/kernel/smp.c            | 2 +-
 arch/powerpc/platforms/cell/smp.c    | 2 +-
 arch/powerpc/platforms/powernv/smp.c | 2 +-
 arch/powerpc/platforms/pseries/smp.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 05bf583..4180197 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -112,7 +112,7 @@ int smp_generic_cpu_bootable(unsigned int nr)
 #ifdef CONFIG_PPC64
 int smp_generic_kick_cpu(int nr)
 {
-	if (nr < 0 || nr >= NR_CPUS)
+	if (nr < 0 || nr >= nr_cpu_ids)
 		return -EINVAL;
 
 	/*
diff --git a/arch/powerpc/platforms/cell/smp.c b/arch/powerpc/platforms/cell/smp.c
index ee8c535..f84d52a 100644
--- a/arch/powerpc/platforms/cell/smp.c
+++ b/arch/powerpc/platforms/cell/smp.c
@@ -115,7 +115,7 @@ static void smp_cell_setup_cpu(int cpu)
 
 static int smp_cell_kick_cpu(int nr)
 {
-	if (nr < 0 || nr >= NR_CPUS)
+	if (nr < 0 || nr >= nr_cpu_ids)
 		return -EINVAL;
 
 	if (!smp_startup_cpu(nr))
diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
index 292825f..40dae96 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -63,7 +63,7 @@ static int pnv_smp_kick_cpu(int nr)
 	long rc;
 	uint8_t status;
 
-	if (nr < 0 || nr >= NR_CPUS)
+	if (nr < 0 || nr >= nr_cpu_ids)
 		return -EINVAL;
 
 	/*
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index c82182a..24785f6 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -151,7 +151,7 @@ static void smp_setup_cpu(int cpu)
 
 static int smp_pSeries_kick_cpu(int nr)
 {
-	if (nr < 0 || nr >= NR_CPUS)
+	if (nr < 0 || nr >= nr_cpu_ids)
 		return -EINVAL;
 
 	if (!smp_startup_cpu(nr))
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [1/2] powerpc/smp: Do not BUG_ON if invalid CPU during kick
  2017-06-27  7:00   ` [PATCH 1/2] " Santosh Sivaraj
@ 2017-06-29 12:21     ` Michael Ellerman
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2017-06-29 12:21 UTC (permalink / raw)
  To: Santosh Sivaraj; +Cc: linuxppc-dev

On Tue, 2017-06-27 at 07:00:05 UTC, Santosh Sivaraj wrote:
> During secondary start, we do not need to BUG_ON if an invalid CPU number
> is passed. We already print an error if secondary cannot be started, so
> just return an error instead.
> 
> Signed-off-by: Santosh Sivaraj <santosh@fossix.org>

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/f8d0d5dc641cd405ad40cb2498b04d

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-06-29 12:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-24  9:16 [PATCH] powerpc/smp: Do not BUG_ON if invalid CPU during kick Santosh Sivaraj
2017-06-26 12:49 ` Michael Ellerman
2017-06-27  7:00   ` [PATCH 1/2] " Santosh Sivaraj
2017-06-29 12:21     ` [1/2] " Michael Ellerman
2017-06-27  7:00   ` [PATCH 2/2] powerpc/smp: Convert NR_CPUS to nr_cpu_ids Santosh Sivaraj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.