linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Christoph Hellwig <hch@lst.de>,
	Randy Dunlap <rdunlap@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	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 <torvalds@linux-foundation.org>,
	viro@zeniv.linux.org.uk, x86@kernel.org,
	Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH] x86/uaccess: Remove redundant likely/unlikely annotations
Date: Fri, 29 May 2020 12:25:05 -0500	[thread overview]
Message-ID: <20200529172505.fdjppgquujab7ayv@treble> (raw)
In-Reply-To: <20200529165419.GF706460@hirez.programming.kicks-ass.net>

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 <jpoimboe@redhat.com>
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 <rdunlap@infradead.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 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;
 	}
-- 
2.21.3



  reply	other threads:[~2020-05-29 17:25 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14  0:50 incoming Andrew Morton
2020-05-14  0:50 ` [patch 1/7] mm, memcg: fix inconsistent oom event behavior Andrew Morton
2020-05-14  0:50 ` [patch 2/7] epoll: call final ep_events_available() check under the lock Andrew Morton
2020-05-14  0:50 ` [patch 3/7] mm/gup: fix fixup_user_fault() on multiple retries Andrew Morton
2020-05-14  0:50 ` [patch 4/7] userfaultfd: fix remap event with MREMAP_DONTUNMAP Andrew Morton
2020-05-14  0:50 ` [patch 5/7] ipc/util.c: sysvipc_find_ipc() incorrectly updates position index Andrew Morton
2020-05-14  0:50 ` [patch 6/7] kasan: consistently disable debugging features Andrew Morton
2020-05-14  0:50 ` [patch 7/7] kasan: add missing functions declarations to kasan.h Andrew Morton
2020-05-14  3:31 ` mmotm 2020-05-13-20-30 uploaded Andrew Morton
2020-05-14 15:30   ` mmotm 2020-05-13-20-30 uploaded (gpu/drm/bridge/sil-sii8620) Randy Dunlap
2020-05-14 15:32   ` mmotm 2020-05-13-20-30 uploaded (objtool warnings) Randy Dunlap
2020-05-14 15:33     ` Randy Dunlap
2020-05-28 15:54     ` Josh Poimboeuf
2020-05-28 17:04       ` Josh Poimboeuf
2020-05-28 17:20     ` Peter Zijlstra
2020-05-29 13:57       ` Christoph Hellwig
2020-05-29 14:35         ` Peter Zijlstra
2020-05-29 14:53           ` Peter Zijlstra
2020-05-29 15:33             ` Peter Zijlstra
2020-05-29 16:05               ` Josh Poimboeuf
2020-05-29 16:12                 ` Peter Zijlstra
2020-05-29 16:50                   ` Josh Poimboeuf
2020-05-29 16:54                     ` Peter Zijlstra
2020-05-29 17:25                       ` Josh Poimboeuf [this message]
2020-05-29 18:29                         ` [PATCH] x86/uaccess: Remove redundant likely/unlikely annotations Randy Dunlap
2020-05-29 19:31                     ` mmotm 2020-05-13-20-30 uploaded (objtool warnings) Linus Torvalds
2020-05-29 20:08                       ` Al Viro
2020-05-29 20:14                         ` Al Viro
2020-05-15 23:30 ` mmotm 2020-05-15-16-29 uploaded Andrew Morton
2020-05-16  5:53   ` Stephen Rothwell
2020-05-18 23:15     ` Stephen Rothwell
2020-05-20  4:48 ` mmotm 2020-05-19-21-47 uploaded Andrew Morton
2020-05-22  3:43 ` mmotm 2020-05-21-20-42 uploaded Andrew Morton
2020-05-22 16:26   ` mmotm 2020-05-21-20-42 uploaded (atomisp) Randy Dunlap
2020-05-23  3:36 ` mmotm 2020-05-22-20-35 uploaded Andrew Morton
2020-05-23 15:08   ` mmotm 2020-05-22-20-35 uploaded (phy/intel/phy-intel-combo.c) Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200529172505.fdjppgquujab7ayv@treble \
    --to=jpoimboe@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=broonie@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-next@vger.kernel.org \
    --cc=mhocko@suse.cz \
    --cc=mm-commits@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sfr@canb.auug.org.au \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).