From: Cong Wang <xiyou.wangcong@gmail.com>
To: netdev@vger.kernel.org
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Subject: [PATCH 11/13] net_sched: remove hashmask from Qdisc_class_hash
Date: Tue, 4 Nov 2014 09:56:34 -0800 [thread overview]
Message-ID: <1415123796-8093-12-git-send-email-xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <1415123796-8093-1-git-send-email-xiyou.wangcong@gmail.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
include/net/sch_generic.h | 8 +++++---
net/sched/sch_api.c | 9 +++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 89c3f37..1f30524 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -359,12 +359,14 @@ struct Qdisc_class_common {
struct Qdisc_class_hash {
struct hlist_head *hash;
unsigned int hashsize;
- unsigned int hashmask;
unsigned int hashelems;
};
-static inline unsigned int qdisc_class_hash(u32 id, u32 mask)
+static inline
+unsigned int qdisc_class_hash(unsigned int id, unsigned int hashsize)
{
+ unsigned int mask = hashsize- 1;
+
id ^= id >> 8;
id ^= id >> 4;
return id & mask;
@@ -376,7 +378,7 @@ qdisc_class_find(const struct Qdisc_class_hash *hash, u32 id)
struct Qdisc_class_common *cl;
unsigned int h;
- h = qdisc_class_hash(id, hash->hashmask);
+ h = qdisc_class_hash(id, hash->hashsize);
hlist_for_each_entry(cl, &hash->hash[h], hnode) {
if (cl->classid == id)
return cl;
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index f57d3c6..efc60d6 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -647,14 +647,13 @@ void qdisc_class_hash_grow(struct Qdisc *sch, struct Qdisc_class_hash *clhash)
struct Qdisc_class_common *cl;
struct hlist_node *next;
struct hlist_head *nhash, *ohash;
- unsigned int nsize, nmask, osize;
+ unsigned int nsize, osize;
unsigned int i, h;
/* Rehash when load factor exceeds 0.75 */
if (clhash->hashelems * 4 <= clhash->hashsize * 3)
return;
nsize = clhash->hashsize * 2;
- nmask = nsize - 1;
nhash = qdisc_class_hash_alloc(nsize);
if (nhash == NULL)
return;
@@ -665,13 +664,12 @@ void qdisc_class_hash_grow(struct Qdisc *sch, struct Qdisc_class_hash *clhash)
sch_tree_lock(sch);
for (i = 0; i < osize; i++) {
hlist_for_each_entry_safe(cl, next, &ohash[i], hnode) {
- h = qdisc_class_hash(cl->classid, nmask);
+ h = qdisc_class_hash(cl->classid, nsize);
hlist_add_head(&cl->hnode, &nhash[h]);
}
}
clhash->hash = nhash;
clhash->hashsize = nsize;
- clhash->hashmask = nmask;
sch_tree_unlock(sch);
qdisc_class_hash_free(ohash, osize);
@@ -686,7 +684,6 @@ int qdisc_class_hash_init(struct Qdisc_class_hash *clhash)
if (clhash->hash == NULL)
return -ENOMEM;
clhash->hashsize = size;
- clhash->hashmask = size - 1;
clhash->hashelems = 0;
return 0;
}
@@ -704,7 +701,7 @@ void qdisc_class_hash_insert(struct Qdisc_class_hash *clhash,
unsigned int h;
INIT_HLIST_NODE(&cl->hnode);
- h = qdisc_class_hash(cl->classid, clhash->hashmask);
+ h = qdisc_class_hash(cl->classid, clhash->hashsize);
hlist_add_head(&cl->hnode, &clhash->hash[h]);
clhash->hashelems++;
}
--
1.8.3.1
next prev parent reply other threads:[~2014-11-04 17:56 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-04 17:56 [PATCH 00/13] net_sched: misc cleanups and improvements Cong Wang
2014-11-04 17:56 ` [PATCH 01/13] net_sched: refactor out tcf_exts Cong Wang
2014-11-04 17:56 ` [PATCH 02/13] net_sched: introduce qdisc_peek() helper function Cong Wang
2014-11-04 18:45 ` Stephen Hemminger
2014-11-05 1:05 ` Cong Wang
2014-11-05 3:49 ` Herbert Xu
2014-11-06 2:50 ` Cong Wang
2014-11-04 17:56 ` [PATCH 03/13] net_sched: rename ->gso_skb to ->dequeued_skb Cong Wang
2014-11-04 17:56 ` [PATCH 04/13] net_sched: rename qdisc_drop() to qdisc_drop_skb() Cong Wang
2014-11-04 17:56 ` [PATCH 05/13] net_sched: introduce qdisc_drop() helper function Cong Wang
2014-11-04 17:56 ` [PATCH 06/13] net_sched: move some qdisc flag into qdisc ops Cong Wang
2014-11-04 17:56 ` [PATCH 07/13] net_sched: move TCQ_F_MQROOT " Cong Wang
2014-11-04 17:56 ` [PATCH 08/13] net_sched: use a flag to indicate fifo qdiscs instead of the name Cong Wang
2014-11-04 17:56 ` [PATCH 09/13] net_sched: redefine qdisc_create_dflt() Cong Wang
2014-11-04 17:56 ` [PATCH 10/13] net_sched: forbid setting default qdisc to inappropriate ones Cong Wang
2014-11-04 17:56 ` Cong Wang [this message]
2014-11-04 17:56 ` [PATCH 12/13] net_sched: remove useless qdisc_stab_lock Cong Wang
2014-11-04 17:56 ` [PATCH 13/13] net_sched: return NULL instead of ERR_PTR for qdisc_alloc() Cong Wang
2014-11-04 18:20 ` [PATCH 00/13] net_sched: misc cleanups and improvements Eric Dumazet
2014-11-04 19:56 ` David Miller
2014-11-05 1:25 ` Cong Wang
2014-11-05 1:47 ` Eric Dumazet
2014-11-06 18:05 ` Cong Wang
2014-11-06 18:17 ` Eric Dumazet
2014-11-06 19:03 ` David Miller
2014-11-06 18:21 ` Eric Dumazet
2014-11-06 19:02 ` David Miller
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=1415123796-8093-12-git-send-email-xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).