All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] xen-netback: correctly schedule rate-limited queues
@ 2017-06-21  9:21 Wei Liu
  2017-06-21  9:38 ` Paul Durrant
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Wei Liu @ 2017-06-21  9:21 UTC (permalink / raw)
  To: netdev; +Cc: Xen-devel, Paul Durrant, David Miller, jean-louis, Wei Liu

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 <jean-louis@dupond.be>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Jean-Louis Dupond <jean-louis@dupond.be>
---
 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(-)

diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index 530586be05b4..5b1d2e8402d9 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -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;
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 8397f6c92451..e322a862ddfe 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -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;
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 602d408fa25e..5042ff8d449a 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -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;
 	}
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* RE: [PATCH net] xen-netback: correctly schedule rate-limited queues
  2017-06-21  9:21 [PATCH net] xen-netback: correctly schedule rate-limited queues Wei Liu
@ 2017-06-21  9:38 ` Paul Durrant
  2017-06-21  9:38 ` Paul Durrant
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Paul Durrant @ 2017-06-21  9:38 UTC (permalink / raw)
  To: Wei Liu, netdev; +Cc: Xen-devel, David Miller, jean-louis, Wei Liu

> -----Original Message-----
> From: Wei Liu [mailto:wei.liu2@citrix.com]
> Sent: 21 June 2017 10:21
> To: netdev@vger.kernel.org
> Cc: Xen-devel <xen-devel@lists.xenproject.org>; Paul Durrant
> <Paul.Durrant@citrix.com>; David Miller <davem@davemloft.net>; jean-
> louis@dupond.be; Wei Liu <wei.liu2@citrix.com>
> Subject: [PATCH net] 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.
> 
> Reported-by: Jean-Louis Dupond <jean-louis@dupond.be>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> Tested-by: Jean-Louis Dupond <jean-louis@dupond.be>

Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

> ---
>  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(-)
> 
> diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-
> netback/common.h
> index 530586be05b4..5b1d2e8402d9 100644
> --- a/drivers/net/xen-netback/common.h
> +++ b/drivers/net/xen-netback/common.h
> @@ -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;
> diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-
> netback/interface.c
> index 8397f6c92451..e322a862ddfe 100644
> --- a/drivers/net/xen-netback/interface.c
> +++ b/drivers/net/xen-netback/interface.c
> @@ -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;
> diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-
> netback/netback.c
> index 602d408fa25e..5042ff8d449a 100644
> --- a/drivers/net/xen-netback/netback.c
> +++ b/drivers/net/xen-netback/netback.c
> @@ -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;
>  	}
> --
> 2.11.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net] xen-netback: correctly schedule rate-limited queues
  2017-06-21  9:21 [PATCH net] xen-netback: correctly schedule rate-limited queues Wei Liu
  2017-06-21  9:38 ` Paul Durrant
