diff mbox series

[1/7] xen/events: fix delayed eoi list handling

Message ID 20231016062831.20630-2-jgross@suse.com (mailing list archive)
State Accepted
Commit 47d970204054f859f35a2237baa75c2d84fcf436
Headers show
Series xen/events: do some cleanups in events_base.c | expand

Commit Message

Jürgen Groß Oct. 16, 2023, 6:28 a.m. UTC
When delaying eoi handling of events, the related elements are queued
into the percpu lateeoi list. In case the list isn't empty, the
elements should be sorted by the time when eoi handling is to happen.

Unfortunately a new element will never be queued at the start of the
list, even if it has a handling time lower than all other list
elements.

Fix that by handling that case the same way as for an empty list.

Fixes: e99502f76271 ("xen/events: defer eoi in case of excessive number of events")
Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 drivers/xen/events/events_base.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Oleksandr Tyshchenko Nov. 13, 2023, 1:51 p.m. UTC | #1
On 16.10.23 09:28, Juergen Gross wrote:


Hello Juergen

> When delaying eoi handling of events, the related elements are queued
> into the percpu lateeoi list. In case the list isn't empty, the
> elements should be sorted by the time when eoi handling is to happen.
> 
> Unfortunately a new element will never be queued at the start of the
> list, even if it has a handling time lower than all other list
> elements.
> 
> Fix that by handling that case the same way as for an empty list.
> 
> Fixes: e99502f76271 ("xen/events: defer eoi in case of excessive number of events")
> Reported-by: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Juergen Gross <jgross@suse.com>


Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

> ---
>   drivers/xen/events/events_base.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
> index 1b2136fe0fa5..0e458b1c0c8c 100644
> --- a/drivers/xen/events/events_base.c
> +++ b/drivers/xen/events/events_base.c
> @@ -601,7 +601,9 @@ static void lateeoi_list_add(struct irq_info *info)
>   
>   	spin_lock_irqsave(&eoi->eoi_list_lock, flags);
>   
> -	if (list_empty(&eoi->eoi_list)) {
> +	elem = list_first_entry_or_null(&eoi->eoi_list, struct irq_info,
> +					eoi_list);
> +	if (!elem || info->eoi_time < elem->eoi_time) {
>   		list_add(&info->eoi_list, &eoi->eoi_list);
>   		mod_delayed_work_on(info->eoi_cpu, system_wq,
>   				    &eoi->delayed, delay);
diff mbox series

Patch

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 1b2136fe0fa5..0e458b1c0c8c 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -601,7 +601,9 @@  static void lateeoi_list_add(struct irq_info *info)
 
 	spin_lock_irqsave(&eoi->eoi_list_lock, flags);
 
-	if (list_empty(&eoi->eoi_list)) {
+	elem = list_first_entry_or_null(&eoi->eoi_list, struct irq_info,
+					eoi_list);
+	if (!elem || info->eoi_time < elem->eoi_time) {
 		list_add(&info->eoi_list, &eoi->eoi_list);
 		mod_delayed_work_on(info->eoi_cpu, system_wq,
 				    &eoi->delayed, delay);