From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: John Fastabend <john.fastabend@gmail.com>,
xiyou.wangcong@gmail.com, jhs@mojatatu.com,
netdev@vger.kernel.org, davem@davemloft.net
Subject: Re: [RCU PATCH 06/14] net: sched: fw use RCU
Date: Thu, 13 Mar 2014 13:22:46 -0700 [thread overview]
Message-ID: <20140313202245.GK21124@linux.vnet.ibm.com> (raw)
In-Reply-To: <1394643673.21721.48.camel@edumazet-glaptop2.roam.corp.google.com>
On Wed, Mar 12, 2014 at 10:01:13AM -0700, Eric Dumazet wrote:
> On Wed, 2014-03-12 at 09:41 -0700, John Fastabend wrote:
>
> > Rearranging the rcu_head placement above results in this error:
> >
> > net/sched/cls_fw.c: In function ‘fw_destroy’:
> > net/sched/cls_fw.c:169:279: error: call to ‘__compiletime_assert_169’
> > declared with attribute error: BUILD_BUG_ON failed:
> > !__is_kfree_rcu_offset(__builtin_offsetof(typeof(*(head)),rcu))
> >
> >
> > However it seems best to have the rcu_head at the end of the struct
> > so I'll just convert the kfree_rcu() to call_rcu().
>
>
> I missed HTSIZE was so big.
>
> Its unfortunate because it makes struct fw_head slightly larger than one
> page.
Hmmm... You know, the offset that kfree uses is a byte offset. I see
no reason why any of the rcu_head structures should be misaligned. If
HTSIZE is too big by only a factor of four or smaller, would the following
(untested) patch to RCU be appropriate?
Thanx, Paul
------------------------------------------------------------------------
rcu: Increase kfree_rcu() offset range
The kfree_rcu() function operates by placing an offset into the rcu_head
structure in place of the function pointer that is normally there.
This offset cannot exceed 4095, on the theory that no Linux kernel will
ever have executable code in page zero. However, the rcu_head structure
contains a pair of function pointers, and should never be misaligned.
This commit therefore divides the offset by the size of a pointer when
being placed into the rcu_head structure, and multiplies it by this
same constant when pulling it out.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 3cea28c64ebe..2dc4ecf923d0 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -1023,8 +1023,13 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
* The BUILD_BUG_ON check must not involve any function calls, hence the
* checks are done in macros here.
*/
-#define kfree_rcu(ptr, rcu_head) \
- __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head))
+#define kfree_rcu(ptr, rcu_head) \
+do { \
+ unsigned long ___offset = offsetof(typeof(*(ptr)), rcu_head); \
+ \
+ BUILD_BUG_ON(___offset & (sizeof(void *) - 1)); \
+ __kfree_rcu(&((ptr)->rcu_head), ___offset / sizeof(void *)); \
+} while (0)
#if defined(CONFIG_TINY_RCU) || defined(CONFIG_RCU_NOCB_CPU_ALL)
static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies)
diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index bfda2726ca45..93dbd98ad6da 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -106,7 +106,7 @@ static inline bool __rcu_reclaim(const char *rn, struct rcu_head *head)
rcu_lock_acquire(&rcu_callback_map);
if (__is_kfree_rcu_offset(offset)) {
RCU_TRACE(trace_rcu_invoke_kfree_callback(rn, head, offset));
- kfree((void *)head - offset);
+ kfree((void *)head - offset * sizeof(void *));
rcu_lock_release(&rcu_callback_map);
return 1;
} else {
next prev parent reply other threads:[~2014-03-13 20:22 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-10 17:03 [RCU PATCH 00/14] Remove qdisc lock around ingress Qdisc John Fastabend
2014-03-10 17:03 ` [RCU PATCH 01/14] net: qdisc: use rcu prefix and silence sparse warnings John Fastabend
2014-03-10 17:20 ` Eric Dumazet
2014-03-10 17:04 ` [RCU PATCH 02/14] net: rcu-ify tcf_proto John Fastabend
2014-03-10 17:30 ` Eric Dumazet
2014-03-10 17:04 ` [RCU PATCH 03/14] net: sched: cls_basic use RCU John Fastabend
2014-03-10 17:33 ` Eric Dumazet
2014-03-10 17:04 ` [RCU PATCH 04/14] net: sched: cls_cgroup " John Fastabend
2014-03-10 17:36 ` Eric Dumazet
2014-03-10 17:05 ` [RCU PATCH 05/14] net: sched: cls_flow " John Fastabend
2014-03-10 17:38 ` Eric Dumazet
2014-03-10 17:05 ` [RCU PATCH 06/14] net: sched: fw " John Fastabend
2014-03-10 17:41 ` Eric Dumazet
2014-03-12 16:41 ` John Fastabend
2014-03-12 17:01 ` Eric Dumazet
2014-03-13 20:22 ` Paul E. McKenney [this message]
2014-03-13 20:56 ` Eric Dumazet
2014-03-13 21:15 ` Paul E. McKenney
2014-03-14 5:43 ` John Fastabend
2014-03-14 13:28 ` Paul E. McKenney
2014-03-14 13:46 ` Eric Dumazet
2014-03-14 15:38 ` Paul E. McKenney
2014-03-14 18:50 ` Paul E. McKenney
2014-03-14 18:59 ` Paul E. McKenney
2014-03-14 19:55 ` Eric Dumazet
2014-03-14 20:35 ` Paul E. McKenney
2014-03-16 16:06 ` [PATCH net-next] net: sched: use no more than one page in struct fw_head Eric Dumazet
2014-03-17 13:51 ` Thomas Graf
2014-03-17 14:13 ` Eric Dumazet
2014-03-17 14:29 ` David Laight
2014-03-17 15:16 ` Eric Dumazet
2014-03-17 15:30 ` Thomas Graf
2014-03-17 15:33 ` Eric Dumazet
2014-03-17 15:43 ` David Laight
2014-03-17 15:52 ` Eric Dumazet
2014-03-17 15:28 ` Thomas Graf
2014-03-17 15:50 ` Thomas Graf
2014-03-17 16:00 ` David Laight
2014-03-17 16:16 ` Eric Dumazet
2014-03-18 2:31 ` David Miller
2014-03-18 3:02 ` Eric Dumazet
2014-03-18 3:20 ` [PATCH v2 " Eric Dumazet
2014-03-18 9:19 ` Thomas Graf
2014-03-18 18:18 ` David Miller
2014-03-10 17:06 ` [RCU PATCH 07/14] net: sched: RCU cls_route John Fastabend
2014-03-10 17:45 ` Eric Dumazet
2014-03-10 19:36 ` John Fastabend
2014-03-10 17:06 ` [RCU PATCH 08/14] net: sched: RCU cls_tcindex John Fastabend
2014-03-10 17:07 ` [RCU PATCH 09/14] net: sched: make cls_u32 lockless John Fastabend
2014-03-10 17:58 ` Eric Dumazet
2014-03-10 17:07 ` [RCU PATCH 10/14] net: sched: rcu'ify cls_rsvp John Fastabend
2014-03-10 17:07 ` [RCU PATCH 11/14] net: make cls_bpf rcu safe John Fastabend
2014-03-10 17:08 ` [RCU PATCH 12/14] net: sched: make tc_action safe to walk under RCU John Fastabend
2014-03-10 17:08 ` [RCU PATCH 13/14] net: sched: make bstats per cpu and estimator RCU safe John Fastabend
2014-03-10 18:06 ` Eric Dumazet
2014-03-10 19:36 ` John Fastabend
2014-03-10 17:09 ` [RCU PATCH 14/14] net: sched: drop ingress qdisc lock John Fastabend
2014-03-11 20:36 ` [RCU PATCH 00/14] Remove qdisc lock around ingress Qdisc David Miller
2014-03-11 20:53 ` Eric Dumazet
2014-03-12 6:58 ` Jamal Hadi Salim
2014-03-12 16:45 ` John Fastabend
2014-03-13 8:44 ` Jamal Hadi Salim
2014-03-14 7:28 ` John Fastabend
2014-03-14 7:45 ` Jamal Hadi Salim
2014-03-12 18:25 ` Cong Wang
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=20140313202245.GK21124@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=jhs@mojatatu.com \
--cc=john.fastabend@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
/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).