* [PATCH] xen/blkback: use rb_entry() [not found] <ddabc96c798df194791134d8e070d728e2a7b59f.1482203698.git.geliangtang@gmail.com> @ 2016-12-20 14:02 ` Geliang Tang 2016-12-20 16:47 ` Konrad Rzeszutek Wilk [not found] ` <20161220164703.GL10069@char.us.oracle.com> 2016-12-20 14:02 ` [PATCH] xen/evtchn: " Geliang Tang [not found] ` <56f3df3380cd7214ce0b2e151f2aa757b0eaca2c.1482205472.git.geliangtang@gmail.com> 2 siblings, 2 replies; 9+ messages in thread From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw) To: Konrad Rzeszutek Wilk, Roger Pau Monné Cc: Geliang Tang, linux-kernel, xen-devel 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/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 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] xen/blkback: use rb_entry() 2016-12-20 14:02 ` [PATCH] xen/blkback: use rb_entry() Geliang Tang @ 2016-12-20 16:47 ` Konrad Rzeszutek Wilk [not found] ` <20161220164703.GL10069@char.us.oracle.com> 1 sibling, 0 replies; 9+ messages in thread From: Konrad Rzeszutek Wilk @ 2016-12-20 16:47 UTC (permalink / raw) To: Geliang Tang; +Cc: xen-devel, linux-kernel, Roger Pau Monné 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 <geliangtang@gmail.com> > --- > 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 > _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <20161220164703.GL10069@char.us.oracle.com>]
* Re: [PATCH] xen/blkback: use rb_entry() [not found] ` <20161220164703.GL10069@char.us.oracle.com> @ 2016-12-20 17:44 ` Roger Pau Monné [not found] ` <20161220174406.uewt5mhniwtznran@dhcp-3-221.uk.xensource.com> 1 sibling, 0 replies; 9+ messages in thread From: Roger Pau Monné @ 2016-12-20 17:44 UTC (permalink / raw) To: Konrad Rzeszutek Wilk; +Cc: Geliang Tang, linux-kernel, xen-devel 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. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <20161220174406.uewt5mhniwtznran@dhcp-3-221.uk.xensource.com>]
* Re: [PATCH] xen/blkback: use rb_entry() [not found] ` <20161220174406.uewt5mhniwtznran@dhcp-3-221.uk.xensource.com> @ 2016-12-20 17:51 ` Konrad Rzeszutek Wilk [not found] ` <20161220175113.GB16671@char.us.oracle.com> 1 sibling, 0 replies; 9+ messages in thread From: Konrad Rzeszutek Wilk @ 2016-12-20 17:51 UTC (permalink / raw) To: Roger Pau Monné; +Cc: Geliang Tang, linux-kernel, xen-devel 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. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <20161220175113.GB16671@char.us.oracle.com>]
* Re: [PATCH] xen/blkback: use rb_entry() [not found] ` <20161220175113.GB16671@char.us.oracle.com> @ 2016-12-20 21:53 ` Eric Dumazet [not found] ` <1482270801.1521.25.camel@edumazet-glaptop3.roam.corp.google.com> 1 sibling, 0 replies; 9+ messages in thread From: Eric Dumazet @ 2016-12-20 21:53 UTC (permalink / raw) To: Konrad Rzeszutek Wilk Cc: Geliang Tang, xen-devel, linux-kernel, Roger Pau Monné 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. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <1482270801.1521.25.camel@edumazet-glaptop3.roam.corp.google.com>]
* Re: [PATCH] xen/blkback: use rb_entry() [not found] ` <1482270801.1521.25.camel@edumazet-glaptop3.roam.corp.google.com> @ 2016-12-20 22:07 ` Konrad Rzeszutek Wilk 0 siblings, 0 replies; 9+ messages in thread From: Konrad Rzeszutek Wilk @ 2016-12-20 22:07 UTC (permalink / raw) To: Eric Dumazet; +Cc: Geliang Tang, xen-devel, linux-kernel, Roger Pau Monné 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! _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] xen/evtchn: use rb_entry() [not found] <ddabc96c798df194791134d8e070d728e2a7b59f.1482203698.git.geliangtang@gmail.com> 2016-12-20 14:02 ` [PATCH] xen/blkback: use rb_entry() Geliang Tang @ 2016-12-20 14:02 ` Geliang Tang [not found] ` <56f3df3380cd7214ce0b2e151f2aa757b0eaca2c.1482205472.git.geliangtang@gmail.com> 2 siblings, 0 replies; 9+ messages in thread From: Geliang Tang @ 2016-12-20 14:02 UTC (permalink / raw) To: Boris Ostrovsky, Juergen Gross; +Cc: Geliang Tang, linux-kernel, xen-devel 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/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 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply related [flat|nested] 9+ messages in thread
[parent not found: <56f3df3380cd7214ce0b2e151f2aa757b0eaca2c.1482205472.git.geliangtang@gmail.com>]
* Re: [PATCH] xen/evtchn: use rb_entry() [not found] ` <56f3df3380cd7214ce0b2e151f2aa757b0eaca2c.1482205472.git.geliangtang@gmail.com> @ 2016-12-20 16:20 ` Juergen Gross 2016-12-22 9:07 ` Juergen Gross 1 sibling, 0 replies; 9+ messages in thread From: Juergen Gross @ 2016-12-20 16:20 UTC (permalink / raw) To: Geliang Tang, Boris Ostrovsky; +Cc: xen-devel, linux-kernel 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 <geliangtang@gmail.com> Reviewed-by: Juergen Gross <jgross@suse.com> > --- > 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; > _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] xen/evtchn: use rb_entry() [not found] ` <56f3df3380cd7214ce0b2e151f2aa757b0eaca2c.1482205472.git.geliangtang@gmail.com> 2016-12-20 16:20 ` Juergen Gross @ 2016-12-22 9:07 ` Juergen Gross 1 sibling, 0 replies; 9+ messages in thread From: Juergen Gross @ 2016-12-22 9:07 UTC (permalink / raw) To: Geliang Tang, Boris Ostrovsky; +Cc: xen-devel, linux-kernel 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 <geliangtang@gmail.com> 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; > _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-12-22 9:07 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <ddabc96c798df194791134d8e070d728e2a7b59f.1482203698.git.geliangtang@gmail.com>
2016-12-20 14:02 ` [PATCH] xen/blkback: use rb_entry() Geliang Tang
2016-12-20 16:47 ` Konrad Rzeszutek Wilk
[not found] ` <20161220164703.GL10069@char.us.oracle.com>
2016-12-20 17:44 ` Roger Pau Monné
[not found] ` <20161220174406.uewt5mhniwtznran@dhcp-3-221.uk.xensource.com>
2016-12-20 17:51 ` Konrad Rzeszutek Wilk
[not found] ` <20161220175113.GB16671@char.us.oracle.com>
2016-12-20 21:53 ` Eric Dumazet
[not found] ` <1482270801.1521.25.camel@edumazet-glaptop3.roam.corp.google.com>
2016-12-20 22:07 ` Konrad Rzeszutek Wilk
2016-12-20 14:02 ` [PATCH] xen/evtchn: " Geliang Tang
[not found] ` <56f3df3380cd7214ce0b2e151f2aa757b0eaca2c.1482205472.git.geliangtang@gmail.com>
2016-12-20 16:20 ` Juergen Gross
2016-12-22 9:07 ` Juergen Gross
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).