[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190307174802.46fmpysxyo35hh43@treble>
Date: Thu, 7 Mar 2019 11:48:02 -0600
From: Josh Poimboeuf <jpoimboe@...hat.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: torvalds@...ux-foundation.org, tglx@...utronix.de, hpa@...or.com,
julien.thierry@....com, will.deacon@....com, luto@...capital.net,
mingo@...nel.org, catalin.marinas@....com, james.morse@....com,
valentin.schneider@....com, brgerst@...il.com, luto@...nel.org,
bp@...en8.de, dvlasenk@...hat.com, linux-kernel@...r.kernel.org,
dvyukov@...gle.com, rostedt@...dmis.org
Subject: Re: [PATCH 00/20] objtool: UACCESS validation v3
On Thu, Mar 07, 2019 at 06:43:22PM +0100, Peter Zijlstra wrote:
> On Thu, Mar 07, 2019 at 10:47:05AM -0600, Josh Poimboeuf wrote:
>
> > This "fixes" it, and also seems to help -Os make much code:
> >
> > diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> > index 445348facea9..8de63db58fdd 100644
> > --- a/include/linux/compiler.h
> > +++ b/include/linux/compiler.h
> > @@ -67,7 +67,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
> > .line = __LINE__, \
> > }; \
> > ______r = !!(cond); \
> > - ______f.miss_hit[______r]++; \
> > + if (______r) ______f.miss_hit[1]++; else ______f.miss_hit[0]++; \
> > ______r; \
> > }))
> > #endif /* CONFIG_PROFILE_ALL_BRANCHES */
>
> Excellen; let me put the kids to bed and then I'll have a poke.
Here's a proper patch.
From: Josh Poimboeuf <jpoimboe@...hat.com>
Subject: [PATCH] tracing: Improve "if" macro code generation
With CONFIG_PROFILE_ALL_BRANCHES, the "if" macro converts the
conditional to an array index. This can cause GCC to create horrible
code. When there are nested ifs, the generated code uses register
values to encode branching decisions.
Make it easier for GCC to optimize by keeping the conditional as a
conditional rather than converting it to an integer. This shrinks the
generated code quite a bit, and also makes the code sane enough for
objtool to understand.
Reported-by: Peter Zijlstra <peterz@...radead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com>
---
include/linux/compiler.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 445348facea9..d58aa0db05f9 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -67,7 +67,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
.line = __LINE__, \
}; \
______r = !!(cond); \
- ______f.miss_hit[______r]++; \
+ ______r ? ______f.miss_hit[1]++ : ______f.miss_hit[0]++;\
______r; \
}))
#endif /* CONFIG_PROFILE_ALL_BRANCHES */
--
2.17.2
Powered by blists - more mailing lists