Skip to contentSkip to conversation

xen/events: fix setting irq affinity

PATCH Applied Juergen Gross 4 participants 11 messages Apr 12, 2021 – Apr 15, 2021

Subsystems (2)
lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

PATCH 1/1 xen/events: fix setting irq affinity

The backport of upstream patch 25da4618af240fbec61 ("xen/events: don't unmask an event channel when an eoi is pending") introduced a regression for stable kernels 5.10 and older: setting IRQ affinity for IRQs related to interdomain events would no longer work, as moving the IRQ to its new cpu was not included in the irq_ack callback for those events.

Fix that by adding the needed call.

Note that kernels 5.11 and later don't need the explicit moving of the IRQ to the target cpu in the irq_ack callback, due to a rework of the affinity setting in kernel 5.11.

---
This patch should be applied to all stable kernel branches up to (including) linux-5.10.y, where upstream patch 25da4618af240fbec61 has been added.

---
 drivers/xen/events/events_base.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/events/events_base.c +2 -2
index 7bd03f6e0422..ee5269331406 100644
@@ -1809,7 +1809,7 @@ static void lateeoi_ack_dynirq(struct irq_data *data)
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EOI_PENDING);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 
@@ -1820,7 +1820,7 @@ static void lateeoi_mask_ack_dynirq(struct irq_data *data)
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EXPLICIT);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Juergen Gross

The backport of upstream patch 25da4618af240fbec61 ("xen/events: don't unmask an event channel when an eoi is pending") introduced a regression for stable kernels 5.10 and older: setting IRQ affinity for IRQs related to interdomain events would no longer work, as moving the IRQ to its new cpu was not included in the irq_ack callback for those events.

Fix that by adding the needed call.

Note that kernels 5.11 and later don't need the explicit moving of the IRQ to the target cpu in the irq_ack callback, due to a rework of the affinity setting in kernel 5.11.

Quoted 7 lines

---
This patch should be applied to all stable kernel branches up to (including) linux-5.10.y, where upstream patch 25da4618af240fbec61 has been added.

This looks functionally correct to me, so:

But I have remarks / questions:

Quoted 12 lines
drivers/xen/events/events_base.c +1 -1
@@ -1809,7 +1809,7 @@ static void lateeoi_ack_dynirq(struct irq_data *data)
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EOI_PENDING);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 

drivers/xen/events/events_base.c static void lateeoi_mask_ack_dynirq(struct irq_data *data) · line 1826

Quoted 8 lines
drivers/xen/events/events_base.c +1 -1
@@ -1820,7 +1820,7 @@ static void lateeoi_mask_ack_dynirq(struct irq_data *data)
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EXPLICIT);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 

Can EVT_MASK_REASON_EOI_{PENDING,EXPLICIT} be cleared in a way racing event_handler_exit() and (if it was called directly from here) irq_move_masked_irq()? If not, the extra do_mask() / do_unmask() pair (granted living on an "unlikely" path) could be avoided.

Even leaving aside the extra overhead in ack_dynirq()'s unlikely code path, there's now some extra (redundant) processing. I guess this is assumed to be within noise?

Possibly related, but first of all seeing the redundancy between eoi_pirq() and ack_dynirq(): Wouldn't it make sense to break out the common part into a helper? (Really the former could simply call the latter as it seems.)

Jan

author maintainer
#2 lore raw
Quoted 40 lines · Jan Beulich
Quoted 13 lines · Juergen Gross

The backport of upstream patch 25da4618af240fbec61 ("xen/events: don't unmask an event channel when an eoi is pending") introduced a regression for stable kernels 5.10 and older: setting IRQ affinity for IRQs related to interdomain events would no longer work, as moving the IRQ to its new cpu was not included in the irq_ack callback for those events.

Fix that by adding the needed call.

Note that kernels 5.11 and later don't need the explicit moving of the IRQ to the target cpu in the irq_ack callback, due to a rework of the affinity setting in kernel 5.11.

Quoted 7 lines

---
This patch should be applied to all stable kernel branches up to (including) linux-5.10.y, where upstream patch 25da4618af240fbec61 has been added.

This looks functionally correct to me, so:

But I have remarks / questions:

Quoted 13 lines
drivers/xen/events/events_base.c +1 -1
@@ -1809,7 +1809,7 @@ static void lateeoi_ack_dynirq(struct irq_data *data)
 
  	if (VALID_EVTCHN(evtchn)) {
  		do_mask(info, EVT_MASK_REASON_EOI_PENDING);
-		event_handler_exit(info);
+		ack_dynirq(data);
  	}
  }
 
