linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dm bufio: use rb_entry()
@ 2016-12-20 14:02 Geliang Tang
  2016-12-20 14:02 ` [PATCH] drm/nouveau/dma: " Geliang Tang
                   ` (9 more replies)
  0 siblings, 10 replies; 34+ messages in thread
From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: Geliang Tang, dm-devel, linux-raid, linux-kernel

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

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/md/dm-bufio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 84d2f0e..ae3c396 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -266,7 +266,7 @@ static struct dm_buffer *__find(struct dm_bufio_client *c, sector_t block)
 	struct dm_buffer *b;
 
 	while (n) {
-		b = container_of(n, struct dm_buffer, node);
+		b = rb_entry(n, struct dm_buffer, node);
 
 		if (b->block == block)
 			return b;
@@ -283,7 +283,7 @@ static void __insert(struct dm_bufio_client *c, struct dm_buffer *b)
 	struct dm_buffer *found;
 
 	while (*new) {
-		found = container_of(*new, struct dm_buffer, node);
+		found = rb_entry(*new, struct dm_buffer, node);
 
 		if (found->block == b->block) {
 			BUG_ON(found != b);
-- 
2.9.3

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

* [PATCH] drm/nouveau/dma: use rb_entry()
  2016-12-20 14:02 [PATCH] dm bufio: use rb_entry() Geliang Tang
@ 2016-12-20 14:02 ` Geliang Tang
  2016-12-21 23:22   ` [Nouveau] " Ben Skeggs
  2016-12-20 14:02 ` [PATCH] IB/qib: " Geliang Tang
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 34+ messages in thread
From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw)
  To: Ben Skeggs, David Airlie; +Cc: Geliang Tang, dri-devel, nouveau, linux-kernel

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

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/gpu/drm/nouveau/nvkm/engine/dma/base.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/base.c
index f11ebdd..4655d17 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/base.c
@@ -34,7 +34,7 @@ nvkm_dma_search(struct nvkm_dma *dma, struct nvkm_client *client, u64 object)
 	struct rb_node *node = client->dmaroot.rb_node;
 	while (node) {
 		struct nvkm_dmaobj *dmaobj =
-			container_of(node, typeof(*dmaobj), rb);
+			rb_entry(node, typeof(*dmaobj), rb);
 		if (object < dmaobj->handle)
 			node = node->rb_left;
 		else
@@ -67,7 +67,7 @@ nvkm_dma_oclass_new(struct nvkm_device *device,
 	dmaobj->handle = oclass->object;
 
 	while (*ptr) {
-		struct nvkm_dmaobj *obj = container_of(*ptr, typeof(*obj), rb);
+		struct nvkm_dmaobj *obj = rb_entry(*ptr, typeof(*obj), rb);
 		parent = *ptr;
 		if (dmaobj->handle < obj->handle)
 			ptr = &parent->rb_left;
-- 
2.9.3

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

* [PATCH] IB/qib: use rb_entry()
  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-20 14:02 ` Geliang Tang
  2016-12-20 14:21   ` Leon Romanovsky
                     ` (3 more replies)
  2016-12-20 14:02 ` [PATCH] netfilter: xt_connlimit: " Geliang Tang
                   ` (7 subsequent siblings)
  9 siblings, 4 replies; 34+ messages in thread
From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw)
  To: Mike Marciniszyn, Doug Ledford, Sean Hefty, Hal Rosenstock
  Cc: Geliang Tang, linux-rdma, linux-kernel

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

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/infiniband/hw/qib/qib_user_sdma.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_user_sdma.c b/drivers/infiniband/hw/qib/qib_user_sdma.c
index 3e0677c..926f3c8 100644
--- a/drivers/infiniband/hw/qib/qib_user_sdma.c
+++ b/drivers/infiniband/hw/qib/qib_user_sdma.c
@@ -144,8 +144,8 @@ qib_user_sdma_rb_search(struct rb_root *root, pid_t pid)
 	struct rb_node *node = root->rb_node;
 
 	while (node) {
-		sdma_rb_node = container_of(node,
-			struct qib_user_sdma_rb_node, node);
+		sdma_rb_node = rb_entry(node, struct qib_user_sdma_rb_node,
+					node);
 		if (pid < sdma_rb_node->pid)
 			node = node->rb_left;
 		else if (pid > sdma_rb_node->pid)
@@ -164,7 +164,7 @@ qib_user_sdma_rb_insert(struct rb_root *root, struct qib_user_sdma_rb_node *new)
 	struct qib_user_sdma_rb_node *got;
 
 	while (*node) {
-		got = container_of(*node, struct qib_user_sdma_rb_node, node);
+		got = rb_entry(*node, struct qib_user_sdma_rb_node, node);
 		parent = *node;
 		if (new->pid < got->pid)
 			node = &((*node)->rb_left);
-- 
2.9.3

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

* [PATCH] netfilter: xt_connlimit: use rb_entry()
  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-20 14:02 ` [PATCH] IB/qib: " Geliang Tang
@ 2016-12-20 14:02 ` Geliang Tang
  2017-01-05 12:26   ` Pablo Neira Ayuso
  2016-12-20 14:02 ` [PATCH] net/mlx5: " Geliang Tang
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 34+ messages in thread
From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik, David S. Miller
  Cc: Geliang Tang, netfilter-devel, coreteam, netdev, linux-kernel

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/netfilter/xt_connlimit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/xt_connlimit.c b/net/netfilter/xt_connlimit.c
index 2aff2b7..660b61d 100644
--- a/net/netfilter/xt_connlimit.c
+++ b/net/netfilter/xt_connlimit.c
@@ -218,7 +218,7 @@ count_tree(struct net *net, struct rb_root *root,
 		int diff;
 		bool addit;
 
-		rbconn = container_of(*rbnode, struct xt_connlimit_rb, node);
+		rbconn = rb_entry(*rbnode, struct xt_connlimit_rb, node);
 
 		parent = *rbnode;
 		diff = same_source_net(addr, mask, &rbconn->addr, family);
@@ -398,7 +398,7 @@ static void destroy_tree(struct rb_root *r)
 	struct rb_node *node;
 
 	while ((node = rb_first(r)) != NULL) {
-		rbconn = container_of(node, struct xt_connlimit_rb, node);
+		rbconn = rb_entry(node, struct xt_connlimit_rb, node);
 
 		rb_erase(node, r);
 
-- 
2.9.3

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

* [PATCH] net/mlx5: use rb_entry()
  2016-12-20 14:02 [PATCH] dm bufio: use rb_entry() Geliang Tang
                   ` (2 preceding siblings ...)
  2016-12-20 14:02 ` [PATCH] netfilter: xt_connlimit: " Geliang Tang
@ 2016-12-20 14:02 ` Geliang Tang
  2016-12-20 14:19   ` Leon Romanovsky
  2016-12-20 19:23   ` David Miller
  2016-12-20 14:02 ` [PATCH] net_sched: sch_fq: " Geliang Tang
                   ` (5 subsequent siblings)
  9 siblings, 2 replies; 34+ messages in thread
From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw)
  To: Saeed Mahameed, Matan Barak, Leon Romanovsky
  Cc: Geliang Tang, netdev, linux-rdma, linux-kernel

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

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
index 3b026c1..7431f63 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
@@ -75,7 +75,7 @@ static void mlx5_fc_stats_insert(struct rb_root *root, struct mlx5_fc *counter)
 	struct rb_node *parent = NULL;
 
 	while (*new) {
-		struct mlx5_fc *this = container_of(*new, struct mlx5_fc, node);
+		struct mlx5_fc *this = rb_entry(*new, struct mlx5_fc, node);
 		int result = counter->id - this->id;
 
 		parent = *new;
-- 
2.9.3

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

* [PATCH] net_sched: sch_fq: use rb_entry()
  2016-12-20 14:02 [PATCH] dm bufio: use rb_entry() Geliang Tang
                   ` (3 preceding siblings ...)
  2016-12-20 14:02 ` [PATCH] net/mlx5: " Geliang Tang
@ 2016-12-20 14:02 ` Geliang Tang
  2016-12-20 16:38   ` Eric Dumazet
  2016-12-20 19:23   ` David Miller
  2016-12-20 14:02 ` [PATCH] net_sched: sch_netem: " Geliang Tang
                   ` (4 subsequent siblings)
  9 siblings, 2 replies; 34+ messages in thread
From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw)
  To: Jamal Hadi Salim, David S. Miller; +Cc: Geliang Tang, netdev, linux-kernel

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

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

* [PATCH] net_sched: sch_netem: use rb_entry()
  2016-12-20 14:02 [PATCH] dm bufio: use rb_entry() Geliang Tang
                   ` (4 preceding siblings ...)
  2016-12-20 14:02 ` [PATCH] net_sched: sch_fq: " Geliang Tang
@ 2016-12-20 14:02 ` Geliang Tang
  2016-12-20 19:23   ` David Miller
  2016-12-20 14:02 ` [PATCH] powerpc/perf/24x7: use rb_entry Geliang Tang
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 34+ messages in thread
From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw)
  To: Stephen Hemminger, Jamal Hadi Salim, David S. Miller
  Cc: Geliang Tang, netem, netdev, linux-kernel

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_netem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 9f7b380..b7e4097 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -152,7 +152,7 @@ struct netem_skb_cb {
 
 static struct sk_buff *netem_rb_to_skb(struct rb_node *rb)
 {
-	return container_of(rb, struct sk_buff, rbnode);
+	return rb_entry(rb, struct sk_buff, rbnode);
 }
 
 static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb)
-- 
2.9.3

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

* [PATCH] powerpc/perf/24x7: use rb_entry
  2016-12-20 14:02 [PATCH] dm bufio: use rb_entry() Geliang Tang
                   ` (5 preceding siblings ...)
  2016-12-20 14:02 ` [PATCH] net_sched: sch_netem: " Geliang Tang
@ 2016-12-20 14:02 ` Geliang Tang
  2019-07-08  1:19   ` Michael Ellerman
  2016-12-20 14:02 ` [PATCH] RDS: use rb_entry() Geliang Tang
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 34+ messages in thread
From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Sukadev Bhattiprolu, Alexey Kardashevskiy, David Gibson
  Cc: Geliang Tang, linuxppc-dev, linux-kernel

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

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 arch/powerpc/perf/hv-24x7.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 7b2ca16..51bd3b4 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -547,7 +547,7 @@ static int event_uniq_add(struct rb_root *root, const char *name, int nl,
 		struct event_uniq *it;
 		int result;
 
-		it = container_of(*new, struct event_uniq, node);
+		it = rb_entry(*new, struct event_uniq, node);
 		result = ev_uniq_ord(name, nl, domain, it->name, it->nl,
 					it->domain);
 
-- 
2.9.3

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

* [PATCH] RDS: use rb_entry()
  2016-12-20 14:02 [PATCH] dm bufio: use rb_entry() Geliang Tang
                   ` (6 preceding siblings ...)
  2016-12-20 14:02 ` [PATCH] powerpc/perf/24x7: use rb_entry Geliang Tang
@ 2016-12-20 14:02 ` Geliang Tang
  2016-12-20 14:20   ` Leon Romanovsky
                     ` (3 more replies)
  2016-12-20 14:02 ` [PATCH] xen/blkback: " Geliang Tang
  2016-12-20 14:02 ` [PATCH] xen/evtchn: " Geliang Tang
  9 siblings, 4 replies; 34+ messages in thread
From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw)
  To: Santosh Shilimkar, David S. Miller
  Cc: Geliang Tang, netdev, linux-rdma, rds-devel, linux-kernel

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/rds/rdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 4c93bad..ea96114 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -135,7 +135,7 @@ void rds_rdma_drop_keys(struct rds_sock *rs)
 	/* Release any MRs associated with this socket */
 	spin_lock_irqsave(&rs->rs_rdma_lock, flags);
 	while ((node = rb_first(&rs->rs_rdma_keys))) {
-		mr = container_of(node, struct rds_mr, r_rb_node);
+		mr = rb_entry(node, struct rds_mr, r_rb_node);
 		if (mr->r_trans == rs->rs_transport)
 			mr->r_invalidate = 0;
 		rb_erase(&mr->r_rb_node, &rs->rs_rdma_keys);
-- 
2.9.3

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

* [PATCH] xen/blkback: use rb_entry()
  2016-12-20 14:02 [PATCH] dm bufio: use rb_entry() Geliang Tang
                   ` (7 preceding siblings ...)
  2016-12-20 14:02 ` [PATCH] RDS: use rb_entry() Geliang Tang
@ 2016-12-20 14:02 ` Geliang Tang
  2016-12-20 16:47   ` Konrad Rzeszutek Wilk
  2016-12-20 14:02 ` [PATCH] xen/evtchn: " Geliang Tang
  9 siblings, 1 reply; 34+ messages in thread
From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Roger Pau Monné
  Cc: Geliang Tang, xen-devel, linux-kernel

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

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/block/xen-blkback/blkback.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 726c32e..7e59fae 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -191,10 +191,10 @@ static void make_response(struct xen_blkif_ring *ring, u64 id,
 			  unsigned short op, int st);
 
 #define foreach_grant_safe(pos, n, rbtree, node) \
-	for ((pos) = container_of(rb_first((rbtree)), typeof(*(pos)), node), \
+	for ((pos) = rb_entry(rb_first((rbtree)), typeof(*(pos)), node), \
 	     (n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL; \
 	     &(pos)->node != NULL; \
-	     (pos) = container_of(n, typeof(*(pos)), node), \
+	     (pos) = rb_entry(n, typeof(*(pos)), node), \
 	     (n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL)
 
 
@@ -223,7 +223,7 @@ static int add_persistent_gnt(struct xen_blkif_ring *ring,
 	/* Figure out where to put new node */
 	new = &ring->persistent_gnts.rb_node;
 	while (*new) {
-		this = container_of(*new, struct persistent_gnt, node);
+		this = rb_entry(*new, struct persistent_gnt, node);
 
 		parent = *new;
 		if (persistent_gnt->gnt < this->gnt)
@@ -254,7 +254,7 @@ static struct persistent_gnt *get_persistent_gnt(struct xen_blkif_ring *ring,
 
 	node = ring->persistent_gnts.rb_node;
 	while (node) {
-		data = container_of(node, struct persistent_gnt, node);
+		data = rb_entry(node, struct persistent_gnt, node);
 
 		if (gref < data->gnt)
 			node = node->rb_left;
-- 
2.9.3

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

* [PATCH] xen/evtchn: use rb_entry()
  2016-12-20 14:02 [PATCH] dm bufio: use rb_entry() Geliang Tang
                   ` (8 preceding siblings ...)
  2016-12-20 14:02 ` [PATCH] xen/blkback: " Geliang Tang
@ 2016-12-20 14:02 ` Geliang Tang
  2016-12-20 16:20   ` Juergen Gross
  2016-12-22  9:07   ` Juergen Gross
  9 siblings, 2 replies; 34+ messages in thread
From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw)
  To: Boris Ostrovsky, Juergen Gross; +Cc: Geliang Tang, xen-devel, linux-kernel

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

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/xen/evtchn.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
index e8c7f09..6890897 100644
--- a/drivers/xen/evtchn.c
+++ b/drivers/xen/evtchn.c
@@ -125,7 +125,7 @@ static int add_evtchn(struct per_user_data *u, struct user_evtchn *evtchn)
 	while (*new) {
 		struct user_evtchn *this;
 
-		this = container_of(*new, struct user_evtchn, node);
+		this = rb_entry(*new, struct user_evtchn, node);
 
 		parent = *new;
 		if (this->port < evtchn->port)
@@ -157,7 +157,7 @@ static struct user_evtchn *find_evtchn(struct per_user_data *u, unsigned port)
 	while (node) {
 		struct user_evtchn *evtchn;
 
-		evtchn = container_of(node, struct user_evtchn, node);
+		evtchn = rb_entry(node, struct user_evtchn, node);
 
 		if (evtchn->port < port)
 			node = node->rb_left;
-- 
2.9.3

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

* Re: [PATCH] net/mlx5: use rb_entry()
  2016-12-20 14:02 ` [PATCH] net/mlx5: " Geliang Tang
@ 2016-12-20 14:19   ` Leon Romanovsky
  2016-12-20 19:23   ` David Miller
  1 sibling, 0 replies; 34+ messages in thread
From: Leon Romanovsky @ 2016-12-20 14:19 UTC (permalink / raw)
  To: Geliang Tang
  Cc: Saeed Mahameed, Matan Barak, netdev, linux-rdma, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1041 bytes --]

On Tue, Dec 20, 2016 at 10:02:14PM +0800, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks,
Acked-by: Leon Romanovsky <leonro@mellanox.com>

>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
> index 3b026c1..7431f63 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
> @@ -75,7 +75,7 @@ static void mlx5_fc_stats_insert(struct rb_root *root, struct mlx5_fc *counter)
>  	struct rb_node *parent = NULL;
>
>  	while (*new) {
> -		struct mlx5_fc *this = container_of(*new, struct mlx5_fc, node);
> +		struct mlx5_fc *this = rb_entry(*new, struct mlx5_fc, node);
>  		int result = counter->id - this->id;
>
>  		parent = *new;
> --
> 2.9.3
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] RDS: use rb_entry()
  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
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 34+ messages in thread
From: Leon Romanovsky @ 2016-12-20 14:20 UTC (permalink / raw)
  To: Geliang Tang
  Cc: Santosh Shilimkar, David S. Miller, netdev, linux-rdma,
	rds-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 942 bytes --]

On Tue, Dec 20, 2016 at 10:02:18PM +0800, Geliang Tang wrote:
> 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/rds/rdma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

>
> diff --git a/net/rds/rdma.c b/net/rds/rdma.c
> index 4c93bad..ea96114 100644
> --- a/net/rds/rdma.c
> +++ b/net/rds/rdma.c
> @@ -135,7 +135,7 @@ void rds_rdma_drop_keys(struct rds_sock *rs)
>  	/* Release any MRs associated with this socket */
>  	spin_lock_irqsave(&rs->rs_rdma_lock, flags);
>  	while ((node = rb_first(&rs->rs_rdma_keys))) {
> -		mr = container_of(node, struct rds_mr, r_rb_node);
> +		mr = rb_entry(node, struct rds_mr, r_rb_node);
>  		if (mr->r_trans == rs->rs_transport)
>  			mr->r_invalidate = 0;
>  		rb_erase(&mr->r_rb_node, &rs->rs_rdma_keys);
> --
> 2.9.3
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] IB/qib: use rb_entry()
  2016-12-20 14:02 ` [PATCH] IB/qib: " Geliang Tang
@ 2016-12-20 14:21   ` Leon Romanovsky
  2016-12-20 15:01   ` Dennis Dalessandro
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 34+ messages in thread
From: Leon Romanovsky @ 2016-12-20 14:21 UTC (permalink / raw)
  To: Geliang Tang
  Cc: Mike Marciniszyn, Doug Ledford, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1418 bytes --]

On Tue, Dec 20, 2016 at 10:02:12PM +0800, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
>  drivers/infiniband/hw/qib/qib_user_sdma.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

> diff --git a/drivers/infiniband/hw/qib/qib_user_sdma.c b/drivers/infiniband/hw/qib/qib_user_sdma.c
> index 3e0677c..926f3c8 100644
> --- a/drivers/infiniband/hw/qib/qib_user_sdma.c
> +++ b/drivers/infiniband/hw/qib/qib_user_sdma.c
> @@ -144,8 +144,8 @@ qib_user_sdma_rb_search(struct rb_root *root, pid_t pid)
>  	struct rb_node *node = root->rb_node;
>
>  	while (node) {
> -		sdma_rb_node = container_of(node,
> -			struct qib_user_sdma_rb_node, node);
> +		sdma_rb_node = rb_entry(node, struct qib_user_sdma_rb_node,
> +					node);
>  		if (pid < sdma_rb_node->pid)
>  			node = node->rb_left;
>  		else if (pid > sdma_rb_node->pid)
> @@ -164,7 +164,7 @@ qib_user_sdma_rb_insert(struct rb_root *root, struct qib_user_sdma_rb_node *new)
>  	struct qib_user_sdma_rb_node *got;
>
>  	while (*node) {
> -		got = container_of(*node, struct qib_user_sdma_rb_node, node);
> +		got = rb_entry(*node, struct qib_user_sdma_rb_node, node);
>  		parent = *node;
>  		if (new->pid < got->pid)
>  			node = &((*node)->rb_left);
> --
> 2.9.3
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] IB/qib: use rb_entry()
  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
  3 siblings, 0 replies; 34+ messages in thread
From: Dennis Dalessandro @ 2016-12-20 15:01 UTC (permalink / raw)
  To: Geliang Tang, Mike Marciniszyn, Doug Ledford, Sean Hefty, Hal Rosenstock
  Cc: linux-rdma, linux-kernel

On 12/20/2016 09:02 AM, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>

Thanks

-Denny

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

* Re: [PATCH] xen/evtchn: use rb_entry()
  2016-12-20 14:02 ` [PATCH] xen/evtchn: " Geliang Tang
@ 2016-12-20 16:20   ` Juergen Gross
  2016-12-22  9:07   ` Juergen Gross
  1 sibling, 0 replies; 34+ messages in thread
From: Juergen Gross @ 2016-12-20 16:20 UTC (permalink / raw)
  To: Geliang Tang, Boris Ostrovsky; +Cc: xen-devel, linux-kernel

On 20/12/16 15:02, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Reviewed-by: Juergen Gross <jgross@suse.com>

> ---
>  drivers/xen/evtchn.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
> index e8c7f09..6890897 100644
> --- a/drivers/xen/evtchn.c
> +++ b/drivers/xen/evtchn.c
> @@ -125,7 +125,7 @@ static int add_evtchn(struct per_user_data *u, struct user_evtchn *evtchn)
>  	while (*new) {
>  		struct user_evtchn *this;
>  
> -		this = container_of(*new, struct user_evtchn, node);
> +		this = rb_entry(*new, struct user_evtchn, node);
>  
>  		parent = *new;
>  		if (this->port < evtchn->port)
> @@ -157,7 +157,7 @@ static struct user_evtchn *find_evtchn(struct per_user_data *u, unsigned port)
>  	while (node) {
>  		struct user_evtchn *evtchn;
>  
> -		evtchn = container_of(node, struct user_evtchn, node);
> +		evtchn = rb_entry(node, struct user_evtchn, node);
>  
>  		if (evtchn->port < port)
>  			node = node->rb_left;
> 

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

* Re: [PATCH] RDS: use rb_entry()
  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
  3 siblings, 0 replies; 34+ messages in thread
From: Santosh Shilimkar @ 2016-12-20 16:34 UTC (permalink / raw)
  To: Geliang Tang, David S. Miller; +Cc: netdev, linux-rdma, rds-devel, linux-kernel

On 12/20/2016 6:02 AM, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
Looks fine.
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>

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

* Re: [PATCH] net_sched: sch_fq: use rb_entry()
  2016-12-20 14:02 ` [PATCH] net_sched: sch_fq: " Geliang Tang
@ 2016-12-20 16:38   ` Eric Dumazet
  2016-12-20 19:23   ` David Miller
  1 sibling, 0 replies; 34+ messages in thread
From: Eric Dumazet @ 2016-12-20 16:38 UTC (permalink / raw)
  To: Geliang Tang; +Cc: Jamal Hadi Salim, David S. Miller, netdev, linux-kernel

On Tue, 2016-12-20 at 22:02 +0800, Geliang Tang wrote:
> 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(-)

Acked-by: Eric Dumazet <edumazet@google.com>

Thanks.

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

* Re: [PATCH] xen/blkback: use rb_entry()
  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é
  0 siblings, 1 reply; 34+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-12-20 16:47 UTC (permalink / raw)
  To: Geliang Tang, roger.pau; +Cc: Roger Pau Monné, xen-devel, linux-kernel

On Tue, Dec 20, 2016 at 10:02:19PM +0800, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.

That is OK but I think 'container_of' is more clear.

Roger, thoughts?

> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
>  drivers/block/xen-blkback/blkback.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
> index 726c32e..7e59fae 100644
> --- a/drivers/block/xen-blkback/blkback.c
> +++ b/drivers/block/xen-blkback/blkback.c
> @@ -191,10 +191,10 @@ static void make_response(struct xen_blkif_ring *ring, u64 id,
>  			  unsigned short op, int st);
>  
>  #define foreach_grant_safe(pos, n, rbtree, node) \
> -	for ((pos) = container_of(rb_first((rbtree)), typeof(*(pos)), node), \
> +	for ((pos) = rb_entry(rb_first((rbtree)), typeof(*(pos)), node), \
>  	     (n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL; \
>  	     &(pos)->node != NULL; \
> -	     (pos) = container_of(n, typeof(*(pos)), node), \
> +	     (pos) = rb_entry(n, typeof(*(pos)), node), \
>  	     (n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL)
>  
>  
> @@ -223,7 +223,7 @@ static int add_persistent_gnt(struct xen_blkif_ring *ring,
>  	/* Figure out where to put new node */
>  	new = &ring->persistent_gnts.rb_node;
>  	while (*new) {
> -		this = container_of(*new, struct persistent_gnt, node);
> +		this = rb_entry(*new, struct persistent_gnt, node);
>  
>  		parent = *new;
>  		if (persistent_gnt->gnt < this->gnt)
> @@ -254,7 +254,7 @@ static struct persistent_gnt *get_persistent_gnt(struct xen_blkif_ring *ring,
>  
>  	node = ring->persistent_gnts.rb_node;
>  	while (node) {
> -		data = container_of(node, struct persistent_gnt, node);
> +		data = rb_entry(node, struct persistent_gnt, node);
>  
>  		if (gref < data->gnt)
>  			node = node->rb_left;
> -- 
> 2.9.3
> 

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

* Re: [PATCH] xen/blkback: use rb_entry()
  2016-12-20 16:47   ` Konrad Rzeszutek Wilk
@ 2016-12-20 17:44     ` Roger Pau Monné
  2016-12-20 17:51       ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 34+ messages in thread
From: Roger Pau Monné @ 2016-12-20 17:44 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk; +Cc: Geliang Tang, xen-devel, linux-kernel

On Tue, Dec 20, 2016 at 11:47:03AM -0500, Konrad Rzeszutek Wilk wrote:
> On Tue, Dec 20, 2016 at 10:02:19PM +0800, Geliang Tang wrote:
> > To make the code clearer, use rb_entry() instead of container_of() to
> > deal with rbtree.
> 
> That is OK but I think 'container_of' is more clear.
> 
> Roger, thoughts?

I think so, container_of is a global macro that's widely used and everyone
knows, rb_entry OTOH it's not and it's use doesn't really simply the code at
all. I'm not really opposed, but it seems kind of a pointless change (not that
it's wrong).

Roger.

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

* Re: [PATCH] xen/blkback: use rb_entry()
  2016-12-20 17:44     ` Roger Pau Monné
@ 2016-12-20 17:51       ` Konrad Rzeszutek Wilk
  2016-12-20 21:53         ` Eric Dumazet
  0 siblings, 1 reply; 34+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-12-20 17:51 UTC (permalink / raw)
  To: Roger Pau Monné; +Cc: Geliang Tang, xen-devel, linux-kernel

On Tue, Dec 20, 2016 at 05:44:06PM +0000, Roger Pau Monné wrote:
> On Tue, Dec 20, 2016 at 11:47:03AM -0500, Konrad Rzeszutek Wilk wrote:
> > On Tue, Dec 20, 2016 at 10:02:19PM +0800, Geliang Tang wrote:
> > > To make the code clearer, use rb_entry() instead of container_of() to
> > > deal with rbtree.
> > 
> > That is OK but I think 'container_of' is more clear.
> > 
> > Roger, thoughts?
> 
> I think so, container_of is a global macro that's widely used and everyone
> knows, rb_entry OTOH it's not and it's use doesn't really simply the code at
> all. I'm not really opposed, but it seems kind of a pointless change (not that
> it's wrong).

<nods> I concur.

Geliang Tang,

Thank you for the patch but there is no need for it.

Thanks again!
> 
> Roger.

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

* Re: [PATCH] net_sched: sch_fq: use rb_entry()
  2016-12-20 14:02 ` [PATCH] net_sched: sch_fq: " Geliang Tang
  2016-12-20 16:38   ` Eric Dumazet
@ 2016-12-20 19:23   ` David Miller
  1 sibling, 0 replies; 34+ messages in thread
From: David Miller @ 2016-12-20 19:23 UTC (permalink / raw)
  To: geliangtang; +Cc: jhs, netdev, linux-kernel

From: Geliang Tang <geliangtang@gmail.com>
Date: Tue, 20 Dec 2016 22:02:15 +0800

> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Applied.

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

* Re: [PATCH] net_sched: sch_netem: use rb_entry()
  2016-12-20 14:02 ` [PATCH] net_sched: sch_netem: " Geliang Tang
@ 2016-12-20 19:23   ` David Miller
  0 siblings, 0 replies; 34+ messages in thread
From: David Miller @ 2016-12-20 19:23 UTC (permalink / raw)
  To: geliangtang; +Cc: stephen, jhs, netem, netdev, linux-kernel

From: Geliang Tang <geliangtang@gmail.com>
Date: Tue, 20 Dec 2016 22:02:16 +0800

> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Applied.

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

* Re: [PATCH] RDS: use rb_entry()
  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
  3 siblings, 0 replies; 34+ messages in thread
From: David Miller @ 2016-12-20 19:23 UTC (permalink / raw)
  To: geliangtang
  Cc: santosh.shilimkar, netdev, linux-rdma, rds-devel, linux-kernel

From: Geliang Tang <geliangtang@gmail.com>
Date: Tue, 20 Dec 2016 22:02:18 +0800

> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Applied.

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

* Re: [PATCH] net/mlx5: use rb_entry()
  2016-12-20 14:02 ` [PATCH] net/mlx5: " Geliang Tang
  2016-12-20 14:19   ` Leon Romanovsky
@ 2016-12-20 19:23   ` David Miller
  1 sibling, 0 replies; 34+ messages in thread
From: David Miller @ 2016-12-20 19:23 UTC (permalink / raw)
  To: geliangtang; +Cc: saeedm, matanb, leonro, netdev, linux-rdma, linux-kernel

From: Geliang Tang <geliangtang@gmail.com>
Date: Tue, 20 Dec 2016 22:02:14 +0800

> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Applied.

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

* RE: [PATCH] IB/qib: use rb_entry()
  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
  3 siblings, 0 replies; 34+ messages in thread
From: Marciniszyn, Mike @ 2016-12-20 19:34 UTC (permalink / raw)
  To: Geliang Tang
  Cc: linux-rdma, linux-kernel, Doug Ledford, Hefty, Sean, Hal Rosenstock

> Subject: [PATCH] IB/qib: use rb_entry()
> 
> To make the code clearer, use rb_entry() instead of container_of() to deal
> with rbtree.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Thanks for the patch!

Mike

Acked-by: Mike Marciniszyn <mike.marciniszyn@intel.com>

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

* Re: [PATCH] xen/blkback: use rb_entry()
  2016-12-20 17:51       ` Konrad Rzeszutek Wilk
@ 2016-12-20 21:53         ` Eric Dumazet
  2016-12-20 22:07           ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 34+ messages in thread
From: Eric Dumazet @ 2016-12-20 21:53 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Roger Pau Monné, Geliang Tang, xen-devel, linux-kernel

On Tue, 2016-12-20 at 12:51 -0500, Konrad Rzeszutek Wilk wrote:
> On Tue, Dec 20, 2016 at 05:44:06PM +0000, Roger Pau Monné wrote:
> > On Tue, Dec 20, 2016 at 11:47:03AM -0500, Konrad Rzeszutek Wilk wrote:
> > > On Tue, Dec 20, 2016 at 10:02:19PM +0800, Geliang Tang wrote:
> > > > To make the code clearer, use rb_entry() instead of container_of() to
> > > > deal with rbtree.
> > > 
> > > That is OK but I think 'container_of' is more clear.
> > > 
> > > Roger, thoughts?
> > 
> > I think so, container_of is a global macro that's widely used and everyone
> > knows, rb_entry OTOH it's not and it's use doesn't really simply the code at
> > all. I'm not really opposed, but it seems kind of a pointless change (not that
> > it's wrong).
> 
> <nods> I concur.
> 
> Geliang Tang,
> 
> Thank you for the patch but there is no need for it.

The same could be said of list_entry()

#define hlist_entry(ptr, type, member) container_of(ptr,type,member)

#define list_entry(ptr, type, member) container_of(ptr, type, member)

# git grep -n list_entry | wc -l
3636

rb_entry() will probably make its way everywhere.

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

* Re: [PATCH] xen/blkback: use rb_entry()
  2016-12-20 21:53         ` Eric Dumazet
@ 2016-12-20 22:07           ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 34+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-12-20 22:07 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Roger Pau Monné, Geliang Tang, xen-devel, linux-kernel

On Tue, Dec 20, 2016 at 01:53:21PM -0800, Eric Dumazet wrote:
> On Tue, 2016-12-20 at 12:51 -0500, Konrad Rzeszutek Wilk wrote:
> > On Tue, Dec 20, 2016 at 05:44:06PM +0000, Roger Pau Monné wrote:
> > > On Tue, Dec 20, 2016 at 11:47:03AM -0500, Konrad Rzeszutek Wilk wrote:
> > > > On Tue, Dec 20, 2016 at 10:02:19PM +0800, Geliang Tang wrote:
> > > > > To make the code clearer, use rb_entry() instead of container_of() to
> > > > > deal with rbtree.
> > > > 
> > > > That is OK but I think 'container_of' is more clear.
> > > > 
> > > > Roger, thoughts?
> > > 
> > > I think so, container_of is a global macro that's widely used and everyone
> > > knows, rb_entry OTOH it's not and it's use doesn't really simply the code at
> > > all. I'm not really opposed, but it seems kind of a pointless change (not that
> > > it's wrong).
> > 
> > <nods> I concur.
> > 
> > Geliang Tang,
> > 
> > Thank you for the patch but there is no need for it.
> 
> The same could be said of list_entry()
> 

Sure. And I am used to that as well :-)

> #define hlist_entry(ptr, type, member) container_of(ptr,type,member)
> 
> #define list_entry(ptr, type, member) container_of(ptr, type, member)
> 
> # git grep -n list_entry | wc -l
> 3636
> 
> rb_entry() will probably make its way everywhere.

That is good to know.

But for right now this patch is not necessary. Thank you!

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

* Re: [Nouveau] [PATCH] drm/nouveau/dma: use rb_entry()
  2016-12-20 14:02 ` [PATCH] drm/nouveau/dma: " Geliang Tang
@ 2016-12-21 23:22   ` Ben Skeggs
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Skeggs @ 2016-12-21 23:22 UTC (permalink / raw)
  To: Geliang Tang, Ben Skeggs, David Airlie; +Cc: linux-kernel, dri-devel, nouveau


[-- Attachment #1.1: Type: text/plain, Size: 1361 bytes --]

On 12/21/2016 12:02 AM, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
Thanks, I've grabbed the patch.

Ben.

> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
>  drivers/gpu/drm/nouveau/nvkm/engine/dma/base.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/base.c
> index f11ebdd..4655d17 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/base.c
> @@ -34,7 +34,7 @@ nvkm_dma_search(struct nvkm_dma *dma, struct nvkm_client *client, u64 object)
>  	struct rb_node *node = client->dmaroot.rb_node;
>  	while (node) {
>  		struct nvkm_dmaobj *dmaobj =
> -			container_of(node, typeof(*dmaobj), rb);
> +			rb_entry(node, typeof(*dmaobj), rb);
>  		if (object < dmaobj->handle)
>  			node = node->rb_left;
>  		else
> @@ -67,7 +67,7 @@ nvkm_dma_oclass_new(struct nvkm_device *device,
>  	dmaobj->handle = oclass->object;
>  
>  	while (*ptr) {
> -		struct nvkm_dmaobj *obj = container_of(*ptr, typeof(*obj), rb);
> +		struct nvkm_dmaobj *obj = rb_entry(*ptr, typeof(*obj), rb);
>  		parent = *ptr;
>  		if (dmaobj->handle < obj->handle)
>  			ptr = &parent->rb_left;
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] RDS: use rb_entry()
  2016-12-20 14:02 ` [PATCH] RDS: use rb_entry() Geliang Tang
                     ` (2 preceding siblings ...)
  2016-12-20 19:23   ` David Miller
@ 2016-12-22  3:33   ` Doug Ledford
  3 siblings, 0 replies; 34+ messages in thread
From: Doug Ledford @ 2016-12-22  3:33 UTC (permalink / raw)
  To: Geliang Tang, Santosh Shilimkar, David S. Miller
  Cc: netdev, linux-rdma, rds-devel, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 2083 bytes --]

On 12/20/2016 9:02 AM, Geliang Tang wrote:
> 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/rds/rdma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/rds/rdma.c b/net/rds/rdma.c
> index 4c93bad..ea96114 100644
> --- a/net/rds/rdma.c
> +++ b/net/rds/rdma.c
> @@ -135,7 +135,7 @@ void rds_rdma_drop_keys(struct rds_sock *rs)
>  	/* Release any MRs associated with this socket */
>  	spin_lock_irqsave(&rs->rs_rdma_lock, flags);
>  	while ((node = rb_first(&rs->rs_rdma_keys))) {
> -		mr = container_of(node, struct rds_mr, r_rb_node);
> +		mr = rb_entry(node, struct rds_mr, r_rb_node);
>  		if (mr->r_trans == rs->rs_transport)
>  			mr->r_invalidate = 0;
>  		rb_erase(&mr->r_rb_node, &rs->rs_rdma_keys);
> 

Dave, I know you already took this, but am I the only one that thinks
these patches are a step backwards?  They claim to promote readability,
but I disagree that they actually do so.  The original code used the
container_of() API with three specific arguments that made sense in the
context of a function named container_of().  The new API uses the exact
same three arguments, but they no longer make the same sense just
comparing the arguments to the function name.  The relationship has been
lost.  And on top of that, if you do this for all of the standard things
in the kernel (rb_entry, list_item, etc.), then you've created a myriad
of APIs that all duplicate one functional API that made sense.  Is it
really an improvement to go from one generic function that makes sense
and works everywhere to multiple implementations of basically just name
wrappers that mean you now need to know many aliases for the same
function?  How do we justify API bloat like this as better or easier to
read when it requires useless API memorization?

-- 
Doug Ledford <dledford@redhat.com>
    GPG Key ID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

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

* Re: [PATCH] xen/evtchn: use rb_entry()
  2016-12-20 14:02 ` [PATCH] xen/evtchn: " Geliang Tang
  2016-12-20 16:20   ` Juergen Gross
@ 2016-12-22  9:07   ` Juergen Gross
  1 sibling, 0 replies; 34+ messages in thread
From: Juergen Gross @ 2016-12-22  9:07 UTC (permalink / raw)
  To: Geliang Tang, Boris Ostrovsky; +Cc: xen-devel, linux-kernel

On 20/12/16 15:02, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Committed to xen/tip.git for-linus-4.10


Juergen

> ---
>  drivers/xen/evtchn.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
> index e8c7f09..6890897 100644
> --- a/drivers/xen/evtchn.c
> +++ b/drivers/xen/evtchn.c
> @@ -125,7 +125,7 @@ static int add_evtchn(struct per_user_data *u, struct user_evtchn *evtchn)
>  	while (*new) {
>  		struct user_evtchn *this;
>  
> -		this = container_of(*new, struct user_evtchn, node);
> +		this = rb_entry(*new, struct user_evtchn, node);
>  
>  		parent = *new;
>  		if (this->port < evtchn->port)
> @@ -157,7 +157,7 @@ static struct user_evtchn *find_evtchn(struct per_user_data *u, unsigned port)
>  	while (node) {
>  		struct user_evtchn *evtchn;
>  
> -		evtchn = container_of(node, struct user_evtchn, node);
> +		evtchn = rb_entry(node, struct user_evtchn, node);
>  
>  		if (evtchn->port < port)
>  			node = node->rb_left;
> 

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

* Re: [PATCH] netfilter: xt_connlimit: use rb_entry()
  2016-12-20 14:02 ` [PATCH] netfilter: xt_connlimit: " Geliang Tang
@ 2017-01-05 12:26   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 34+ messages in thread
From: Pablo Neira Ayuso @ 2017-01-05 12:26 UTC (permalink / raw)
  To: Geliang Tang
  Cc: Patrick McHardy, Jozsef Kadlecsik, David S. Miller,
	netfilter-devel, coreteam, netdev, linux-kernel

On Tue, Dec 20, 2016 at 10:02:13PM +0800, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.

Applied this one to nf-next, thanks.

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

* Re: [PATCH] IB/qib: use rb_entry()
  2016-12-20 14:02 ` [PATCH] IB/qib: " Geliang Tang
                     ` (2 preceding siblings ...)
  2016-12-20 19:34   ` Marciniszyn, Mike
@ 2017-01-12 17:09   ` Doug Ledford
  3 siblings, 0 replies; 34+ messages in thread
From: Doug Ledford @ 2017-01-12 17:09 UTC (permalink / raw)
  To: Geliang Tang, Mike Marciniszyn, Sean Hefty, Hal Rosenstock
  Cc: linux-rdma, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 547 bytes --]

On Tue, 2016-12-20 at 22:02 +0800, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

In spite of the fact that I don't really like this patch, and don't
think it's an improvement, because other people have taken the same
basic patches, I'll not reject this one.

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH] powerpc/perf/24x7: use rb_entry
  2016-12-20 14:02 ` [PATCH] powerpc/perf/24x7: use rb_entry Geliang Tang
@ 2019-07-08  1:19   ` Michael Ellerman
  0 siblings, 0 replies; 34+ messages in thread
From: Michael Ellerman @ 2019-07-08  1:19 UTC (permalink / raw)
  To: Geliang Tang, Benjamin Herrenschmidt, Paul Mackerras,
	Sukadev Bhattiprolu, Alexey Kardashevskiy, David Gibson
  Cc: Geliang Tang, linuxppc-dev, linux-kernel

On Tue, 2016-12-20 at 14:02:17 UTC, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/c197922f0a8072d286dff8001f8ad0d4b95ec1dd

cheers

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

end of thread, other threads:[~2019-07-08  1:19 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH] net_sched: sch_fq: " Geliang Tang
2016-12-20 16:38   ` 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

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).