All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] sfq: whitespace cleanup
       [not found] ` <20080118144730.7878f12a@deepthought>
@ 2008-01-19  0:09   ` Stephen Hemminger
  2008-01-19  4:18   ` [PATCH 2/2] SFQ: use net_random Paul E. McKenney
       [not found]   ` <20080118144837.0a3593c5@deepthought>
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2008-01-19  0:09 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

Add whitespace around operators, and add a few blank lines
to improve readability.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


--- a/net/sched/sch_sfq.c	2008-01-17 08:33:04.000000000 -0800
+++ b/net/sched/sch_sfq.c	2008-01-17 08:43:51.000000000 -0800
@@ -122,7 +122,7 @@ static unsigned sfq_hash(struct sfq_sche
 	{
 		const struct iphdr *iph = ip_hdr(skb);
 		h = iph->daddr;
-		h2 = iph->saddr^iph->protocol;
+		h2 = iph->saddr ^ iph->protocol;
 		if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&
 		    (iph->protocol == IPPROTO_TCP ||
 		     iph->protocol == IPPROTO_UDP ||
@@ -137,7 +137,7 @@ static unsigned sfq_hash(struct sfq_sche
 	{
 		struct ipv6hdr *iph = ipv6_hdr(skb);
 		h = iph->daddr.s6_addr32[3];
-		h2 = iph->saddr.s6_addr32[3]^iph->nexthdr;
+		h2 = iph->saddr.s6_addr32[3] ^ iph->nexthdr;
 		if (iph->nexthdr == IPPROTO_TCP ||
 		    iph->nexthdr == IPPROTO_UDP ||
 		    iph->nexthdr == IPPROTO_UDPLITE ||
@@ -148,9 +148,10 @@ static unsigned sfq_hash(struct sfq_sche
 		break;
 	}
 	default:
-		h = (u32)(unsigned long)skb->dst^skb->protocol;
-		h2 = (u32)(unsigned long)skb->sk;
+		h = (unsigned long)skb->dst ^ skb->protocol;
+		h2 = (unsigned long)skb->sk;
 	}
+
 	return sfq_fold_hash(q, h, h2);
 }
 
@@ -208,7 +209,7 @@ static unsigned int sfq_drop(struct Qdis
 	   drop a packet from it */
 
 	if (d > 1) {
-		sfq_index x = q->dep[d+SFQ_DEPTH].next;
+		sfq_index x = q->dep[d + SFQ_DEPTH].next;
 		skb = q->qs[x].prev;
 		len = skb->len;
 		__skb_unlink(skb, &q->qs[x]);
@@ -241,7 +242,7 @@ static unsigned int sfq_drop(struct Qdis
 }
 
 static int
-sfq_enqueue(struct sk_buff *skb, struct Qdisc* sch)
+sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 {
 	struct sfq_sched_data *q = qdisc_priv(sch);
 	unsigned hash = sfq_hash(q, skb);
@@ -252,6 +253,7 @@ sfq_enqueue(struct sk_buff *skb, struct 
 		q->ht[hash] = x = q->dep[SFQ_DEPTH].next;
 		q->hash[x] = hash;
 	}
+
 	/* If selected queue has length q->limit, this means that
 	 * all another queues are empty and that we do simple tail drop,
 	 * i.e. drop _this_ packet.
@@ -284,7 +286,7 @@ sfq_enqueue(struct sk_buff *skb, struct 
 }
 
 static int
-sfq_requeue(struct sk_buff *skb, struct Qdisc* sch)
+sfq_requeue(struct sk_buff *skb, struct Qdisc *sch)
 {
 	struct sfq_sched_data *q = qdisc_priv(sch);
 	unsigned hash = sfq_hash(q, skb);
@@ -295,6 +297,7 @@ sfq_requeue(struct sk_buff *skb, struct 
 		q->ht[hash] = x = q->dep[SFQ_DEPTH].next;
 		q->hash[x] = hash;
 	}
+
 	sch->qstats.backlog += skb->len;
 	__skb_queue_head(&q->qs[x], skb);
 	/* If selected queue has length q->limit+1, this means that
@@ -310,6 +313,7 @@ sfq_requeue(struct sk_buff *skb, struct 
 		kfree_skb(skb);
 		return NET_XMIT_CN;
 	}
+
 	sfq_inc(q, x);
 	if (q->qs[x].qlen == 1) {		/* The flow is new */
 		if (q->tail == SFQ_DEPTH) {	/* It is the first flow */
@@ -322,6 +326,7 @@ sfq_requeue(struct sk_buff *skb, struct 
 			q->tail = x;
 		}
 	}
+
 	if (++sch->q.qlen <= q->limit) {
 		sch->qstats.requeues++;
 		return 0;
@@ -336,7 +341,7 @@ sfq_requeue(struct sk_buff *skb, struct 
 
 
 static struct sk_buff *
-sfq_dequeue(struct Qdisc* sch)
+sfq_dequeue(struct Qdisc *sch)
 {
 	struct sfq_sched_data *q = qdisc_priv(sch);
 	struct sk_buff *skb;
@@ -373,7 +378,7 @@ sfq_dequeue(struct Qdisc* sch)
 }
 
 static void
-sfq_reset(struct Qdisc* sch)
+sfq_reset(struct Qdisc *sch)
 {
 	struct sk_buff *skb;
 
@@ -383,7 +388,7 @@ sfq_reset(struct Qdisc* sch)
 
 static void sfq_perturbation(unsigned long arg)
 {
-	struct Qdisc *sch = (struct Qdisc*)arg;
+	struct Qdisc *sch = (struct Qdisc *)arg;
 	struct sfq_sched_data *q = qdisc_priv(sch);
 
 	q->perturbation = net_random();
@@ -403,7 +408,7 @@ static int sfq_change(struct Qdisc *sch,
 
 	sch_tree_lock(sch);
 	q->quantum = ctl->quantum ? : psched_mtu(sch->dev);
-	q->perturb_period = ctl->perturb_period*HZ;
+	q->perturb_period = ctl->perturb_period * HZ;
 	if (ctl->limit)
 		q->limit = min_t(u32, ctl->limit, SFQ_DEPTH - 1);
 
@@ -430,13 +435,15 @@ static int sfq_init(struct Qdisc *sch, s
 	timer->data = (unsigned long)sch;;
 	init_timer_deferrable(&q->perturb_timer);
 
-	for (i=0; i<SFQ_HASH_DIVISOR; i++)
+	for (i = 0; i < SFQ_HASH_DIVISOR; i++)
 		q->ht[i] = SFQ_DEPTH;
-	for (i=0; i<SFQ_DEPTH; i++) {
+
+	for (i = 0; i < SFQ_DEPTH; i++) {
 		skb_queue_head_init(&q->qs[i]);
-		q->dep[i+SFQ_DEPTH].next = i+SFQ_DEPTH;
-		q->dep[i+SFQ_DEPTH].prev = i+SFQ_DEPTH;
+		q->dep[i + SFQ_DEPTH].next = i + SFQ_DEPTH;
+		q->dep[i + SFQ_DEPTH].prev = i + SFQ_DEPTH;
 	}
+
 	q->limit = SFQ_DEPTH - 1;
 	q->max_depth = 0;
 	q->tail = SFQ_DEPTH;
@@ -449,7 +456,8 @@ static int sfq_init(struct Qdisc *sch, s
 		if (err)
 			return err;
 	}
-	for (i=0; i<SFQ_DEPTH; i++)
+
+	for (i = 0; i < SFQ_DEPTH; i++)
 		sfq_link(q, i);
 	return 0;
 }
@@ -467,7 +475,7 @@ static int sfq_dump(struct Qdisc *sch, s
 	struct tc_sfq_qopt opt;
 
 	opt.quantum = q->quantum;
-	opt.perturb_period = q->perturb_period/HZ;
+	opt.perturb_period = q->perturb_period / HZ;
 
 	opt.limit = q->limit;
 	opt.divisor = SFQ_HASH_DIVISOR;

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

* Re: [PATCH 2/2] SFQ: use net_random
       [not found] ` <20080118144730.7878f12a@deepthought>
  2008-01-19  0:09   ` [PATCH 3/3] sfq: whitespace cleanup Stephen Hemminger
@ 2008-01-19  4:18   ` Paul E. McKenney
  2008-01-21  1:19     ` David Miller
       [not found]   ` <20080118144837.0a3593c5@deepthought>
  2 siblings, 1 reply; 4+ messages in thread
From: Paul E. McKenney @ 2008-01-19  4:18 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: David Miller, netdev

On Fri, Jan 18, 2008 at 02:47:30PM -0800, Stephen Hemminger wrote:
> SFQ doesn't need true random numbers, it is only using them to salt
> a hash. Therefore it is better to use net_random() and avoid any possible
> problems with depleting the entropy pool.

The random-number algorithm used by net_random() certainly does appear
to be considerably stronger than the one I used to generate the results
in the 1990 paper.  ;-)

Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
> 
> 
> --- a/net/sched/sch_sfq.c	2008-01-17 09:00:58.000000000 -0800
> +++ b/net/sched/sch_sfq.c	2008-01-17 09:03:26.000000000 -0800
> @@ -386,7 +386,7 @@ static void sfq_perturbation(unsigned lo
>  	struct Qdisc *sch = (struct Qdisc*)arg;
>  	struct sfq_sched_data *q = qdisc_priv(sch);
> 
> -	get_random_bytes(&q->perturbation, 4);
> +	q->perturbation = net_random();
> 
>  	if (q->perturb_period)
>  		mod_timer(&q->perturb_timer, jiffies + q->perturb_period);
> @@ -415,7 +415,7 @@ static int sfq_change(struct Qdisc *sch,
>  	del_timer(&q->perturb_timer);
>  	if (q->perturb_period) {
>  		mod_timer(&q->perturb_timer, jiffies + q->perturb_period);
> -		get_random_bytes(&q->perturbation, 4);
> +		q->perturbation = net_random();
>  	}
>  	sch_tree_unlock(sch);
>  	return 0;
> @@ -443,7 +443,7 @@ static int sfq_init(struct Qdisc *sch, s
>  	if (opt == NULL) {
>  		q->quantum = psched_mtu(sch->dev);
>  		q->perturb_period = 0;
> -		get_random_bytes(&q->perturbation, 4);
> +		q->perturbation = net_random();
>  	} else {
>  		int err = sfq_change(sch, opt);
>  		if (err)

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

* Re: [PATCH 2/2] SFQ: use net_random
  2008-01-19  4:18   ` [PATCH 2/2] SFQ: use net_random Paul E. McKenney
@ 2008-01-21  1:19     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2008-01-21  1:19 UTC (permalink / raw)
  To: paulmck; +Cc: stephen.hemminger, netdev

From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Date: Fri, 18 Jan 2008 20:18:20 -0800

> On Fri, Jan 18, 2008 at 02:47:30PM -0800, Stephen Hemminger wrote:
> > SFQ doesn't need true random numbers, it is only using them to salt
> > a hash. Therefore it is better to use net_random() and avoid any possible
> > problems with depleting the entropy pool.
> 
> The random-number algorithm used by net_random() certainly does appear
> to be considerably stronger than the one I used to generate the results
> in the 1990 paper.  ;-)
> 
> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

Also applied, thanks.

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

* Re: [PATCH 3/3] sfq: whitespace cleanup
       [not found]   ` <20080118144837.0a3593c5@deepthought>
@ 2008-01-21  1:21     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2008-01-21  1:21 UTC (permalink / raw)
  To: stephen.hemminger; +Cc: paulmck, netdev

From: Stephen Hemminger <stephen.hemminger@vyatta.com>
Date: Fri, 18 Jan 2008 14:48:37 -0800

> Add whitespace around operators, and add a few blank lines
> to improve readability.
> 
> Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>

Applied.

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

end of thread, other threads:[~2008-01-21  1:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20080118144309.3530ed2f@deepthought>
     [not found] ` <20080118144730.7878f12a@deepthought>
2008-01-19  0:09   ` [PATCH 3/3] sfq: whitespace cleanup Stephen Hemminger
2008-01-19  4:18   ` [PATCH 2/2] SFQ: use net_random Paul E. McKenney
2008-01-21  1:19     ` David Miller
     [not found]   ` <20080118144837.0a3593c5@deepthought>
2008-01-21  1:21     ` [PATCH 3/3] sfq: whitespace cleanup David Miller

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.