Skip to contentSkip to conversation

powerpc/mpic: Disable preemption when calling mpic_processor_id()

PATCH In review Scott Wood 2 participants 5 messages Sep 27, 2013 PowerPC

lore
Share & tools
lore

Scott Wood

author
#0 lore raw

PATCH 1/1 powerpc/mpic: Disable preemption when calling mpic_processor_id()

Otherwise, we get a debug traceback due to the use of smp_processor_id() (or get_paca()) inside hard_smp_processor_id(). mpic_host_map() is just looking for a default CPU, so it doesn't matter if we migrate after getting the CPU ID.

---
 arch/powerpc/sysdev/mpic.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
arch/powerpc/sysdev/mpic.c +7 -1
index 1be54fa..bdcb858 100644
@@ -1088,8 +1088,14 @@ static int mpic_host_map(struct irq_domain *h, unsigned int virq,
 	 * is done here.
 	 */
 	if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) {
+		int cpu;
+
+		preempt_disable();
+		cpu = mpic_processor_id(mpic);
+		preempt_enable();
+
 		mpic_set_vector(virq, hw);
-		mpic_set_destination(virq, mpic_processor_id(mpic));
+		mpic_set_destination(virq, cpu);
 		mpic_irq_set_priority(virq, 8);
 	}
 
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 3 lines · Scott Wood

Otherwise, we get a debug traceback due to the use of smp_processor_id() (or get_paca()) inside hard_smp_processor_id(). mpic_host_map() is just looking for a default CPU, so it doesn't =

matter

arch/powerpc/sysdev/mpic.c static int mpic_host_map(struct irq_domain *h, =

Quoted 12 lines

if we migrate after getting the CPU ID.
=20

---
arch/powerpc/sysdev/mpic.c | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)

=20

arch/powerpc/sysdev/mpic.c +0 -0
index 1be54fa..bdcb858 100644
@@ -1088,8 +1088,14 @@ static int mpic_host_map(struct irq_domain *h, =

unsigned int virq,

arch/powerpc/sysdev/mpic.c static int mpic_host_map(struct irq_domain *h, unsigned int virq, · line 1096

Quoted 9 lines
arch/powerpc/sysdev/mpic.c +6 -0
 	 * is done here.
 	 */
 	if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) {
+		int cpu;
+
+		preempt_disable();
+		cpu =3D mpic_processor_id(mpic);
+		preempt_enable();
+

Any reason you didn't stick this inside of mpic_processor_id() ?

Quoted 14 lines
arch/powerpc/sysdev/mpic.c +1 -1
 		mpic_set_vector(virq, hw);
-		mpic_set_destination(virq, mpic_processor_id(mpic));
+		mpic_set_destination(virq, cpu);
 		mpic_irq_set_priority(virq, 8);
 	}

=20
--=20
1.8.1.2
=20
=20
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

author
#2 lore raw
Quoted 12 lines · Kumar Gala
Quoted 10 lines · Scott Wood

Otherwise, we get a debug traceback due to the use of smp_processor_id() (or get_paca()) inside hard_smp_processor_id(). mpic_host_map() is just looking for a default CPU, so it doesn't matter if we migrate after getting the CPU ID.

---
arch/powerpc/sysdev/mpic.c | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)
Quoted 16 lines
Quoted 5 lines
arch/powerpc/sysdev/mpic.c +0 -0
index 1be54fa..bdcb858 100644

