xen-netback: correctly schedule rate-limited queues
Subsystems (3)
PATCH 1/1 xen-netback: correctly schedule rate-limited queues
Add a flag to indicate if a queue is rate-limited. Test the flag in NAPI poll handler and avoid rescheduling the queue if true, otherwise we risk locking up the host. The rescheduling will be done in the timer callback function.
--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/interface.c | 6 +++++- drivers/net/xen-netback/netback.c | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-)
drivers/net/xen-netback/common.h +1 -0
@@ -199,6 +199,7 @@ struct xenvif_queue { /* Per-queue data for xenvif */unsigned long remaining_credit;struct timer_list credit_timeout;u64 credit_window_start; +bool rate_limited;/* Statistics */ struct xenvif_stats stats;
drivers/net/xen-netback/interface.c +5 -1
@@ -106,7 +106,11 @@ static int xenvif_poll(struct napi_struct *napi, int budget)if (work_done < budget) {napi_complete_done (napi, work_done); -xenvif_napi_schedule_or_enable_events (queue); +/* If the queue is rate-limited, it shall be +* rescheduled in the timer callback. +*/ +if (likely (!queue->rate_limited)) +xenvif_napi_schedule_or_enable_events (queue); }return work_done;
drivers/net/xen-netback/netback.c +5 -1
@@ -180,6 +180,7 @@ static void tx_add_credit(struct xenvif_queue *queue) max_credit =ULONG_MAX ;/* wrapped: clamp to ULONG_MAX */ queue->remaining_credit =min (max_credit, max_burst); + queue->rate_limited = false; }void xenvif_tx_credit_callback (unsigned long data)
@@ -686,8 +687,10 @@ static bool tx_credit_exceeded(struct xenvif_queue *queue, unsigned size)msecs_to_jiffies (queue->credit_usec /1000 );/* Timer could already be pending in rare cases. */ -if (timer_pending (&queue->credit_timeout)) +if (timer_pending (&queue->credit_timeout)) { + queue->rate_limited = true;return true; + }/* Passed the point where we can replenish credit? */ if (time_after_eq64 (now, next_credit)) {
@@ -702,6 +705,7 @@ static bool tx_credit_exceeded(struct xenvif_queue *queue, unsigned size)mod_timer (&queue->credit_timeout, next_credit); queue->credit_window_start = next_credit; + queue->rate_limited = true;return true; }
Signature · 1 line
2.11.0
Quoted 9 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 21 June 2017 10:21
To: [email protected]
Cc: Xen-devel <[email protected]>; Paul Durrant <[email protected]>; David Miller <[email protected]>; jean- [email protected]; Wei Liu <[email protected]>
Subject: [PATCH net] xen-netback: correctly schedule rate-limited queues
Quoted 8 lines
Add a flag to indicate if a queue is rate-limited. Test the flag in NAPI poll handler and avoid rescheduling the queue if true, otherwise we risk locking up the host. The rescheduling will be done in the timer callback function.
Reported-by Jean-Louis Dupond <[email protected]>Signed-off-by Wei Liu <[email protected]>Tested-by Jean-Louis Dupond <[email protected]>
Quoted 74 lines
--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/interface.c | 6 +++++- drivers/net/xen-netback/netback.c | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-)drivers/net/xen- renamed from drivers/net/xen-netback/common.h +0
-0
netback/common.h
index530586be05b4..5b1d2e8402d9100644drivers/net/xen-netback/common.h +1
-0@@ -199,6 +199,7 @@ struct xenvif_queue { /* Per-queue data for xenvif */unsigned long remaining_credit;struct timer_list credit_timeout;u64 credit_window_start; +bool rate_limited;/* Statistics */ struct xenvif_stats stats;drivers/net/xen- renamed from drivers/net/xen-netback/interface.c +0
-0
netback/interface.c
index8397f6c92451..e322a862ddfe100644drivers/net/xen-netback/interface.c +5
-1@@ -106,7 +106,11 @@ static int xenvif_poll(struct napi_struct *napi, int budget)if (work_done < budget) {napi_complete_done (napi, work_done); -xenvif_napi_schedule_or_enable_events (queue); +/* If the queue is rate-limited, it shall be +* rescheduled in the timer callback. +*/ +if (likely (!queue->rate_limited)) +xenvif_napi_schedule_or_enable_events (queue); }drivers/net/xen-netback/interface.c +0
-0return work_done;drivers/net/xen- renamed from drivers/net/xen-netback/netback.c +0
-0
netback/netback.c
index602d408fa25e..5042ff8d449a100644drivers/net/xen-netback/netback.c +0
-0@@ -180,6 +180,7 @@ static void tx_add_credit(struct xenvif_queue *queue) max_credit =ULONG_MAX ;/* wrapped: clamp to
ULONG_MAX*/drivers/net/xen-netback/netback.c +4
-1queue->remaining_credit =min (max_credit, max_burst); + queue->rate_limited = false; }void xenvif_tx_credit_callback (unsigned long data)@@ -686,8 +687,10 @@ static bool tx_credit_exceeded(struct xenvif_queue *queue, unsigned size)msecs_to_jiffies (queue->credit_usec /1000 );/* Timer could already be pending in rare cases. */ -if (timer_pending (&queue->credit_timeout)) +if (timer_pending (&queue->credit_timeout)) { + queue->rate_limited = true;return true; + }/* Passed the point where we can replenish credit? */ drivers/net/xen-netback/netback.c +1
-0if (time_after_eq64 (now, next_credit)) {@@ -702,6 +705,7 @@ static bool tx_credit_exceeded(struct xenvif_queue *queue, unsigned size)mod_timer (&queue->credit_timeout, next_credit); queue->credit_window_start = next_credit; + queue->rate_limited = true;return true;
Quoted 3 lines
}
--
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 9 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 21 June 2017 10:21
To: [email protected]
Cc: Xen-devel <[email protected]>; Paul Durrant <[email protected]>; David Miller <[email protected]>; jean- [email protected]; Wei Liu <[email protected]>
Subject: [PATCH net] xen-netback: correctly schedule rate-limited queues
Quoted 8 lines
Add a flag to indicate if a queue is rate-limited. Test the flag in NAPI poll handler and avoid rescheduling the queue if true, otherwise we risk locking up the host. The rescheduling will be done in the timer callback function.
Reported-by Jean-Louis Dupond <[email protected]>Signed-off-by Wei Liu <[email protected]>Tested-by Jean-Louis Dupond <[email protected]>
Quoted 77 lines
--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/interface.c | 6 +++++- drivers/net/xen-netback/netback.c | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-)drivers/net/xen- renamed from drivers/net/xen-netback/common.h +0
-0
netback/common.h
index530586be05b4..5b1d2e8402d9100644drivers/net/xen-netback/common.h +1
-0@@ -199,6 +199,7 @@ struct xenvif_queue { /* Per-queue data for xenvif */unsigned long remaining_credit;struct timer_list credit_timeout;u64 credit_window_start; +bool rate_limited;/* Statistics */ struct xenvif_stats stats;drivers/net/xen- renamed from drivers/net/xen-netback/interface.c +0
-0
netback/interface.c
index8397f6c92451..e322a862ddfe100644drivers/net/xen-netback/interface.c +5
-1@@ -106,7 +106,11 @@ static int xenvif_poll(struct napi_struct *napi, int budget)if (work_done < budget) {napi_complete_done (napi, work_done); -xenvif_napi_schedule_or_enable_events (queue); +/* If the queue is rate-limited, it shall be +* rescheduled in the timer callback. +*/ +if (likely (!queue->rate_limited)) +xenvif_napi_schedule_or_enable_events (queue); }drivers/net/xen-netback/interface.c +0
-0return work_done;drivers/net/xen- renamed from drivers/net/xen-netback/netback.c +0
-0
netback/netback.c
index602d408fa25e..5042ff8d449a100644drivers/net/xen-netback/netback.c +0
-0@@ -180,6 +180,7 @@ static void tx_add_credit(struct xenvif_queue *queue) max_credit =ULONG_MAX ;/* wrapped: clamp to
ULONG_MAX*/drivers/net/xen-netback/netback.c +4
-1queue->remaining_credit =min (max_credit, max_burst); + queue->rate_limited = false; }void xenvif_tx_credit_callback (unsigned long data)@@ -686,8 +687,10 @@ static bool tx_credit_exceeded(struct xenvif_queue *queue, unsigned size)msecs_to_jiffies (queue->credit_usec /1000 );/* Timer could already be pending in rare cases. */ -if (timer_pending (&queue->credit_timeout)) +if (timer_pending (&queue->credit_timeout)) { + queue->rate_limited = true;return true; + }/* Passed the point where we can replenish credit? */ drivers/net/xen-netback/netback.c +1
-0if (time_after_eq64 (now, next_credit)) {@@ -702,6 +705,7 @@ static bool tx_credit_exceeded(struct xenvif_queue *queue, unsigned size)mod_timer (&queue->credit_timeout, next_credit); queue->credit_window_start = next_credit; + queue->rate_limited = true;return true;}
--
2.11.0
From: Wei Liu <[email protected]>
Date: Wed, 21 Jun 2017 10:21:22 +0100
Quoted 8 lines
Add a flag to indicate if a queue is rate-limited. Test the flag in NAPI poll handler and avoid rescheduling the queue if true, otherwise we risk locking up the host. The rescheduling will be done in the timer callback function.
Reported-by Jean-Louis Dupond <[email protected]>Signed-off-by Wei Liu <[email protected]>Tested-by Jean-Louis Dupond <[email protected]>
Applied.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
From: Wei Liu <[email protected]>
Date: Wed, 21 Jun 2017 10:21:22 +0100
Quoted 8 lines
Add a flag to indicate if a queue is rate-limited. Test the flag in NAPI poll handler and avoid rescheduling the queue if true, otherwise we risk locking up the host. The rescheduling will be done in the timer callback function.
Reported-by Jean-Louis Dupond <[email protected]>Signed-off-by Wei Liu <[email protected]>Tested-by Jean-Louis Dupond <[email protected]>
Applied.
Op 2017-06-22 17:16, schreef David Miller:
Quoted 8 lines
From: Wei Liu <[email protected]>
Date: Wed, 21 Jun 2017 10:21:22 +0100Quoted 5 lines
Add a flag to indicate if a queue is rate-limited. Test the flag in NAPI poll handler and avoid rescheduling the queue if true, otherwise we risk locking up the host. The rescheduling will be done in the timer callback function.
Quoted 5 lines
Quoted 3 lines
Reported-by Jean-Louis Dupond <[email protected]>Signed-off-by Wei Liu <[email protected]>Tested-by Jean-Louis Dupond <[email protected]>Applied.
Could this get applied to stable & LTS kernels also? Seems important enough in my opinion.
Thanks!
David Miller
maintainerFrom: Jean-Louis Dupond <[email protected]>
Date: Thu, 27 Jul 2017 10:21:56 +0200
Quoted 11 lines
Op 2017-06-22 17:16, schreef David Miller:
Quoted 10 lines
From: Wei Liu <[email protected]>
Date: Wed, 21 Jun 2017 10:21:22 +0100Quoted 7 lines
Add a flag to indicate if a queue is rate-limited. Test the flag in NAPI poll handler and avoid rescheduling the queue if true, otherwise we risk locking up the host. The rescheduling will be done in the timer callback function.
Reported-by Jean-Louis Dupond <[email protected]>Signed-off-by Wei Liu <[email protected]>Tested-by Jean-Louis Dupond <[email protected]>
Quoted 4 lines
Quoted 1 line
Applied.
Could this get applied to stable & LTS kernels also? Seems important enough in my opinion.
Sure, queued up.
David Miller
maintainerFrom: Jean-Louis Dupond <[email protected]>
Date: Thu, 27 Jul 2017 10:21:56 +0200
Quoted 11 lines
Op 2017-06-22 17:16, schreef David Miller:
Quoted 10 lines
From: Wei Liu <[email protected]>
Date: Wed, 21 Jun 2017 10:21:22 +0100Quoted 7 lines
Add a flag to indicate if a queue is rate-limited. Test the flag in NAPI poll handler and avoid rescheduling the queue if true, otherwise we risk locking up the host. The rescheduling will be done in the timer callback function.
Reported-by Jean-Louis Dupond <[email protected]>Signed-off-by Wei Liu <[email protected]>Tested-by Jean-Louis Dupond <[email protected]>
Quoted 4 lines
Quoted 1 line
Applied.
Could this get applied to stable & LTS kernels also? Seems important enough in my opinion.
Sure, queued up.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Op 2017-06-22 17:16, schreef David Miller:
Quoted 8 lines
From: Wei Liu <[email protected]>
Date: Wed, 21 Jun 2017 10:21:22 +0100Quoted 5 lines
Add a flag to indicate if a queue is rate-limited. Test the flag in NAPI poll handler and avoid rescheduling the queue if true, otherwise we risk locking up the host. The rescheduling will be done in the timer callback function.
Quoted 5 lines
Quoted 3 lines
Reported-by Jean-Louis Dupond <[email protected]>Signed-off-by Wei Liu <[email protected]>Tested-by Jean-Louis Dupond <[email protected]>Applied.
Could this get applied to stable & LTS kernels also? Seems important enough in my opinion.
Thanks!
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel