Re: [PATCH 02/36] scsi,rcu: convert call_rcu(fc_rport_free_rcu) to
kfree_rcu()
[Posted March 30, 2011 by corbet]
| From: |
| "Paul E. McKenney" <paulmck-AT-linux.vnet.ibm.com> |
| To: |
| James Bottomley <James.Bottomley-AT-suse.de> |
| Subject: |
| Re: [PATCH 02/36] scsi,rcu: convert call_rcu(fc_rport_free_rcu) to
kfree_rcu() |
| Date: |
| Wed, 23 Mar 2011 17:32:23 -0700 |
| Message-ID: |
| <20110324003223.GF2322@linux.vnet.ibm.com> |
| Cc: |
| Robert Love <robert.w.love-AT-intel.com>,
Lai Jiangshan <laijs-AT-cn.fujitsu.com>,
Ingo Molnar <mingo-AT-elte.hu>, Jens Axboe <axboe-AT-kernel.dk>,
Neil Horman <nhorman-AT-tuxdriver.com>,
"David S. Miller" <davem-AT-davemloft.net>,
Alexey Kuznetsov <kuznet-AT-ms2.inr.ac.ru>,
"Pekka Savola (ipv6)" <pekkas-AT-netcore.fi>,
James Morris <jmorris-AT-namei.org>,
Hideaki YOSHIFUJI <yoshfuji-AT-linux-ipv6.org>,
Patrick McHardy <kaber-AT-trash.net>,
Eric Dumazet <eric.dumazet-AT-gmail.com>,
Stephen Hemminger <shemminger-AT-vyatta.com>,
Tejun Heo <tj-AT-kernel.org>, Jarek Poplawski <jarkao2-AT-gmail.com>,
"linux-kernel-AT-vger.kernel.org" <linux-kernel-AT-vger.kernel.org>,
"devel-AT-open-fcoe.org" <devel-AT-open-fcoe.org>,
"linux-scsi-AT-vger.kernel.org" <linux-scsi-AT-vger.kernel.org>,
"netdev-AT-vger.kernel.org" <netdev-AT-vger.kernel.org> |
| Archive‑link: | |
Article |
On Wed, Mar 23, 2011 at 05:45:32PM -0500, James Bottomley wrote:
> On Wed, 2011-03-23 at 15:24 -0700, Paul E. McKenney wrote:
> > On Wed, Mar 23, 2011 at 09:05:51AM -0500, James Bottomley wrote:
> > > On Tue, 2011-03-22 at 23:50 -0700, Paul E. McKenney wrote:
> > > > The kfree_rcu() definition is as
> > > > follows:
> > > >
> > > > #define kfree_rcu(ptr, rcu_head) \
> > > > __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head))
> > >
> > > Isn't this one of those cases where the obvious use of the interface is
> > > definitely wrong?
> > >
> > > It's also another nasty pseudo C prototype. I know we do this sort of
> > > thing for container_of et al, but I don't really think we want to extend
> > > it.
> > >
> > > Why not make the interface take a pointer to the embedding structure and
> > > one to the rcu_head ... that way all pointer mathematics can be
> > > contained inside the RCU routines.
> >
> > Hello, James,
> >
> > If you pass in a pair of pointers, then it is difficult for RCU to detect
> > bugs where the two pointers are unrelated. Yes, you can do some sanity
> > checks, but these get cumbersome and have corner cases where they can
> > be fooled. In contrast, Lai's interface allows the compiler to do the
> > needed type checking -- unless the second argument is a field of type
> > struct rcu_head in the structure pointed to by the first argument, the
> > compiler will complain.
> >
> > Either way, the pointer mathematics are buried in the RCU API.
> >
> > Or am I missing something here?
>
> No ... I like the utility ... I just dislike the inelegance of having to
> name a structure element in what looks like a C prototype.
>
> I can see this proliferating everywhere since most of our reference
> counting release callbacks basically free the enclosing object ...
Indeed! Improvements are welcome -- it is just that I am not convinced
that the dual-pointer approach is really an improvement.
The C preprocessor... It is ugly, inelegant, painful, annoying, and
should have been strangled at birth -- but it is always there when you
need it!
Thanx, Paul
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html