Thread (27 messages) 27 messages, 3 authors, 2011-01-12

Re: [RFC] sched: CHOKe packet scheduler

flat view

From: Eric Dumazet <hidden>
Date: 2011-01-05 06:19:40

Le mardi 04 janvier 2011 à 16:29 -0800, Stephen Hemminger a écrit :
quoted hunk ↗ jump to hunk
+static struct sk_buff *skb_peek_random(struct sk_buff_head *list)
+{
+	struct sk_buff *skb = list->next;
+	unsigned int idx = net_random() % list->qlen;
+
+	while (skb && idx-- > 0)
+		skb = skb->next;
+
+	return skb;
+}
You could avoid the divide op :

unsigned int idx = reciprocal_divide(random32(), list->qlen);


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help