From patchwork Tue Dec 2 08:56:48 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarek Poplawski X-Patchwork-Id: 11745 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 92BB9DDDF8 for ; Tue, 2 Dec 2008 19:57:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752395AbYLBI4z (ORCPT ); Tue, 2 Dec 2008 03:56:55 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752104AbYLBI4z (ORCPT ); Tue, 2 Dec 2008 03:56:55 -0500 Received: from ey-out-2122.google.com ([74.125.78.27]:23651 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751305AbYLBI4y (ORCPT ); Tue, 2 Dec 2008 03:56:54 -0500 Received: by ey-out-2122.google.com with SMTP id 6so1228579eyi.37 for ; Tue, 02 Dec 2008 00:56:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:x-mutt-fcc :user-agent; bh=W0KxAJ87JDGw59IxWic8e/5vvG/kLqNOaGPOq59bz7M=; b=LaFDfq0wpqk8XuIJQNYWZE3d1HTvpZibHTCQte4VA8du8v1NFkWxA8vxZxwT5fkaM/ T2BkDfuad1jl8I7W2/Di0heAiyzQInaBzdIGce+idSoKFqS3/UQdNcQMb7LmGyGNbTfy Sq4P5yUYDzSxcpFrhbaw+na+w7vb9/Yphmk/k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:x-mutt-fcc:user-agent; b=HPiImtErB18iGhWxazjfcTI0qL+JDkUQTttL5dJydWKSXq55CxanzDTJhlM+eU7CHA Yb3iqLLoC/1E4dWmuE0Q7OdsITDqZrHTkAMDiP6kE1ltSYkkVL0C2FN8W6gz1yfrXFoa WjvHxjITWBeIBkFmllEGVm7sUrIVzEg34XTqo= Received: by 10.210.81.10 with SMTP id e10mr13697680ebb.187.1228208213445; Tue, 02 Dec 2008 00:56:53 -0800 (PST) Received: from ff.dom.local (bv170.internetdsl.tpnet.pl [80.53.205.170]) by mx.google.com with ESMTPS id 7sm8309919eyg.52.2008.12.02.00.56.51 (version=SSLv3 cipher=RC4-MD5); Tue, 02 Dec 2008 00:56:53 -0800 (PST) Date: Tue, 2 Dec 2008 08:56:48 +0000 From: Jarek Poplawski To: David Miller Cc: Martin Devera , Patrick McHardy , netdev@vger.kernel.org Subject: [PATCH 3/3] pkt_sched: sch_htb: Clean htb_class prio and quantum fields Message-ID: <20081202085648.GC10412@ff.dom.local> MIME-Version: 1.0 Content-Disposition: inline X-Mutt-Fcc: =outbox User-Agent: Mutt/1.5.18 (2008-05-17) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org While implementing htb_parent_to_leaf() there where added backup prio and quantum struct htb_class fields to preserve these values for inner classes in case of their return to leaf. This patch cleans this a bit by removing union leaf duplicates. Signed-off-by: Jarek Poplawski --- net/sched/sch_htb.c | 41 ++++++++++++++++------------------------- 1 files changed, 16 insertions(+), 25 deletions(-) diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 7a71e94..80cb94d 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -84,11 +84,12 @@ struct htb_class { unsigned int children; struct htb_class *parent; /* parent class */ + int prio; /* these two are used only by leaves... */ + int quantum; /* but stored for parent-to-leaf return */ + union { struct htb_class_leaf { struct Qdisc *q; - int prio; - int quantum; int deficit[TC_HTB_MAXDEPTH]; struct list_head drop_list; } leaf; @@ -122,10 +123,6 @@ struct htb_class { psched_tdiff_t mbuffer; /* max wait time */ long tokens, ctokens; /* current number of tokens */ psched_time_t t_c; /* checkpoint time */ - - int prio; /* For parent to leaf return possible here */ - int quantum; /* we do backup. Finally full replacement */ - /* of un.leaf originals should be done. */ }; static inline long L2T(struct htb_class *cl, struct qdisc_rate_table *rate, @@ -523,10 +520,10 @@ static inline void htb_activate(struct htb_sched *q, struct htb_class *cl) WARN_ON(cl->level || !cl->un.leaf.q || !cl->un.leaf.q->q.qlen); if (!cl->prio_activity) { - cl->prio_activity = 1 << cl->un.leaf.prio; + cl->prio_activity = 1 << cl->prio; htb_activate_prios(q, cl); list_add_tail(&cl->un.leaf.drop_list, - q->drops + cl->un.leaf.prio); + q->drops + cl->prio); } } @@ -816,7 +813,7 @@ next: if (likely(skb != NULL)) { cl->un.leaf.deficit[level] -= qdisc_pkt_len(skb); if (cl->un.leaf.deficit[level] < 0) { - cl->un.leaf.deficit[level] += cl->un.leaf.quantum; + cl->un.leaf.deficit[level] += cl->quantum; htb_next_rb_node((level ? cl->parent->un.inner.ptr : q-> ptr[0]) + prio); } @@ -1050,8 +1047,8 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg, opt.buffer = cl->buffer; opt.ceil = cl->ceil->rate; opt.cbuffer = cl->cbuffer; - opt.quantum = cl->un.leaf.quantum; - opt.prio = cl->un.leaf.prio; + opt.quantum = cl->quantum; + opt.prio = cl->prio; opt.level = cl->level; NLA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt); @@ -1155,8 +1152,6 @@ static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl, memset(&parent->un.inner, 0, sizeof(parent->un.inner)); INIT_LIST_HEAD(&parent->un.leaf.drop_list); parent->un.leaf.q = new_q ? new_q : &noop_qdisc; - parent->un.leaf.quantum = parent->quantum; - parent->un.leaf.prio = parent->prio; parent->tokens = parent->buffer; parent->ctokens = parent->cbuffer; parent->t_c = psched_get_time(); @@ -1400,27 +1395,23 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, /* it used to be a nasty bug here, we have to check that node is really leaf before changing cl->un.leaf ! */ if (!cl->level) { - cl->un.leaf.quantum = rtab->rate.rate / q->rate2quantum; - if (!hopt->quantum && cl->un.leaf.quantum < 1000) { + cl->quantum = rtab->rate.rate / q->rate2quantum; + if (!hopt->quantum && cl->quantum < 1000) { printk(KERN_WARNING "HTB: quantum of class %X is small. Consider r2q change.\n", cl->common.classid); - cl->un.leaf.quantum = 1000; + cl->quantum = 1000; } - if (!hopt->quantum && cl->un.leaf.quantum > 200000) { + if (!hopt->quantum && cl->quantum > 200000) { printk(KERN_WARNING "HTB: quantum of class %X is big. Consider r2q change.\n", cl->common.classid); - cl->un.leaf.quantum = 200000; + cl->quantum = 200000; } if (hopt->quantum) - cl->un.leaf.quantum = hopt->quantum; - if ((cl->un.leaf.prio = hopt->prio) >= TC_HTB_NUMPRIO) - cl->un.leaf.prio = TC_HTB_NUMPRIO - 1; - - /* backup for htb_parent_to_leaf */ - cl->quantum = cl->un.leaf.quantum; - cl->prio = cl->un.leaf.prio; + cl->quantum = hopt->quantum; + if ((cl->prio = hopt->prio) >= TC_HTB_NUMPRIO) + cl->prio = TC_HTB_NUMPRIO - 1; } cl->buffer = hopt->buffer;