Re: [PATCH 1/2] Move kfree_call_rcu() to slab_common.c
From: Matthew Wilcox
Date: Thu Jan 04 2018 - 18:13:13 EST
On Thu, Jan 04, 2018 at 02:18:50PM -0800, Rao Shoaib wrote:
> > > > > +#define kfree_rcu(ptr, rcu_head_name) \
> > > > > + do { \
> > > > > + typeof(ptr) __ptr = ptr; \
> > > > > + unsigned long __off = offsetof(typeof(*(__ptr)), \
> > > > > + rcu_head_name); \
> > > > > + struct rcu_head *__rptr = (void *)__ptr + __off; \
> > > > > + __kfree_rcu(__rptr, __off); \
> > > > > + } while (0)
> > > > why do you want to open code this?
> > But why are you changing this macro at all? If it was to avoid the
> > double-mention of "ptr", then you haven't done that.
> I have -- I do not get the error because ptr is being assigned only one. If
> you have a better way than let me know and I will be happy to make the
> change.
But look at the original:
#define kfree_rcu(ptr, rcu_head) \
__kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head))
^^^ ^^^
versus your version:
+#define kfree_rcu(ptr, rcu_head_name) \
+ do { \
+ typeof(ptr) __ptr = ptr; \
^^^ ^^^
+ unsigned long __off = offsetof(typeof(*(__ptr)), \
+ rcu_head_name); \
+ struct rcu_head *__rptr = (void *)__ptr + __off; \
+ __kfree_rcu(__rptr, __off); \
+ } while (0)
I don't see the difference.