@@ -1820,7 +1820,7 @@ static void lateeoi_mask_ack_dynirq(struct irq_data *data)
 
Quoted 12 lines

drivers/xen/events/events_base.c static void lateeoi_mask_ack_dynirq(struct irq_data *data) · line 1826

Quoted 7 lines
drivers/xen/events/events_base.c +1 -1
  	if (VALID_EVTCHN(evtchn)) {
  		do_mask(info, EVT_MASK_REASON_EXPLICIT);
-		event_handler_exit(info);
+		ack_dynirq(data);
  	}
  }
 

Can EVT_MASK_REASON_EOI_{PENDING,EXPLICIT} be cleared in a way racing event_handler_exit() and (if it was called directly from here) irq_move_masked_irq()? If not, the extra do_mask() / do_unmask() pair (granted living on an "unlikely" path) could be avoided.

No, they can't race. And yes, the path is really unlikely, so I didn't want to optimize this rare case.

Quoted 3 lines

Even leaving aside the extra overhead in ack_dynirq()'s unlikely code path, there's now some extra (redundant) processing. I guess this is assumed to be within noise?

Yes. All required data should be in the caches already, and the extra processing is only a few instructions.

Quoted 4 lines

Possibly related, but first of all seeing the redundancy between eoi_pirq() and ack_dynirq(): Wouldn't it make sense to break out the common part into a helper? (Really the former could simply call the latter as it seems.)

In theory, yes. OTOH this no longer applies to upstream, so i dind't bother doing that for stable.

Juergen

#3 lore raw
Quoted 8 lines · Juergen Gross
Quoted 4 lines · Jan Beulich

Possibly related, but first of all seeing the redundancy between eoi_pirq() and ack_dynirq(): Wouldn't it make sense to break out the common part into a helper? (Really the former could simply call the latter as it seems.)

In theory, yes. OTOH this no longer applies to upstream, so i dind't bother doing that for stable.

Oh, I guess I should have check the tip of the tree first...

Jan

#4 lore raw
In reply to Juergen Gross
Quoted 13 lines · Juergen Gross

The backport of upstream patch 25da4618af240fbec61 ("xen/events: don't unmask an event channel when an eoi is pending") introduced a regression for stable kernels 5.10 and older: setting IRQ affinity for IRQs related to interdomain events would no longer work, as moving the IRQ to its new cpu was not included in the irq_ack callback for those events.

Fix that by adding the needed call.

Note that kernels 5.11 and later don't need the explicit moving of the IRQ to the target cpu in the irq_ack callback, due to a rework of the affinity setting in kernel 5.11.

Quoted 5 lines

---
This patch should be applied to all stable kernel branches up to (including) linux-5.10.y, where upstream patch 25da4618af240fbec61 has been added.

Now queued up, thanks.

greg k-h

maintainer Applied
#5 lore raw

Patch "xen/events: fix setting irq affinity" has been added to the 4.4-stable tree

In reply to Juergen Gross

This is a note to let you know that I've just added the patch titled

xen/events: fix setting irq affinity

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
xen-events-fix-setting-irq-affinity.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Thu Apr 15 15:56:08 2021
From: Juergen Gross <[email protected]>
Date: Mon, 12 Apr 2021 08:28:45 +0200
Subject: xen/events: fix setting irq affinity
To: [email protected]
Cc: Juergen Gross <[email protected]>, Boris Ostrovsky <[email protected]>, Stefano Stabellini <[email protected]>, [email protected]
Message-ID: <[email protected]>

From: Juergen Gross <[email protected]>

The backport of upstream patch 25da4618af240fbec61 ("xen/events: don't unmask an event channel when an eoi is pending") introduced a regression for stable kernels 5.10 and older: setting IRQ affinity for IRQs related to interdomain events would no longer work, as moving the IRQ to its new cpu was not included in the irq_ack callback for those events.

Fix that by adding the needed call.

Note that kernels 5.11 and later don't need the explicit moving of the IRQ to the target cpu in the irq_ack callback, due to a rework of the affinity setting in kernel 5.11.

---
 drivers/xen/events/events_base.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/events/events_base.c +2 -2
