From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934337AbcI3V3q (ORCPT ); Fri, 30 Sep 2016 17:29:46 -0400 Received: from g2t1383g.austin.hpe.com ([15.233.16.89]:54297 "EHLO g2t1383g.austin.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933895AbcI3V1r (ORCPT ); Fri, 30 Sep 2016 17:27:47 -0400 From: Waiman Long To: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Jonathan Corbet Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnaldo Carvalho de Melo , Davidlohr Bueso , Mike Galbraith , Jason Low , Scott J Norton , Douglas Hatch , Waiman Long Subject: [PATCH v3 03/13] futex: Add helpers to get & cmpxchg futex value without lock Date: Fri, 30 Sep 2016 17:26:12 -0400 Message-Id: <1475270782-51720-4-git-send-email-Waiman.Long@hpe.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1475270782-51720-1-git-send-email-Waiman.Long@hpe.com> References: <1475270782-51720-1-git-send-email-Waiman.Long@hpe.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- kernel/futex.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index f4e20ad..ebe59fa 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -794,6 +794,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.7.1