From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753032AbcL2QOU (ORCPT ); Thu, 29 Dec 2016 11:14:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42952 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752734AbcL2QOQ (ORCPT ); Thu, 29 Dec 2016 11:14:16 -0500 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 , Scott J Norton , Waiman Long Subject: [PATCH v4 03/20] futex: Add helpers to get & cmpxchg futex value without lock Date: Thu, 29 Dec 2016 11:13:29 -0500 Message-Id: <1483028026-10305-4-git-send-email-longman@redhat.com> In-Reply-To: <1483028026-10305-1-git-send-email-longman@redhat.com> References: <1483028026-10305-1-git-send-email-longman@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 29 Dec 2016 16:14:16 +0000 (UTC) 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 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