All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Corey Hickey <bugfood-ml@fatooh.org>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 1/7] Preparatory refactoring part 1.
Date: Mon, 30 Jul 2007 15:51:05 +0200	[thread overview]
Message-ID: <46ADECC9.7010303@trash.net> (raw)
In-Reply-To: <11857548774008-git-send-email-bugfood-ml@fatooh.org>

Corey Hickey wrote:
> diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
> index 9579573..8ae077f 100644
> --- a/net/sched/sch_sfq.c
> +++ b/net/sched/sch_sfq.c
> @@ -77,6 +77,9 @@
>  #define SFQ_DEPTH		128
>  #define SFQ_HASH_DIVISOR	1024
>  
> +#define SFQ_HEAD 0
> +#define SFQ_TAIL 1
> +
>  /* This type should contain at least SFQ_DEPTH*2 values */
>  typedef unsigned char sfq_index;
>  
> @@ -244,10 +247,8 @@ static unsigned int sfq_drop(struct Qdisc *sch)
>  	return 0;
>  }
>  
> -static int
> -sfq_enqueue(struct sk_buff *skb, struct Qdisc* sch)
> +static void sfq_q_enqueue(struct sk_buff *skb, struct sfq_sched_data *q, unsigned int end)


Please make sure to break at 80 chars and to keep the style
in this file consistent (newline before function name).

>  {
> -	struct sfq_sched_data *q = qdisc_priv(sch);
>  	unsigned hash = sfq_hash(q, skb);
>  	sfq_index x;
>  
> @@ -256,8 +257,12 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc* sch)
>  		q->ht[hash] = x = q->dep[SFQ_DEPTH].next;
>  		q->hash[x] = hash;
>  	}
> -	sch->qstats.backlog += skb->len;


Why not keep this instead of having both callers do it?

