* [PATCH] netfilter: xt_connlimit: use rb_entry()
[not found] <ddabc96c798df194791134d8e070d728e2a7b59f.1482203698.git.geliangtang@gmail.com>
@ 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
` (3 subsequent siblings)
4 siblings, 1 reply; 15+ 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] 15+ messages in thread
* Re: [PATCH] netfilter: xt_connlimit: use rb_entry()
2016-12-20 14:02 ` [PATCH] netfilter: xt_connlimit: use rb_entry() Geliang Tang
@ 2017-01-05 12:26 ` Pablo Neira Ayuso
0 siblings, 0 replies; 15+ 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] 15+ messages in thread
* [PATCH] net/mlx5: use rb_entry()
[not found] <ddabc96c798df194791134d8e070d728e2a7b59f.1482203698.git.geliangtang@gmail.com>
2016-12-20 14:02 ` [PATCH] netfilter: xt_connlimit: use rb_entry() 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
` (2 subsequent siblings)
4 siblings, 2 replies; 15+ 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] 15+ 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; 15+ 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] 15+ 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; 15+ 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] 15+ messages in thread
* [PATCH] net_sched: sch_fq: use rb_entry()
[not found] <ddabc96c798df194791134d8e070d728e2a7b59f.1482203698.git.geliangtang@gmail.com>
2016-12-20 14:02 ` [PATCH] netfilter: xt_connlimit: use rb_entry() Geliang Tang
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
2016-12-20 14:02 ` [PATCH] RDS: " Geliang Tang
4 siblings, 2 replies; 15+ 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] 15+ 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; 15+ 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] 15+ 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; 15+ 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] 15+ messages in thread
* [PATCH] net_sched: sch_netem: use rb_entry()
[not found] <ddabc96c798df194791134d8e070d728e2a7b59f.1482203698.git.geliangtang@gmail.com>
` (2 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] RDS: " Geliang Tang
4 siblings, 1 reply; 15+ 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] 15+ messages in thread
* [PATCH] RDS: use rb_entry()
[not found] <ddabc96c798df194791134d8e070d728e2a7b59f.1482203698.git.geliangtang@gmail.com>
` (3 preceding siblings ...)
2016-12-20 14:02 ` [PATCH] net_sched: sch_netem: " Geliang Tang
@ 2016-12-20 14:02 ` Geliang Tang
2016-12-20 14:20 ` Leon Romanovsky
` (3 more replies)
4 siblings, 4 replies; 15+ 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] 15+ messages in thread
* Re: [PATCH] RDS: use rb_entry()
2016-12-20 14:02 ` [PATCH] RDS: " Geliang Tang
@ 2016-12-20 14:20 ` Leon Romanovsky
[not found] ` <2cd84448fe04ffb7023be892c5ed04bbfc759c87.1482204342.git.geliangtang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (2 subsequent siblings)
3 siblings, 0 replies; 15+ 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] 15+ messages in thread
[parent not found: <2cd84448fe04ffb7023be892c5ed04bbfc759c87.1482204342.git.geliangtang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] RDS: use rb_entry()
2016-12-20 14:02 ` [PATCH] RDS: " Geliang Tang
2016-12-20 14:20 ` Leon Romanovsky
[not found] ` <2cd84448fe04ffb7023be892c5ed04bbfc759c87.1482204342.git.geliangtang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-12-20 19:23 ` David Miller
2016-12-22 3:33 ` Doug Ledford
3 siblings, 0 replies; 15+ 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] 15+ messages in thread
* Re: [PATCH] RDS: use rb_entry()
2016-12-20 14:02 ` [PATCH] RDS: " Geliang Tang
` (2 preceding siblings ...)
2016-12-20 19:23 ` David Miller
@ 2016-12-22 3:33 ` Doug Ledford
3 siblings, 0 replies; 15+ 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] 15+ messages in thread