lkml.org 
[lkml]   [2016]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH] RDS: use rb_entry()
    From
    Date
    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

    [unhandled content-type:application/pgp-signature]
    \
     
     \ /
      Last update: 2016-12-22 04:34    [W:3.280 / U:0.144 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site