@@ -1779,7 +1779,7 @@ static void lateeoi_ack_dynirq(struct ir
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EOI_PENDING);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 
@@ -1790,7 +1790,7 @@ static void lateeoi_mask_ack_dynirq(stru
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EXPLICIT);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/xen-events-fix-setting-irq-affinity.patch

maintainer Applied
#6 lore raw

Patch "xen/events: fix setting irq affinity" has been added to the 4.9-stable tree

In reply to Juergen Gross

This is a note to let you know that I've just added the patch titled

xen/events: fix setting irq affinity

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
xen-events-fix-setting-irq-affinity.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Thu Apr 15 15:56:08 2021
From: Juergen Gross <[email protected]>
Date: Mon, 12 Apr 2021 08:28:45 +0200
Subject: xen/events: fix setting irq affinity
To: [email protected]
Cc: Juergen Gross <[email protected]>, Boris Ostrovsky <[email protected]>, Stefano Stabellini <[email protected]>, [email protected]
Message-ID: <[email protected]>

From: Juergen Gross <[email protected]>

The backport of upstream patch 25da4618af240fbec61 ("xen/events: don't unmask an event channel when an eoi is pending") introduced a regression for stable kernels 5.10 and older: setting IRQ affinity for IRQs related to interdomain events would no longer work, as moving the IRQ to its new cpu was not included in the irq_ack callback for those events.

Fix that by adding the needed call.

Note that kernels 5.11 and later don't need the explicit moving of the IRQ to the target cpu in the irq_ack callback, due to a rework of the affinity setting in kernel 5.11.

---
 drivers/xen/events/events_base.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/events/events_base.c +2 -2
@@ -1780,7 +1780,7 @@ static void lateeoi_ack_dynirq(struct ir
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EOI_PENDING);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 
@@ -1791,7 +1791,7 @@ static void lateeoi_mask_ack_dynirq(stru
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EXPLICIT);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/xen-events-fix-setting-irq-affinity.patch

maintainer Applied
#7 lore raw

Patch "xen/events: fix setting irq affinity" has been added to the 4.14-stable tree

In reply to Juergen Gross

This is a note to let you know that I've just added the patch titled

xen/events: fix setting irq affinity

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
xen-events-fix-setting-irq-affinity.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Thu Apr 15 15:56:08 2021
From: Juergen Gross <[email protected]>
Date: Mon, 12 Apr 2021 08:28:45 +0200
Subject: xen/events: fix setting irq affinity
To: [email protected]
Cc: Juergen Gross <[email protected]>, Boris Ostrovsky <[email protected]>, Stefano Stabellini <[email protected]>, [email protected]
Message-ID: <[email protected]>

From: Juergen Gross <[email protected]>

The backport of upstream patch 25da4618af240fbec61 ("xen/events: don't unmask an event channel when an eoi is pending") introduced a regression for stable kernels 5.10 and older: setting IRQ affinity for IRQs related to interdomain events would no longer work, as moving the IRQ to its new cpu was not included in the irq_ack callback for those events.

Fix that by adding the needed call.

Note that kernels 5.11 and later don't need the explicit moving of the IRQ to the target cpu in the irq_ack callback, due to a rework of the affinity setting in kernel 5.11.

---
 drivers/xen/events/events_base.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/events/events_base.c +2 -2
@@ -1782,7 +1782,7 @@ static void lateeoi_ack_dynirq(struct ir
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EOI_PENDING);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 
@@ -1793,7 +1793,7 @@ static void lateeoi_mask_ack_dynirq(stru
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EXPLICIT);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/xen-events-fix-setting-irq-affinity.patch

maintainer Applied
#8 lore raw

Patch "xen/events: fix setting irq affinity" has been added to the 4.19-stable tree

In reply to Juergen Gross

This is a note to let you know that I've just added the patch titled

xen/events: fix setting irq affinity

to the 4.19-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
xen-events-fix-setting-irq-affinity.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Thu Apr 15 15:56:08 2021
From: Juergen Gross <[email protected]>
Date: Mon, 12 Apr 2021 08:28:45 +0200
Subject: xen/events: fix setting irq affinity
To: [email protected]
Cc: Juergen Gross <[email protected]>, Boris Ostrovsky <[email protected]>, Stefano Stabellini <[email protected]>, [email protected]
Message-ID: <[email protected]>

From: Juergen Gross <[email protected]>

