From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 212E5C433E0 for ; Thu, 18 Feb 2021 18:16:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C494764EAE for ; Thu, 18 Feb 2021 18:16:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230469AbhBRSP6 convert rfc822-to-8bit (ORCPT ); Thu, 18 Feb 2021 13:15:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232562AbhBRPtj (ORCPT ); Thu, 18 Feb 2021 10:49:39 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2E16C061756; Thu, 18 Feb 2021 07:48:55 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id EE6261F45D20 From: Gabriel Krisman Bertazi To: =?utf-8?Q?Andr=C3=A9?= Almeida Cc: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , linux-kernel@vger.kernel.org, Steven Rostedt , Sebastian Andrzej Siewior , kernel@collabora.com, pgriffais@valvesoftware.com, z.figura12@gmail.com, joel@joelfernandes.org, malteskarupke@fastmail.fm, linux-api@vger.kernel.org, fweimer@redhat.com, libc-alpha@sourceware.org, linux-kselftest@vger.kernel.org, shuah@kernel.org, acme@kernel.org, corbet@lwn.net Subject: Re: [RFC PATCH 01/13] futex2: Implement wait and wake functions In-Reply-To: <74e321d5-2cf5-f3a6-6a7a-49e1ed2fda07@collabora.com> (=?utf-8?Q?=22Andr=C3=A9?= Almeida"'s message of "Thu, 18 Feb 2021 10:29:46 -0300") Organization: Collabora References: <20210215152404.250281-1-andrealmeid@collabora.com> <20210215152404.250281-2-andrealmeid@collabora.com> <87k0r9w19l.fsf@collabora.com> <74e321d5-2cf5-f3a6-6a7a-49e1ed2fda07@collabora.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Date: Thu, 18 Feb 2021 10:48:50 -0500 Message-ID: <87y2fltlzx.fsf@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org André Almeida writes: >>> + if (unlikely(ret)) { >>> + spin_unlock(&bucket->lock); >>> + >>> + bucket_dec_waiters(bucket); >>> + __set_current_state(TASK_RUNNING); >>> + *awakened = futex_dequeue_multiple(futexv, i); >>> + >>> + if (__get_user(uval, uaddr)) >>> + return -EFAULT; >>> + >>> + if (*awakened >= 0) >>> + return 1; >> If you are awakened, you don't need to waste time with trying to get >> the >> next key. >> > > Yes, and this is what this return is supposed to do. What I'm missing? you don't need to do that __get_user if some other key was already awoke. [...] if (*awakened >= 0) return 1; if (__get_user(uval, uaddr)) return -EFAULT; [...] -- Gabriel Krisman Bertazi