@ 2017-06-21  9:38 ` Paul Durrant
  2017-06-22 15:16 ` David Miller
  2017-06-22 15:16 ` David Miller
  3 siblings, 0 replies; 10+ messages in thread
From: Paul Durrant @ 2017-06-21  9:38 UTC (permalink / raw)
  To: netdev; +Cc: Xen-devel, jean-louis, David Miller, Wei Liu

> -----Original Message-----
> From: Wei Liu [mailto:wei.liu2@citrix.com]
> Sent: 21 June 2017 10:21
> To: netdev@vger.kernel.org
> Cc: Xen-devel <xen-devel@lists.xenproject.org>; Paul Durrant
> <Paul.Durrant@citrix.com>; David Miller <davem@davemloft.net>; jean-
> louis@dupond.be; Wei Liu <wei.liu2@citrix.com>
> Subject: [PATCH net] 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.
> 
> Reported-by: Jean-Louis Dupond <jean-louis@dupond.be>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> Tested-by: Jean-Louis Dupond <jean-louis@dupond.be>

Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

> ---
>  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(-)
> 
> diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-
> netback/common.h
> index 530586be05b4..5b1d2e8402d9 100644
> --- a/drivers/net/xen-netback/common.h
> +++ b/drivers/net/xen-netback/common.h
> @@ -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;
> diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-
> netback/interface.c
> index 8397f6c92451..e322a862ddfe 100644
> --- a/drivers/net/xen-netback/interface.c
> +++ b/drivers/net/xen-netback/interface.c
> @@ -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;
> diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-
> netback/netback.c
> index 602d408fa25e..5042ff8d449a 100644
> --- a/drivers/net/xen-netback/netback.c
> +++ b/drivers/net/xen-netback/netback.c
> @@ -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;
>  	}
> --
> 2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net] xen-netback: correctly schedule rate-limited queues
  2017-06-21  9:21 [PATCH net] xen-netback: correctly schedule rate-limited queues Wei Liu
  2017-06-21  9:38 ` Paul Durrant
  2017-06-21  9:38 ` Paul Durrant
@ 2017-06-22 15:16 ` David Miller
  2017-07-27  8:21   ` Jean-Louis Dupond
  2017-07-27  8:21   ` Jean-Louis Dupond
  2017-06-22 15:16 ` David Miller
  3 siblings, 2 replies; 10+ messages in thread
From: David Miller @ 2017-06-22 15:16 UTC (permalink / raw)
  To: wei.liu2; +Cc: netdev, xen-devel, Paul.Durrant, jean-louis

From: Wei Liu <wei.liu2@citrix.com>
Date: Wed, 21 Jun 2017 10:21:22 +0100

> 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 <jean-louis@dupond.be>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> Tested-by: Jean-Louis Dupond <jean-louis@dupond.be>

Applied.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net] xen-netback: correctly schedule rate-limited queues
  2017-06-21  9:21 [PATCH net] xen-netback: correctly schedule rate-limited queues Wei Liu
                   ` (2 preceding siblings ...)
  2017-06-22 15:16 ` David Miller
@ 2017-06-22 15:16 ` David Miller
  3 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2017-06-22 15:16 UTC (permalink / raw)
  To: wei.liu2; +Cc: netdev, Paul.Durrant, jean-louis, xen-devel

From: Wei Liu <wei.liu2@citrix.com>
Date: Wed, 21 Jun 2017 10:21:22 +0100

> 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 <jean-louis@dupond.be>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> Tested-by: Jean-Louis Dupond <jean-louis@dupond.be>

Applied.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net] xen-netback: correctly schedule rate-limited queues
  2017-06-22 15:16 ` David Miller
  2017-07-27  8:21   ` Jean-Louis Dupond
@ 2017-07-27  8:21   ` Jean-Louis Dupond
  2017-07-27 16:35     ` David Miller
  2017-07-27 16:35     ` David Miller
  1 sibling, 2 replies; 10+ messages in thread
From: Jean-Louis Dupond @ 2017-07-27  8:21 UTC (permalink / raw)
  To: David Miller; +Cc: wei.liu2, netdev, xen-devel, Paul.Durrant

Op 2017-06-22 17:16, schreef David Miller:
> From: Wei Liu <wei.liu2@citrix.com>
> Date: Wed, 21 Jun 2017 10:21:22 +0100
> 
>> 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 <jean-louis@dupond.be>
>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>> Tested-by: Jean-Louis Dupond <jean-louis@dupond.be>
> 
> Applied.

Could this get applied to stable & LTS kernels also?
Seems important enough in my opinion.

Thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net] xen-netback: correctly schedule rate-limited queues
  2017-06-22 15:16 ` David Miller
@ 2017-07-27  8:21   ` Jean-Louis Dupond
  2017-07-27  8:21   ` Jean-Louis Dupond
  1 sibling, 0 replies; 10+ messages in thread
