From patchwork Fri May 29 17:25:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 11579387 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F9831392 for ; Fri, 29 May 2020 17:25:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3BEAB21789 for ; Fri, 29 May 2020 17:25:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iwDBR37e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BEAB21789 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3401E8001A; Fri, 29 May 2020 13:25:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2F18980010; Fri, 29 May 2020 13:25:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B8068001A; Fri, 29 May 2020 13:25:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id F377D80010 for ; Fri, 29 May 2020 13:25:17 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B1842160C6 for ; Fri, 29 May 2020 17:25:17 +0000 (UTC) X-FDA: 76870432674.21.loss56_10fe5c726010b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 93912180442C2 for ; Fri, 29 May 2020 17:25:17 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jpoimboe@redhat.com,,RULES_HIT:30012:30051:30054:30070:30079:30090:30091,0,RBL:207.211.31.120:@redhat.com:.lbl8.mailshell.net-66.10.201.10 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: loss56_10fe5c726010b X-Filterd-Recvd-Size: 5505 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Fri, 29 May 2020 17:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590773116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=x0aFDdEIWprzVJ+1w7q7ZPdjI2x8X8Jq4phAYixSU2s=; b=iwDBR37eT6oi48kPtPxbI527K+umz2RlgmsMxfSXwLtbWSUB8iP9ToV5aba877EARyQf+/ mbRVL44ScsbAPZA16PfMJwcKy4drG5R/2Z7PWBT9q8xgFJbZDPhRGxQ3fnP62sVUUhn3ls z5/jlmNJjjSzYRj4KG3y1KKZJtOzO5k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-349-fXOlowKrPN6-kKeCKTRHcw-1; Fri, 29 May 2020 13:25:12 -0400 X-MC-Unique: fXOlowKrPN6-kKeCKTRHcw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21AF5872FE0; Fri, 29 May 2020 17:25:10 +0000 (UTC) Received: from treble (ovpn-116-170.rdu2.redhat.com [10.10.116.170]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB56F7A1ED; Fri, 29 May 2020 17:25:07 +0000 (UTC) Date: Fri, 29 May 2020 12:25:05 -0500 From: Josh Poimboeuf To: Peter Zijlstra Cc: Christoph Hellwig , Randy Dunlap , 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 Subject: [PATCH] x86/uaccess: Remove redundant likely/unlikely annotations Message-ID: <20200529172505.fdjppgquujab7ayv@treble> 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200529165419.GF706460@hirez.programming.kicks-ass.net> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Rspamd-Queue-Id: 93912180442C2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 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 --- 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; }