Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8bb8743 authored by Wei Liu's avatar Wei Liu Committed by Greg Kroah-Hartman
Browse files

xen-netback: correctly schedule rate-limited queues




[ Upstream commit dfa523ae9f2542bee4cddaea37b3be3e157f6e6b ]

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: default avatarJean-Louis Dupond <jean-louis@dupond.be>
Signed-off-by: default avatarWei Liu <wei.liu2@citrix.com>
Tested-by: default avatarJean-Louis Dupond <jean-louis@dupond.be>
Reviewed-by: default avatarPaul Durrant <paul.durrant@citrix.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d03994ea
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -195,6 +195,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;
+5 −1
Original line number Diff line number Diff line
@@ -99,6 +99,10 @@ int xenvif_poll(struct napi_struct *napi, int budget)

	if (work_done < budget) {
		napi_complete(napi);
		/* 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);
	}

+5 −1
Original line number Diff line number Diff line
@@ -819,6 +819,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;
}

static void tx_credit_callback(unsigned long data)
@@ -1336,8 +1337,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)) {
@@ -1354,6 +1357,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;
	}