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=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 9B838C433B4 for ; Fri, 23 Apr 2021 21:40:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C29561467 for ; Fri, 23 Apr 2021 21:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230056AbhDWVlJ (ORCPT ); Fri, 23 Apr 2021 17:41:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244088AbhDWVlB (ORCPT ); Fri, 23 Apr 2021 17:41:01 -0400 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 1D20EC061574 for ; Fri, 23 Apr 2021 14:40:23 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id AB8A91F40FD7 Subject: Re: [patch 3/6] futex: Get rid of the val2 conditional dance To: Thomas Gleixner , LKML Cc: Peter Zijlstra , Adhemerval Zanella , Lukasz Majewski , Florian Weimer , Carlos O'Donell , "Michael Kerrisk (man-pages)" , Davidlohr Bueso , Ingo Molnar , Darren Hart , Andrei Vagin , Kurt Kanzenbach , kernel@collabora.com References: <20210422194417.866740847@linutronix.de> <20210422194705.125957049@linutronix.de> From: =?UTF-8?Q?Andr=c3=a9_Almeida?= Message-ID: Date: Fri, 23 Apr 2021 18:40:13 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <20210422194705.125957049@linutronix.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Thomas, Às 16:44 de 22/04/21, Thomas Gleixner escreveu: > There is no point in checking which FUTEX operand treats the utime pointer > as 'val2' argument because that argument to do_futex() is only used by > exactly these operands. > > So just handing it in unconditionally is not making any difference, but > removes a lot of pointless gunk. > > Signed-off-by: Thomas Gleixner > --- > kernel/futex.c | 16 ++-------------- > 1 file changed, 2 insertions(+), 14 deletions(-) > > --- a/kernel/futex.c > +++ b/kernel/futex.c > @@ -3765,7 +3765,6 @@ SYSCALL_DEFINE6(futex, u32 __user *, uad > { > struct timespec64 ts; > ktime_t t, *tp = NULL; > - u32 val2 = 0; > int cmd = op & FUTEX_CMD_MASK; > > if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI || > @@ -3785,15 +3784,8 @@ SYSCALL_DEFINE6(futex, u32 __user *, uad > t = timens_ktime_to_host(CLOCK_MONOTONIC, t); > tp = &t; > } > - /* > - * requeue parameter in 'utime' if cmd == FUTEX_*_REQUEUE_*. > - * number of waiters to wake in 'utime' if cmd == FUTEX_WAKE_OP. > - */ > - if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE || > - cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP) > - val2 = (u32) (unsigned long) utime; > > - return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); > + return do_futex(uaddr, op, val, tp, uaddr2, (unsigned long)utime, val3); Given do_futex()'s type signature, I think it makes more sense to cast utime to u32. > } > > #ifdef CONFIG_COMPAT > @@ -3961,7 +3953,6 @@ SYSCALL_DEFINE6(futex_time32, u32 __user > { > struct timespec64 ts; > ktime_t t, *tp = NULL; > - int val2 = 0; > int cmd = op & FUTEX_CMD_MASK; > > if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI || > @@ -3979,11 +3970,8 @@ SYSCALL_DEFINE6(futex_time32, u32 __user > t = timens_ktime_to_host(CLOCK_MONOTONIC, t); > tp = &t; > } > - if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE || > - cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP) > - val2 = (int) (unsigned long) utime; > > - return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); > + return do_futex(uaddr, op, val, tp, uaddr2, (unsigned long)utime, val3); Same here. > } > #endif /* CONFIG_COMPAT_32BIT_TIME */ > >