Geert Uytterhoeven
2013-05-31 09:16:20 UTC
--- linux-3.8/arch/m68k/include/asm/futex.h.~1~ 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.8/arch/m68k/include/asm/futex.h 2013-02-20 22:07:23.459917612 +0100
@@ -0,0 +1,94 @@
+#ifndef _ASM_M68K_FUTEX_H
+#define _ASM_M68K_FUTEX_H
+
+#ifdef __KERNEL__
+#if !defined(CONFIG_MMU)
+#include <asm-generic/futex.h>
+#else /* CONFIG_MMU */
Why would you not use the version below on nommu?+++ linux-3.8/arch/m68k/include/asm/futex.h 2013-02-20 22:07:23.459917612 +0100
@@ -0,0 +1,94 @@
+#ifndef _ASM_M68K_FUTEX_H
+#define _ASM_M68K_FUTEX_H
+
+#ifdef __KERNEL__
+#if !defined(CONFIG_MMU)
+#include <asm-generic/futex.h>
+#else /* CONFIG_MMU */
It doesn't seem to have any real dependencies on MMU support?
What am I missing?
no-MMU butchers the semantics of the various primitives (mainly the
user-space accessors).
Does no-MMU pagefault_disable() disable preemption? This code
relies on that.
It seems it does.relies on that.
+#include <linux/futex.h>
+#include <linux/uaccess.h>
+#include <asm/errno.h>
+
+static inline int
+futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
+ u32 oldval, u32 newval)
+{
+ u32 val;
+
+ if (unlikely(get_user(val, uaddr) != 0))
+ return -EFAULT;
+
+ if (val == oldval && unlikely(put_user(newval, uaddr) != 0))
+ return -EFAULT;
+
+ *uval = val;
+
+ return 0;
+}
This is purely generic, so it could move to the asm-generic version,+#include <linux/uaccess.h>
+#include <asm/errno.h>
+
+static inline int
+futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
+ u32 oldval, u32 newval)
+{
+ u32 val;
+
+ if (unlikely(get_user(val, uaddr) != 0))
+ return -EFAULT;
+
+ if (val == oldval && unlikely(put_user(newval, uaddr) != 0))
+ return -EFAULT;
+
+ *uval = val;
+
+ return 0;
+}
also fixing blackfin, c6x, metag, openrisc, um, unicore32, and xtensa?
investigate each and every arch to guess if they can safely use this
version or not. I'd rather put this somewhere alongside the stub futex.h
and have other archs opt-in at the discretion of their maintainers.
decide the rest...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds