From: Geliang Tang <geliangtang@gmail.com>
To: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Michal Hocko <mhocko@suse.com>, Jens Axboe <axboe@fb.com>,
Johannes Weiner <hannes@cmpxchg.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] writeback: use rb_entry()
Date: Sun, 22 Jan 2017 22:40:17 +0800 [thread overview]
Message-ID: <20170122144017.4uqlvmzhravsrprf@ThinkPad> (raw)
In-Reply-To: <20170115235431.GF14446@mtj.duckdns.org>
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@gmail.com>
> > ---
> > 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@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2017-01-22 14:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5b23d0cb523f4719673a462ab1569ae99084337e.1483685419.git.geliangtang@gmail.com>
2017-01-13 15:17 ` [PATCH] writeback: use rb_entry() Geliang Tang
2017-01-15 23:54 ` Tejun Heo
2017-01-22 14:40 ` Geliang Tang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170122144017.4uqlvmzhravsrprf@ThinkPad \
--to=geliangtang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@fb.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).