arch/powerpc/sysdev/mpic.c static int mpic_host_map(struct irq_domain *h, unsigned int virq, · line 1096

Quoted 9 lines
arch/powerpc/sysdev/mpic.c +6 -0
@@ -1088,8 +1088,14 @@ static int mpic_host_map(struct irq_domain *h, unsigned int virq,
 	 * is done here.
 	 */
 	if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) {
+		int cpu;
+
+		preempt_disable();
+		cpu = mpic_processor_id(mpic);
+		preempt_enable();
+

Any reason you didn't stick this inside of mpic_processor_id() ?

Because the debug check might be valid for other callers and we don't want to defeat it. In this caller it's used only as a heuristic and thus it doesn't matter if we re-enable preemption before using the result.

-Scott

#3 lore raw
Quoted 6 lines · Scott Wood
Quoted 5 lines · Kumar Gala

On Sep 26, 2013, at 7:18 PM, Scott Wood wrote:
=20

Quoted 3 lines

Otherwise, we get a debug traceback due to the use of smp_processor_id() (or get_paca()) inside hard_smp_processor_id(). mpic_host_map() is just looking for a default CPU, so it doesn't =

matter

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

if we migrate after getting the CPU ID.
=20

---

Quoted 8 lines
Quoted 8 lines

arch/powerpc/sysdev/mpic.c static int mpic_host_map(struct irq_domain =

Quoted 8 lines

arch/powerpc/sysdev/mpic.c | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)

=20

arch/powerpc/sysdev/mpic.c +0 -0
index 1be54fa..bdcb858 100644
@@ -1088,8 +1088,14 @@ static int mpic_host_map(struct irq_domain =

*h, unsigned int virq,

Quoted 11 lines
Quoted 11 lines

arch/powerpc/sysdev/mpic.c static int mpic_host_map(struct irq_domain *h, unsigned int virq, · line 1096

Quoted 9 lines
arch/powerpc/sysdev/mpic.c +6 -0
 	 * is done here.
 	 */
 	if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) {
+		int cpu;
+
+		preempt_disable();
+		cpu =3D mpic_processor_id(mpic);
+		preempt_enable();
+

=20
Any reason you didn't stick this inside of mpic_processor_id() ?

Quoted 5 lines

=20
Because the debug check might be valid for other callers and we don't want to defeat it. In this caller it's used only as a heuristic and thus it doesn't matter if we re-enable preemption before using the result.

Gotcha, I think you should reword the commit message. Reading it makes = me think that preemption should be disabled for all mpic_processor_id() = calls.

- k=

author
#4 lore raw
Quoted 32 lines · Kumar Gala
Quoted 30 lines · Scott Wood
Quoted 28 lines · Kumar Gala
Quoted 15 lines · Scott Wood

Otherwise, we get a debug traceback due to the use of smp_processor_id() (or get_paca()) inside hard_smp_processor_id(). mpic_host_map() is just looking for a default CPU, so it doesn't matter if we migrate after getting the CPU ID.

---
arch/powerpc/sysdev/mpic.c | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)
arch/powerpc/sysdev/mpic.c +0 -0
index 1be54fa..bdcb858 100644

arch/powerpc/sysdev/mpic.c static int mpic_host_map(struct irq_domain *h, unsigned int virq, · line 1096

Quoted 9 lines
arch/powerpc/sysdev/mpic.c +6 -0
@@ -1088,8 +1088,14 @@ static int mpic_host_map(struct irq_domain *h, unsigned int virq,
 	 * is done here.
 	 */
 	if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) {
+		int cpu;
+
+		preempt_disable();
+		cpu = mpic_processor_id(mpic);
+		preempt_enable();
+

Any reason you didn't stick this inside of mpic_processor_id() ?

Quoted 8 lines
Quoted 4 lines

Because the debug check might be valid for other callers and we don't want to defeat it. In this caller it's used only as a heuristic and thus it doesn't matter if we re-enable preemption before using the result.

Gotcha, I think you should reword the commit message. Reading it makes me think that preemption should be disabled for all mpic_processor_id() calls.

It should be disabled for all mpic_processor_id() calls -- but some calls will need preemption to be disabled for longer than just the call to mpic_processor_id().

I did mention in the commit message why mpic_host_map() is unusual.

BTW, I wonder why we don't use mpic_set_affinity (and thus irq_choose_cpu), both here and in the non-MPIC_NO_RESET case. Though I usually notice IRQs being round robinned -- I guess userspace is writing to the affinity in proc? Or is something elsewhere in the kernel calling set_affinity at some point?

Another thing I just noticed while looking at IRQ_DESTINATION-related code, in mpic_teardown_this_cpu(), what stops it from removing the only CPU that an interrupt is targeted at?

-Scott