Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1548142 > unrolled thread

[PATCH v4 03/20] futex: Add helpers to get & cmpxchg futex value without lock

Started byWaiman Long <longman@redhat.com>
First post2016-12-29 17:20 +0100
Last post2016-12-29 17:20 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v4 03/20] futex: Add helpers to get & cmpxchg futex value without lock Waiman Long <longman@redhat.com> - 2016-12-29 17:20 +0100

#1548142 — [PATCH v4 03/20] futex: Add helpers to get & cmpxchg futex value without lock

FromWaiman Long <longman@redhat.com>
Date2016-12-29 17:20 +0100
Subject[PATCH v4 03/20] futex: Add helpers to get & cmpxchg futex value without lock
Message-ID<sTLAR-pI-19@gated-at.bofh.it>
Two new helper functions cmpxchg_futex_value() and get_futex_value()
are added to access and change the futex value without the hash
bucket lock.  As a result, page fault is enabled and the page will
be faulted in if not present yet.

Signed-off-by: Waiman Long <longman@redhat.com>
---
 kernel/futex.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/kernel/futex.c b/kernel/futex.c
index 6f7cb40..7590c7d 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -803,6 +803,21 @@ static int get_futex_value_locked(u32 *dest, u32 __user *from)
 	return ret ? -EFAULT : 0;
 }
 
+/*
+ * The equivalents of the above cmpxchg_futex_value_locked() and
+ * get_futex_value_locked which are called without the hash bucket lock
+ * and so can have page fault enabled.
+ */
+static inline int cmpxchg_futex_value(u32 *curval, u32 __user *uaddr,
+				      u32 uval, u32 newval)
+{
+	return futex_atomic_cmpxchg_inatomic(curval, uaddr, uval, newval);
+}
+
+static inline int get_futex_value(u32 *dest, u32 __user *from)
+{
+	return __get_user(*dest, from);
+}
 
 /*
  * PI code:
-- 
1.8.3.1

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web