From: Jean-Louis Dupond @ 2017-07-27  8:21 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Paul.Durrant, wei.liu2, xen-devel

Op 2017-06-22 17:16, schreef David Miller:
> From: Wei Liu <wei.liu2@citrix.com>
> Date: Wed, 21 Jun 2017 10:21:22 +0100
> 
>> 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 <jean-louis@dupond.be>
>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>> Tested-by: Jean-Louis Dupond <jean-louis@dupond.be>
> 
> Applied.

Could this get applied to stable & LTS kernels also?
Seems important enough in my opinion.

Thanks!

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net] xen-netback: correctly schedule rate-limited queues
  2017-07-27  8:21   ` Jean-Louis Dupond
@ 2017-07-27 16:35     ` David Miller
  2017-07-27 16:35     ` David Miller
  1 sibling, 0 replies; 10+ messages in thread
From: David Miller @ 2017-07-27 16:35 UTC (permalink / raw)
  To: jean-louis; +Cc: wei.liu2, netdev, xen-devel, Paul.Durrant

From: Jean-Louis Dupond <jean-louis@dupond.be>
Date: Thu, 27 Jul 2017 10:21:56 +0200

> Op 2017-06-22 17:16, schreef David Miller:
>> From: Wei Liu <wei.liu2@citrix.com>
>> Date: Wed, 21 Jun 2017 10:21:22 +0100
>> 
>>> 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 <jean-louis@dupond.be>
>>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>>> Tested-by: Jean-Louis Dupond <jean-louis@dupond.be>
>> Applied.
> 
> Could this get applied to stable & LTS kernels also?
> Seems important enough in my opinion.

Sure, queued up.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net] xen-netback: correctly schedule rate-limited queues
  2017-07-27  8:21   ` Jean-Louis Dupond
  2017-07-27 16:35     ` David Miller
@ 2017-07-27 16:35     ` David Miller
  1 sibling, 0 replies; 10+ messages in thread
From: David Miller @ 2017-07-27 16:35 UTC (permalink / raw)
  To: jean-louis; +Cc: netdev, Paul.Durrant, wei.liu2, xen-devel

From: Jean-Louis Dupond <jean-louis@dupond.be>
Date: Thu, 27 Jul 2017 10:21:56 +0200

> Op 2017-06-22 17:16, schreef David Miller:
>> From: Wei Liu <wei.liu2@citrix.com>
>> Date: Wed, 21 Jun 2017 10:21:22 +0100
>> 
>>> 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 <jean-louis@dupond.be>
>>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>>> Tested-by: Jean-Louis Dupond <jean-louis@dupond.be>
>> Applied.
> 
> Could this get applied to stable & LTS kernels also?
> Seems important enough in my opinion.

Sure, queued up.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net] xen-netback: correctly schedule rate-limited queues
@ 2017-06-21  9:21 Wei Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Wei Liu @ 2017-06-21  9:21 UTC (permalink / raw)
  To: netdev; +Cc: Xen-devel, Paul Durrant, jean-louis, David Miller, Wei Liu

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 <jean-louis@dupond.be>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Jean-Louis Dupond <jean-louis@dupond.be>
---
 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(-)

diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index 530586be05b4..5b1d2e8402d9 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -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;
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 8397f6c92451..e322a862ddfe 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -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;
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 602d408fa25e..5042ff8d449a 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -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;
 	}
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-07-27 16:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-21  9:21 [PATCH net] xen-netback: correctly schedule rate-limited queues Wei Liu
2017-06-21  9:38 ` Paul Durrant
2017-06-21  9:38 ` Paul Durrant
2017-06-22 15:16 ` David Miller
2017-07-27  8:21   ` Jean-Louis Dupond
2017-07-27  8:21   ` Jean-Louis Dupond
2017-07-27 16:35     ` David Miller
2017-07-27 16:35     ` David Miller
2017-06-22 15:16 ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2017-06-21  9:21 Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.