[ovs-dev] [PATCH 3/4] datapath: Don't expect bottom-halves to be disabled.

Jesse Gross jesse at nicira.com
Thu May 13 23:48:09 UTC 2010


On Thu, May 13, 2010 at 10:47 AM, Ben Pfaff <blp at nicira.com> wrote:

> On Wed, May 12, 2010 at 02:33:30PM -0700, Jesse Gross wrote:
> > We currently document that BHs need to be disabled when handling
> > received packets.  However, this isn't actually generally the
> > case (usually preemption is disabled but not BHs).  Only one place
> > actually relies on BHs being disabled so fix that and update the
> > documentation of our expectations.
>
> Passes lockdep.  The changes to dp_process_received_packet() are pretty
> ugly.  It would be better, in my opinion, to write the code as
> assignments to "u64 *" and then take advantage of __this_cpu_inc().  I
> think that is one of the intended use cases of the __this_cpu_*()
> functions.  But that would also require backporting __this_cpu().
>

Yeah, it is ugly.  I backported the functions needed for __this_cpu_inc()
with the following commit:

commit e7daccede9310c5cc571857b8924271d2f405f11
Author: Jesse Gross <jesse at nicira.com>
Date:   Thu May 13 16:27:53 2010 -0700

    datapath: Backport __this_cpu functions.

    Backport some of the __this_cpu functions (specifically those needed
    for __this_cpu_inc) to earlier kernels.

diff --git a/datapath/linux-2.6/compat-2.6/include/linux/percpu.h
b/datapath/lin
index 0f68bb2..98abfa2 100644
--- a/datapath/linux-2.6/compat-2.6/include/linux/percpu.h
+++ b/datapath/linux-2.6/compat-2.6/include/linux/percpu.h
@@ -7,4 +7,35 @@
 #define percpu_ptr per_cpu_ptr
 #endif

+#ifndef per_cpu_offset
+#define per_cpu_offset(x) (__per_cpu_offset[x])
+#endif
+
+#ifndef __my_cpu_offset
+#define __my_cpu_offset per_cpu_offset(raw_smp_processor_id())
+#endif
+
+#ifndef SHIFT_PERCPU_PTR
+#define SHIFT_PERCPU_PTR(__p, __offset) RELOC_HIDE((__p), (__offset))
+#endif
+
+#ifndef __this_cpu_ptr
+#define __this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
+#endif
+
+#ifndef __this_cpu_generic_to_op
+#define __this_cpu_generic_to_op(pcp, val, op)                          \
+do {                                                                    \
+       *__this_cpu_ptr(&(pcp)) op val;                                 \
+} while (0)
+#endif
+
+#ifndef __this_cpu_add
+#define __this_cpu_add(pcp, val)       __this_cpu_generic_to_op((pcp),
(val), +
+#endif
+
+#ifndef __this_cpu_inc
+#define __this_cpu_inc(pcp)            __this_cpu_add((pcp), 1)
+#endif
+
 #endif /* linux/percpu.h wrapper */

And then used your patch.


> Also, for what it's worth, we use percpu_ptr() but it was dropped in
> 2.6.30 in favor of per_cpu_ptr().  Probably should fix that sometime
> too.
>

 I'll send out a patch next to take care of this.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20100513/f24df149/attachment-0003.html>


More information about the dev mailing list