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=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 B2328C433E1 for ; Fri, 29 May 2020 18:29:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 52D1D20723 for ; Fri, 29 May 2020 18:29:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="OktvBRzz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52D1D20723 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C02528001A; Fri, 29 May 2020 14:29:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B8C9D80010; Fri, 29 May 2020 14:29:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2C4A8001A; Fri, 29 May 2020 14:29:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0075.hostedemail.com [216.40.44.75]) by kanga.kvack.org (Postfix) with ESMTP id 876A080010 for ; Fri, 29 May 2020 14:29:31 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 459188248076 for ; Fri, 29 May 2020 18:29:31 +0000 (UTC) X-FDA: 76870594542.17.root55_8d45e9fa89908 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 16485180D0184 for ; Fri, 29 May 2020 18:29:31 +0000 (UTC) X-HE-Tag: root55_8d45e9fa89908 X-Filterd-Recvd-Size: 5469 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Fri, 29 May 2020 18:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=B5WVANQZx4YCGx97jJ5OLiz8s2lEqqhT42bbB5YnkyM=; b=OktvBRzz6+OuWH5zwNRdS/Angw zaWqzcSHUi7LJ+pozmbCvkcKL+K6eyAYP2YkbChE4QjKJJoauaZqqKzVr23x/72OP04qi/Px9dm6s Ad5YUeDqgMiefrDYSr1sJIne+NX7MNVsNgW6SfFbSopUtDp8HFaGwOX0+lpmvgW8YU8X3dbGNJkYk EddZkfa2GsHiOna7DkMtbEyy/pmRGktK6k3Uwh6qKbIYjAqw9CE57DALW+f4SQE/3pMrZVKQR73V9 9ReybVEUI/yS3lRLHckpUw9OaYwfPgffzUCQ179BUWISlzXaZ7fVVOIe03B4JGSebLOWAkUuIPNjU ZEaOh3/w==; Received: from [2601:1c0:6280:3f0::19c2] by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jejkq-0006aG-Fy; Fri, 29 May 2020 18:29:16 +0000 Subject: Re: [PATCH] x86/uaccess: Remove redundant likely/unlikely annotations To: Josh Poimboeuf , Peter Zijlstra Cc: Christoph Hellwig , Andrew Morton , broonie@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-next@vger.kernel.org, mhocko@suse.cz, mm-commits@vger.kernel.org, sfr@canb.auug.org.au, Linus Torvalds , viro@zeniv.linux.org.uk, x86@kernel.org, Steven Rostedt References: <611fa14d-8d31-796f-b909-686d9ebf84a9@infradead.org> <20200528172005.GP2483@worktop.programming.kicks-ass.net> <20200529135750.GA1580@lst.de> <20200529143556.GE706478@hirez.programming.kicks-ass.net> <20200529145325.GB706518@hirez.programming.kicks-ass.net> <20200529153336.GC706518@hirez.programming.kicks-ass.net> <20200529160514.cyaytn33thphb3tz@treble> <20200529161253.GD706460@hirez.programming.kicks-ass.net> <20200529165011.o7vvhn4wcj6zjxux@treble> <20200529165419.GF706460@hirez.programming.kicks-ass.net> <20200529172505.fdjppgquujab7ayv@treble> From: Randy Dunlap Message-ID: <77d5741f-4b84-4cb8-1b01-3e411d3b8a70@infradead.org> Date: Fri, 29 May 2020 11:29:14 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200529172505.fdjppgquujab7ayv@treble> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 16485180D0184 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 5/29/20 10:25 AM, Josh Poimboeuf wrote: > On Fri, May 29, 2020 at 06:54:19PM +0200, Peter Zijlstra wrote: >> On Fri, May 29, 2020 at 11:50:11AM -0500, Josh Poimboeuf wrote: >>> The nested likelys seem like overkill anyway -- user_access_begin() is >>> __always_inline and it already has unlikely(), which should be >>> propagated. >>> >>> So just remove the outer likelys? >> >> That fixes it. Ack! > > If there are no objections to the patch, I can add it to my objtool-core > branch unless anybody else wants to take it. It only affects > linux-next. > > ---8<--- > > From: Josh Poimboeuf > Subject: [PATCH] x86/uaccess: Remove redundant likely/unlikely annotations > > Since user_access_begin() already has an unlikely() annotation for its > access_ok() check, "if (likely(user_access_begin))" results in nested > likely annotations. When combined with CONFIG_TRACE_BRANCH_PROFILING, > GCC converges the error/success paths of the nested ifs, using a > register value to distinguish between them. > > While the code is technically uaccess safe, it complicates the > branch-profiling generated code. It also confuses objtool, because it > doesn't do register value tracking, resulting in the following warnings: > > arch/x86/lib/csum-wrappers_64.o: warning: objtool: csum_and_copy_from_user()+0x2a4: call to memset() with UACCESS enabled > arch/x86/lib/csum-wrappers_64.o: warning: objtool: csum_and_copy_to_user()+0x243: return with UACCESS enabled > > The outer likely annotations aren't actually needed anyway, since the > compiler propagates the error path coldness when it inlines > user_access_begin(). > > Fixes: 18372ef87665 ("x86_64: csum_..._copy_..._user(): switch to unsafe_..._user()") > Reported-by: Randy Dunlap > Acked-by: Peter Zijlstra > Signed-off-by: Josh Poimboeuf Acked-by: Randy Dunlap # build-tested Thanks. > --- > arch/x86/lib/csum-wrappers_64.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c > index a12b8629206d..ee63d7576fd2 100644 > --- a/arch/x86/lib/csum-wrappers_64.c > +++ b/arch/x86/lib/csum-wrappers_64.c > @@ -27,7 +27,7 @@ csum_and_copy_from_user(const void __user *src, void *dst, > might_sleep(); > *errp = 0; > > - if (!likely(user_access_begin(src, len))) > + if (!user_access_begin(src, len)) > goto out_err; > > /* > @@ -89,7 +89,7 @@ csum_and_copy_to_user(const void *src, void __user *dst, > > might_sleep(); > > - if (unlikely(!user_access_begin(dst, len))) { > + if (!user_access_begin(dst, len)) { > *errp = -EFAULT; > return 0; > } > -- ~Randy