Re: [PATCH] writeback: use rb_entry()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jan 15, 2017 at 06:54:31PM -0500, Tejun Heo wrote:
> On Fri, Jan 13, 2017 at 11:17: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@xxxxxxxxx>
> > ---
> >  mm/backing-dev.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/mm/backing-dev.c b/mm/backing-dev.c
> > index 3bfed5ab..ffb77a1 100644
> > --- a/mm/backing-dev.c
> > +++ b/mm/backing-dev.c
> > @@ -410,8 +410,8 @@ wb_congested_get_create(struct backing_dev_info *bdi, int blkcg_id, gfp_t gfp)
> >  
> >  	while (*node != NULL) {
> >  		parent = *node;
> > -		congested = container_of(parent, struct bdi_writeback_congested,
> > -					 rb_node);
> > +		congested = rb_entry(parent, struct bdi_writeback_congested,
> > +				     rb_node);
> 
> I don't get the rb_entry() macro.  It's just another name for
> container_of().  I have no objection to the patch but this macro is a
> bit silly.
> 

There are several *_entry macros which are defined in kernel data
structures, like list_entry, hlist_entry, rb_entry, etc. Each of them is
just another name for container_of. We use different *_entry so that we
could identify the specific type of data structure that we are dealing
with.

-Geliang

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]
  Powered by Linux