linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geliang Tang <geliangtang@gmail.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>,
	"David S. Miller" <davem@davemloft.net>
Cc: Geliang Tang <geliangtang@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] net_sched: sch_fq: use rb_entry()
Date: Tue, 20 Dec 2016 22:02:15 +0800	[thread overview]
Message-ID: <6aa180710d70b09d4f81d3d219b3161077e1ff11.1482204526.git.geliangtang@gmail.com> (raw)
In-Reply-To: <ddabc96c798df194791134d8e070d728e2a7b59f.1482203698.git.geliangtang@gmail.com>

To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 net/sched/sch_fq.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/sched/sch_fq.c b/net/sched/sch_fq.c
index 86309a3..a4f738a 100644
--- a/net/sched/sch_fq.c
+++ b/net/sched/sch_fq.c
@@ -136,7 +136,7 @@ static void fq_flow_set_throttled(struct fq_sched_data *q, struct fq_flow *f)
 		struct fq_flow *aux;
 
 		parent = *p;
-		aux = container_of(parent, struct fq_flow, rate_node);
+		aux = rb_entry(parent, struct fq_flow, rate_node);
 		if (f->time_next_packet >= aux->time_next_packet)
 			p = &parent->rb_right;
 		else
@@ -188,7 +188,7 @@ static void fq_gc(struct fq_sched_data *q,
 	while (*p) {
 		parent = *p;
 
-		f = container_of(parent, struct fq_flow, fq_node);
+		f = rb_entry(parent, struct fq_flow, fq_node);
 		if (f->sk == sk)
 			break;
 
@@ -256,7 +256,7 @@ static struct fq_flow *fq_classify(struct sk_buff *skb, struct fq_sched_data *q)
 	while (*p) {
 		parent = *p;
 
-		f = container_of(parent, struct fq_flow, fq_node);
+		f = rb_entry(parent, struct fq_flow, fq_node);
 		if (f->sk == sk) {
 			/* socket might have been reallocated, so check
 			 * if its sk_hash is the same.
@@ -424,7 +424,7 @@ static void fq_check_throttled(struct fq_sched_data *q, u64 now)
 
 	q->time_next_delayed_flow = ~0ULL;
 	while ((p = rb_first(&q->delayed)) != NULL) {
-		struct fq_flow *f = container_of(p, struct fq_flow, rate_node);
+		struct fq_flow *f = rb_entry(p, struct fq_flow, rate_node);
 
 		if (f->time_next_packet > now) {
 			q->time_next_delayed_flow = f->time_next_packet;
@@ -563,7 +563,7 @@ static void fq_reset(struct Qdisc *sch)
 	for (idx = 0; idx < (1U << q->fq_trees_log); idx++) {
 		root = &q->fq_root[idx];
 		while ((p = rb_first(root)) != NULL) {
-			f = container_of(p, struct fq_flow, fq_node);
+			f = rb_entry(p, struct fq_flow, fq_node);
 			rb_erase(p, root);
 
 			fq_flow_purge(f);
@@ -593,7 +593,7 @@ static void fq_rehash(struct fq_sched_data *q,
 		oroot = &old_array[idx];
 		while ((op = rb_first(oroot)) != NULL) {
 			rb_erase(op, oroot);
-			of = container_of(op, struct fq_flow, fq_node);
+			of = rb_entry(op, struct fq_flow, fq_node);
 			if (fq_gc_candidate(of)) {
 				fcnt++;
 				kmem_cache_free(fq_flow_cachep, of);
@@ -606,7 +606,7 @@ static void fq_rehash(struct fq_sched_data *q,
 			while (*np) {
 				parent = *np;
 
-				nf = container_of(parent, struct fq_flow, fq_node);
+				nf = rb_entry(parent, struct fq_flow, fq_node);
 				BUG_ON(nf->sk == of->sk);
 
 				if (nf->sk > of->sk)
-- 
2.9.3

  parent reply	other threads:[~2016-12-20 14:03 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-20 14:02 [PATCH] dm bufio: use rb_entry() Geliang Tang
2016-12-20 14:02 ` [PATCH] drm/nouveau/dma: " Geliang Tang
2016-12-21 23:22   ` [Nouveau] " Ben Skeggs
2016-12-20 14:02 ` [PATCH] IB/qib: " Geliang Tang
2016-12-20 14:21   ` Leon Romanovsky
2016-12-20 15:01   ` Dennis Dalessandro
2016-12-20 19:34   ` Marciniszyn, Mike
2017-01-12 17:09   ` Doug Ledford
2016-12-20 14:02 ` [PATCH] netfilter: xt_connlimit: " Geliang Tang
2017-01-05 12:26   ` Pablo Neira Ayuso
2016-12-20 14:02 ` [PATCH] net/mlx5: " Geliang Tang
2016-12-20 14:19   ` Leon Romanovsky
2016-12-20 19:23   ` David Miller
2016-12-20 14:02 ` Geliang Tang [this message]
2016-12-20 16:38   ` [PATCH] net_sched: sch_fq: " Eric Dumazet
2016-12-20 19:23   ` David Miller
2016-12-20 14:02 ` [PATCH] net_sched: sch_netem: " Geliang Tang
2016-12-20 19:23   ` David Miller
2016-12-20 14:02 ` [PATCH] powerpc/perf/24x7: use rb_entry Geliang Tang
2019-07-08  1:19   ` Michael Ellerman
2016-12-20 14:02 ` [PATCH] RDS: use rb_entry() Geliang Tang
2016-12-20 14:20   ` Leon Romanovsky
2016-12-20 16:34   ` Santosh Shilimkar
2016-12-20 19:23   ` David Miller
2016-12-22  3:33   ` Doug Ledford
2016-12-20 14:02 ` [PATCH] xen/blkback: " Geliang Tang
2016-12-20 16:47   ` Konrad Rzeszutek Wilk
2016-12-20 17:44     ` Roger Pau Monné
2016-12-20 17:51       ` Konrad Rzeszutek Wilk
2016-12-20 21:53         ` Eric Dumazet
2016-12-20 22:07           ` Konrad Rzeszutek Wilk
2016-12-20 14:02 ` [PATCH] xen/evtchn: " Geliang Tang
2016-12-20 16:20   ` Juergen Gross
2016-12-22  9:07   ` Juergen Gross

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=6aa180710d70b09d4f81d3d219b3161077e1ff11.1482204526.git.geliangtang@gmail.com \
    --to=geliangtang@gmail.com \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=linux-kernel@vger.kernel.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 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).