> -	__skb_queue_tail(&q->qs[x], skb);
> +
> +	if (end == SFQ_TAIL)
> +		__skb_queue_tail(&q->qs[x], skb);
> +	else
> +		__skb_queue_head(&q->qs[x], skb);
> +
>  	sfq_inc(q, x);
>  	if (q->qs[x].qlen == 1) {		/* The flow is new */
>  		if (q->tail == SFQ_DEPTH) {	/* It is the first flow */
> @@ -270,12 +275,21 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc* sch)
>  			q->tail = x;
>  		}
>  	}
> +}
> +
> +static int
> +sfq_enqueue(struct sk_buff *skb, struct Qdisc* sch)
> +{
> +	struct sfq_sched_data *q = qdisc_priv(sch);


newline please.

> +	sfq_q_enqueue(skb, q, SFQ_TAIL);
> +	sch->qstats.backlog += skb->len;
>  	if (++sch->q.qlen < q->limit-1) {
>  		sch->bstats.bytes += skb->len;
>  		sch->bstats.packets++;
>  		return 0;
>  	}
>  
> +	sch->qstats.drops++;


sfq_drop already increments this.

>  	sfq_drop(sch);
>  	return NET_XMIT_CN;
>  }
> @@ -284,28 +298,8 @@ static int
>  sfq_requeue(struct sk_buff *skb, struct Qdisc* sch)
>  {
>  	struct sfq_sched_data *q = qdisc_priv(sch);

newline please

> -	unsigned hash = sfq_hash(q, skb);
> -	sfq_index x;
> -
> -	x = q->ht[hash];
> -	if (x == SFQ_DEPTH) {
> -		q->ht[hash] = x = q->dep[SFQ_DEPTH].next;
> -		q->hash[x] = hash;
> -	}
> +	sfq_q_enqueue(skb, q, SFQ_HEAD);
>  	sch->qstats.backlog += skb->len;
> -	__skb_queue_head(&q->qs[x], skb);
> -	sfq_inc(q, x);
> -	if (q->qs[x].qlen == 1) {		/* The flow is new */
> -		if (q->tail == SFQ_DEPTH) {	/* It is the first flow */
> -			q->tail = x;
> -			q->next[x] = x;
> -			q->allot[x] = q->quantum;
> -		} else {
> -			q->next[x] = q->next[q->tail];
> -			q->next[q->tail] = x;
> -			q->tail = x;
> -		}
> -	}
>  	if (++sch->q.qlen < q->limit - 1) {
>  		sch->qstats.requeues++;
>  		return 0;
> @@ -316,13 +310,8 @@ sfq_requeue(struct sk_buff *skb, struct Qdisc* sch)
>  	return NET_XMIT_CN;
>  }
>  
> -
> -
> -
> -static struct sk_buff *
> -sfq_dequeue(struct Qdisc* sch)
> +static struct sk_buff *sfq_q_dequeue(struct sfq_sched_data *q)


Keep style consistent please.

>  {
> -	struct sfq_sched_data *q = qdisc_priv(sch);
>  	struct sk_buff *skb;
>  	sfq_index a, old_a;
>  
> @@ -335,8 +324,6 @@ sfq_dequeue(struct Qdisc* sch)
>  	/* Grab packet */
>  	skb = __skb_dequeue(&q->qs[a]);
>  	sfq_dec(q, a);
> -	sch->q.qlen--;
> -	sch->qstats.backlog -= skb->len;
>  
>  	/* Is the slot empty? */
>  	if (q->qs[a].qlen == 0) {
> @@ -353,6 +340,21 @@ sfq_dequeue(struct Qdisc* sch)
>  		a = q->next[a];
>  		q->allot[a] += q->quantum;
>  	}
> +
> +	return skb;
> +}
> +
> +static struct sk_buff
> +*sfq_dequeue(struct Qdisc* sch)
> +{
> +	struct sfq_sched_data *q = qdisc_priv(sch);
> +	struct sk_buff *skb;
> +
> +	skb = sfq_q_dequeue(q);
> +	if (skb == NULL)
> +		return NULL;
> +	sch->q.qlen--;
> +	sch->qstats.backlog -= skb->len;
>  	return skb;
>  }
>  


  reply	other threads:[~2007-07-30 13:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-30  0:21 SFQ: backport some features from ESFQ (try 2) Corey Hickey
2007-07-30  0:21 ` [PATCH 1/7] Preparatory refactoring part 1 Corey Hickey
2007-07-30 13:51   ` Patrick McHardy [this message]
2007-07-31  1:26     ` Corey Hickey
2007-07-31 10:46       ` Patrick McHardy
2007-07-30  0:21 ` [PATCH 2/7] Preparatory refactoring part 2 Corey Hickey
2007-07-30 13:59   ` Patrick McHardy
2007-07-31  7:43     ` Corey Hickey
2007-07-30  0:21 ` [PATCH 3/7] Move two functions Corey Hickey
2007-07-30  0:21 ` [PATCH 4/7] Add "depth" Corey Hickey
2007-07-30  0:21 ` [PATCH 5/7] Add divisor Corey Hickey
2007-07-30  0:21 ` [PATCH 6/7] Make qdisc changeable Corey Hickey
2007-07-30 14:11   ` Patrick McHardy
2007-07-31  7:43     ` Corey Hickey
2007-08-06  2:47     ` Corey Hickey
2007-08-06 12:06       ` Patrick McHardy
2007-07-30  0:21 ` [PATCH 7/7] Remove comments about hardcoded values Corey Hickey
2007-07-30  0:21 ` [PATCH] [iproute2] SFQ: Support changing depth and divisor Corey Hickey
  -- strict thread matches above, loose matches on Subject: below --
2007-07-29  7:08 [PATCH 0/7] SFQ: backport some features from ESFQ Corey Hickey
2007-07-29  7:08 ` [PATCH 1/7] Preparatory refactoring part 1 Corey Hickey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46ADECC9.7010303@trash.net \
    --to=kaber@trash.net \
    --cc=bugfood-ml@fatooh.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.