To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <[email protected]>
---
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
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <[email protected]>
---
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
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <[email protected]>
---
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
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <[email protected]>
---
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
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <[email protected]>
---
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
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <[email protected]>
---
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
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <[email protected]>
---
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
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <[email protected]>
---
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
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <[email protected]>
---
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
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <[email protected]>
---
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
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <[email protected]>
---
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
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 <[email protected]>
> ---
> net/rds/rdma.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks,
Reviewed-by: Leon Romanovsky <[email protected]>
>
> 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
>
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 <[email protected]>
> ---
> drivers/infiniband/hw/qib/qib_user_sdma.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Thanks,
Reviewed-by: Leon Romanovsky <[email protected]>
> 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
>
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 <[email protected]>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks,
Acked-by: Leon Romanovsky <[email protected]>
>
> 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
>
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 <[email protected]>
Reviewed-by: Dennis Dalessandro <[email protected]>
Thanks
-Denny
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 <[email protected]>
Reviewed-by: Juergen Gross <[email protected]>
> ---
> 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;
>
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 <[email protected]>
> ---
Looks fine.
Acked-by: Santosh Shilimkar <[email protected]>
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 <[email protected]>
> ---
> net/sched/sch_fq.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
Acked-by: Eric Dumazet <[email protected]>
Thanks.
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 <[email protected]>
> ---
> 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
>
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.
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.
From: Geliang Tang <[email protected]>
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 <[email protected]>
Applied.
From: Geliang Tang <[email protected]>
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 <[email protected]>
Applied.
From: Geliang Tang <[email protected]>
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 <[email protected]>
Applied.
From: Geliang Tang <[email protected]>
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 <[email protected]>
Applied.
> 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 <[email protected]>
Thanks for the patch!
Mike
Acked-by: Mike Marciniszyn <[email protected]>
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.
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!
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 <[email protected]>
> ---
> 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;
>
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 <[email protected]>
> ---
> 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 <[email protected]>
GPG Key ID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
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 <[email protected]>
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;
>
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 <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/c197922f0a8072d286dff8001f8ad0d4b95ec1dd
cheers