Skip to contentSkip to conversation

powerpc/xive: use hw CPU ids when configuring the CPU queues

PATCH Applied Cédric Le Goater 3 participants 5 messages Feb 13, 2018 – Feb 18, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/xive: use hw CPU ids when configuring the CPU queues

The CPU event notification queues on sPAPR should be configured using a hardware CPU identifier.

The problem did not show up on the Power Hypervisor because pHyp supports 8 threads per core which keeps CPU number contiguous. This is not the case on all sPAPR virtual machines, some use SMT=1.

Also improve error logging by adding the CPU number.

---

I think we should send this one to stable also.

 arch/powerpc/sysdev/xive/spapr.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
arch/powerpc/sysdev/xive/spapr.c +10 -6
index d9c4c9366049..091f1d0d0af1 100644
@@ -356,7 +356,8 @@ static int xive_spapr_configure_queue(u32 target, struct xive_q *q, u8 prio,
 
 	rc = plpar_int_get_queue_info(0, target, prio, &esn_page, &esn_size);
 	if (rc) {
-		pr_err("Error %lld getting queue info prio %d\n", rc, prio);
+		pr_err("Error %lld getting queue info CPU %d prio %d\n", rc,
+		       target, prio);
 		rc = -EIO;
 		goto fail;
 	}
@@ -370,7 +371,8 @@ static int xive_spapr_configure_queue(u32 target, struct xive_q *q, u8 prio,
 	/* Configure and enable the queue in HW */
 	rc = plpar_int_set_queue_config(flags, target, prio, qpage_phys, order);
 	if (rc) {
-		pr_err("Error %lld setting queue for prio %d\n", rc, prio);
+		pr_err("Error %lld setting queue for CPU %d prio %d\n", rc,
+		       target, prio);
 		rc = -EIO;
 	} else {
 		q->qpage = qpage;
@@ -389,8 +391,8 @@ static int xive_spapr_setup_queue(unsigned int cpu, struct xive_cpu *xc,
 	if (IS_ERR(qpage))
 		return PTR_ERR(qpage);
 
-	return xive_spapr_configure_queue(cpu, q, prio, qpage,
-					  xive_queue_shift);
+	return xive_spapr_configure_queue(get_hard_smp_processor_id(cpu),
+					  q, prio, qpage, xive_queue_shift);
 }
 
 static void xive_spapr_cleanup_queue(unsigned int cpu, struct xive_cpu *xc,
@@ -399,10 +401,12 @@ static void xive_spapr_cleanup_queue(unsigned int cpu, struct xive_cpu *xc,
 	struct xive_q *q = &xc->queue[prio];
 	unsigned int alloc_order;
 	long rc;
+	int hw_cpu = get_hard_smp_processor_id(cpu);
 
-	rc = plpar_int_set_queue_config(0, cpu, prio, 0, 0);
+	rc = plpar_int_set_queue_config(0, hw_cpu, prio, 0, 0);
 	if (rc)
-		pr_err("Error %ld setting queue for prio %d\n", rc, prio);
+		pr_err("Error %ld setting queue for CPU %d prio %d\n", rc,
+		       hw_cpu, prio);
 
 	alloc_order = xive_alloc_order(xive_queue_shift);
 	free_pages((unsigned long)q->qpage, alloc_order);
Signature · 1 line
2.13.6
#1 lore raw
Quoted 7 lines · C=C3=A9dric Le Goater <[email protected]> writes:

The CPU event notification queues on sPAPR should be configured using a hardware CPU identifier.

The problem did not show up on the Power Hypervisor because pHyp supports 8 threads per core which keeps CPU number contiguous. This is not the case on all sPAPR virtual machines, some use SMT=3D1.

Quoted 6 lines

Also improve error logging by adding the CPU number.

---

I think we should send this one to stable also.

Fixes eac1e731b59e ("powerpc/xive: guest exploitation of the XIVE interrup=

t controller")
Cc: [email protected] # v4.14+

?

cheers

arch/powerpc/sysdev/xive/=

Quoted 1 line
arch/powerpc/sysdev/xive/= renamed from arch/powerpc/sysdev/xive/spapr.c +0 -0

spapr.c

arch/powerpc/sysdev/xive/spapr.c static int xive_spapr_configure_queue(u32 target, str=

Quoted 4 lines

index d9c4c9366049..091f1d0d0af1 100644

arch/powerpc/sysdev/xive/spapr.c +0 -0
@@ -356,7 +356,8 @@ static int xive_spapr_configure_queue(u32 target, str=

uct xive_q *q, u8 prio,

arch/powerpc/sysdev/xive/spapr.c static int xive_spapr_configure_queue(u32 target, str=

Quoted 10 lines

=20=20

arch/powerpc/sysdev/xive/spapr.c +2 -1
 	rc =3D plpar_int_get_queue_info(0, target, prio, &esn_page, &esn_size);
 	if (rc) {
-		pr_err("Error %lld getting queue info prio %d\n", rc, prio);
+		pr_err("Error %lld getting queue info CPU %d prio %d\n", rc,
+		       target, prio);
 		rc =3D -EIO;
 		goto fail;
 	}
@@ -370,7 +371,8 @@ static int xive_spapr_configure_queue(u32 target, str=

uct xive_q *q, u8 prio,

arch/powerpc/sysdev/xive/spapr.c static int xive_spapr_configure_queue(u32 target, str= · line 372

Quoted 2 lines
arch/powerpc/sysdev/xive/spapr.c +0 -0
 	/* Configure and enable the queue in HW */
 	rc =3D plpar_int_set_queue_config(flags, target, prio, qpage_phys, orde=

r);

arch/powerpc/sysdev/xive/spapr.c static int xive_spapr_setup_queue(unsigned int cpu, s=

Quoted 8 lines
arch/powerpc/sysdev/xive/spapr.c +2 -1
 	if (rc) {
-		pr_err("Error %lld setting queue for prio %d\n", rc, prio);
+		pr_err("Error %lld setting queue for CPU %d prio %d\n", rc,
+		       target, prio);
 		rc =3D -EIO;
 	} else {
 		q->qpage =3D qpage;
@@ -389,8 +391,8 @@ static int xive_spapr_setup_queue(unsigned int cpu, s=

truct xive_cpu *xc,

Quoted 10 lines
arch/powerpc/sysdev/xive/spapr.c +0 -0
 	if (IS_ERR(qpage))
 		return PTR_ERR(qpage);

=20=20

arch/powerpc/sysdev/xive/spapr.c +2 -2
-	return xive_spapr_configure_queue(cpu, q, prio, qpage,
-					  xive_queue_shift);
+	return xive_spapr_configure_queue(get_hard_smp_processor_id(cpu),
+					  q, prio, qpage, xive_queue_shift);
 }

=20=20
static void xive_spapr_cleanup_queue(unsigned int cpu, struct xive_cpu *=

xc,

arch/powerpc/sysdev/xive/spapr.c static void xive_spapr_cleanup_queue(unsigned int c=

Quoted 1 line
arch/powerpc/sysdev/xive/spapr.c +0 -0
@@ -399,10 +401,12 @@ static void xive_spapr_cleanup_queue(unsigned int c=

pu, struct xive_cpu *xc,

Quoted 16 lines
arch/powerpc/sysdev/xive/spapr.c +1 -0
 	struct xive_q *q =3D &xc->queue[prio];
 	unsigned int alloc_order;
 	long rc;
+	int hw_cpu =3D get_hard_smp_processor_id(cpu);

=20=20

arch/powerpc/sysdev/xive/spapr.c +3 -2
-	rc =3D plpar_int_set_queue_config(0, cpu, prio, 0, 0);
+	rc =3D plpar_int_set_queue_config(0, hw_cpu, prio, 0, 0);
 	if (rc)
-		pr_err("Error %ld setting queue for prio %d\n", rc, prio);
+		pr_err("Error %ld setting queue for CPU %d prio %d\n", rc,
+		       hw_cpu, prio);

=20=20

arch/powerpc/sysdev/xive/spapr.c +0 -1
 	alloc_order =3D xive_alloc_order(xive_queue_shift);
 	free_pages((unsigned long)q->qpage, alloc_order);
--=20

2.13.6

#2 lore raw
Quoted 9 lines · Michael Ellerman
Quoted 7 lines · Cédric Le Goater

The CPU event notification queues on sPAPR should be configured using a hardware CPU identifier.

The problem did not show up on the Power Hypervisor because pHyp supports 8 threads per core which keeps CPU number contiguous. This is not the case on all sPAPR virtual machines, some use SMT=1.

Quoted 8 lines
Quoted 6 lines

Also improve error logging by adding the CPU number.

---

I think we should send this one to stable also.

Fixes eac1e731b59e ("powerpc/xive: guest exploitation of the XIVE interrupt controller")

yes.

Quoted 1 line
Cc [email protected] # v4.14+

yes. I just added the Cc:. I am not sure that will work with patchwork though.

Thanks,

C.

Quoted 56 lines

?

cheers

Quoted 52 lines
arch/powerpc/sysdev/xive/spapr.c +10 -6
index d9c4c9366049..091f1d0d0af1 100644
@@ -356,7 +356,8 @@ static int xive_spapr_configure_queue(u32 target, struct xive_q *q, u8 prio,
 
 	rc = plpar_int_get_queue_info(0, target, prio, &esn_page, &esn_size);
 	if (rc) {
-		pr_err("Error %lld getting queue info prio %d\n", rc, prio);
+		pr_err("Error %lld getting queue info CPU %d prio %d\n", rc,
+		       target, prio);
 		rc = -EIO;
 		goto fail;
 	}
@@ -370,7 +371,8 @@ static int xive_spapr_configure_queue(u32 target, struct xive_q *q, u8 prio,
 	/* Configure and enable the queue in HW */
 	rc = plpar_int_set_queue_config(flags, target, prio, qpage_phys, order);
 	if (rc) {
-		pr_err("Error %lld setting queue for prio %d\n", rc, prio);
+		pr_err("Error %lld setting queue for CPU %d prio %d\n", rc,
+		       target, prio);
 		rc = -EIO;
 	} else {
 		q->qpage = qpage;
@@ -389,8 +391,8 @@ static int xive_spapr_setup_queue(unsigned int cpu, struct xive_cpu *xc,
 	if (IS_ERR(qpage))
 		return PTR_ERR(qpage);
 
-	return xive_spapr_configure_queue(cpu, q, prio, qpage,
-					  xive_queue_shift);
+	return xive_spapr_configure_queue(get_hard_smp_processor_id(cpu),
+					  q, prio, qpage, xive_queue_shift);
 }
 
 static void xive_spapr_cleanup_queue(unsigned int cpu, struct xive_cpu *xc,
@@ -399,10 +401,12 @@ static void xive_spapr_cleanup_queue(unsigned int cpu, struct xive_cpu *xc,
 	struct xive_q *q = &xc->queue[prio];
 	unsigned int alloc_order;
 	long rc;
+	int hw_cpu = get_hard_smp_processor_id(cpu);
 
-	rc = plpar_int_set_queue_config(0, cpu, prio, 0, 0);
+	rc = plpar_int_set_queue_config(0, hw_cpu, prio, 0, 0);
 	if (rc)
-		pr_err("Error %ld setting queue for prio %d\n", rc, prio);
+		pr_err("Error %ld setting queue for CPU %d prio %d\n", rc,
+		       hw_cpu, prio);
 
 	alloc_order = xive_alloc_order(xive_queue_shift);
 	free_pages((unsigned long)q->qpage, alloc_order);
Signature · 1 line
2.13.6
#3 lore raw
Quoted 10 lines · C=C3=A9dric Le Goater <[email protected]> writes:
Quoted 9 lines · Michael Ellerman

C=C3=A9dric Le Goater <[email protected]> writes:
=20

Quoted 7 lines

The CPU event notification queues on sPAPR should be configured using a hardware CPU identifier.

The problem did not show up on the Power Hypervisor because pHyp supports 8 threads per core which keeps CPU number contiguous. This is not the case on all sPAPR virtual machines, some use SMT=3D1.

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

Also improve error logging by adding the CPU number.

---

I think we should send this one to stable also.

=20

Fixes eac1e731b59e ("powerpc/xive: guest exploitation of the XIVE inter=

rupt controller")

Quoted 7 lines

yes.

Quoted 1 line
Cc [email protected] # v4.14+

yes. I just added the Cc:. I am not sure that will work with=20 patchwork though.

They don't accept patches that way.

I'll add the tags and commit it.

cheers

#4 lore raw
In reply to Cédric Le Goater
Quoted 10 lines · On Tue, 2018-02-13 at 08:47:12 UTC, =?utf-8?q?C=C3=A9dric_Le_Goater?= wrote:

The CPU event notification queues on sPAPR should be configured using a hardware CPU identifier.

The problem did not show up on the Power Hypervisor because pHyp supports 8 threads per core which keeps CPU number contiguous. This is not the case on all sPAPR virtual machines, some use SMT=1.

Also improve error logging by adding the CPU number.

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/8e036c8d30a2cd9d8fc7442fbf6824

cheers