The backport of upstream patch 25da4618af240fbec61 ("xen/events: don't unmask an event channel when an eoi is pending") introduced a regression for stable kernels 5.10 and older: setting IRQ affinity for IRQs related to interdomain events would no longer work, as moving the IRQ to its new cpu was not included in the irq_ack callback for those events.

Fix that by adding the needed call.

Note that kernels 5.11 and later don't need the explicit moving of the IRQ to the target cpu in the irq_ack callback, due to a rework of the affinity setting in kernel 5.11.

---
 drivers/xen/events/events_base.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/events/events_base.c +2 -2
@@ -1782,7 +1782,7 @@ static void lateeoi_ack_dynirq(struct ir
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EOI_PENDING);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 
@@ -1793,7 +1793,7 @@ static void lateeoi_mask_ack_dynirq(stru
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EXPLICIT);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.19/xen-events-fix-setting-irq-affinity.patch

maintainer Applied
#9 lore raw

Patch "xen/events: fix setting irq affinity" has been added to the 5.4-stable tree

In reply to Juergen Gross

This is a note to let you know that I've just added the patch titled

xen/events: fix setting irq affinity

to the 5.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
xen-events-fix-setting-irq-affinity.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Thu Apr 15 15:56:08 2021
From: Juergen Gross <[email protected]>
Date: Mon, 12 Apr 2021 08:28:45 +0200
Subject: xen/events: fix setting irq affinity
To: [email protected]
Cc: Juergen Gross <[email protected]>, Boris Ostrovsky <[email protected]>, Stefano Stabellini <[email protected]>, [email protected]
Message-ID: <[email protected]>

From: Juergen Gross <[email protected]>

The backport of upstream patch 25da4618af240fbec61 ("xen/events: don't unmask an event channel when an eoi is pending") introduced a regression for stable kernels 5.10 and older: setting IRQ affinity for IRQs related to interdomain events would no longer work, as moving the IRQ to its new cpu was not included in the irq_ack callback for those events.

Fix that by adding the needed call.

Note that kernels 5.11 and later don't need the explicit moving of the IRQ to the target cpu in the irq_ack callback, due to a rework of the affinity setting in kernel 5.11.

---
 drivers/xen/events/events_base.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/events/events_base.c +2 -2
@@ -1783,7 +1783,7 @@ static void lateeoi_ack_dynirq(struct ir
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EOI_PENDING);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 
@@ -1794,7 +1794,7 @@ static void lateeoi_mask_ack_dynirq(stru
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EXPLICIT);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-5.4/xen-events-fix-setting-irq-affinity.patch

maintainer Applied
#10 lore raw

Patch "xen/events: fix setting irq affinity" has been added to the 5.10-stable tree

In reply to Juergen Gross

This is a note to let you know that I've just added the patch titled

xen/events: fix setting irq affinity

to the 5.10-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
xen-events-fix-setting-irq-affinity.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Thu Apr 15 15:56:08 2021
From: Juergen Gross <[email protected]>
Date: Mon, 12 Apr 2021 08:28:45 +0200
Subject: xen/events: fix setting irq affinity
To: [email protected]
Cc: Juergen Gross <[email protected]>, Boris Ostrovsky <[email protected]>, Stefano Stabellini <[email protected]>, [email protected]
Message-ID: <[email protected]>

From: Juergen Gross <[email protected]>

The backport of upstream patch 25da4618af240fbec61 ("xen/events: don't unmask an event channel when an eoi is pending") introduced a regression for stable kernels 5.10 and older: setting IRQ affinity for IRQs related to interdomain events would no longer work, as moving the IRQ to its new cpu was not included in the irq_ack callback for those events.

Fix that by adding the needed call.

Note that kernels 5.11 and later don't need the explicit moving of the IRQ to the target cpu in the irq_ack callback, due to a rework of the affinity setting in kernel 5.11.

---
 drivers/xen/events/events_base.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/events/events_base.c +2 -2
@@ -1809,7 +1809,7 @@ static void lateeoi_ack_dynirq(struct ir
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EOI_PENDING);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 
@@ -1820,7 +1820,7 @@ static void lateeoi_mask_ack_dynirq(stru
 
 	if (VALID_EVTCHN(evtchn)) {
 		do_mask(info, EVT_MASK_REASON_EXPLICIT);
-		event_handler_exit(info);
+		ack_dynirq(data);
 	}
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-5.10/xen-events-fix-setting-irq-affinity.patch