Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1333519
| From | Nicolas Pitre <nicolas.pitre@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] [media] zl10353: use div_u64 instead of do_div |
| Date | 2016-02-14 18:00 +0100 |
| Message-ID | <r28bF-5jV-15@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <r1qDE-2aX-9@gated-at.bofh.it> <r1t8w-3TO-63@gated-at.bofh.it> <r1E3U-2mN-25@gated-at.bofh.it> <r1Qoq-1Y5-7@gated-at.bofh.it> <r1ZL4-8cu-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Sun, 14 Feb 2016, Ard Biesheuvel wrote:
> On 13 February 2016 at 22:57, Nicolas Pitre <nicolas.pitre@linaro.org> wrote:
> > On Sat, 13 Feb 2016, Ard Biesheuvel wrote:
> >
> >> On 12 February 2016 at 22:01, Arnd Bergmann <arnd@arndb.de> wrote:
> >> > However, I did stumble over an older patch I did now, which I could
> >> > not remember what it was good for. It does fix the problem, and
> >> > it seems to be a better solution.
> >> >
> >> > Arnd
> >> >
> >> > diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> >> > index b5acbb404854..b5ff9881bef8 100644
> >> > --- a/include/linux/compiler.h
> >> > +++ b/include/linux/compiler.h
> >> > @@ -148,7 +148,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
> >> > */
> >> > #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> >> > #define __trace_if(cond) \
> >> > - if (__builtin_constant_p((cond)) ? !!(cond) : \
> >> > + if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
> >> > ({ \
> >> > int ______r; \
> >> > static struct ftrace_branch_data \
> >> >
> >>
> >> I remember seeing this patch, but I don't remember the exact context.
> >> But when you think about it, !!cond can be a build time constant even
> >> if cond is not, as long as you can prove statically that cond != 0. So
> >
> > You're right. I just tested it and to my surprise gcc is smart enough
> > to figure that case out.
> >
> >> I think this change is obviously correct, and an improvement since it
> >> will remove the profiling overhead of branches that are not true
> >> branches in the first place.
> >
> > Indeed.
> >
>
> ... and perhaps we should not evaluate cond twice either?
It is not. The value of the argument to __builtin_constant_p() is not
itself evaluated and therefore does not produce side effects.
Nicolas
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] [media] zl10353: use div_u64 instead of do_div Arnd Bergmann <arnd@arndb.de> - 2016-02-12 15:30 +0100
Re: [PATCH] [media] zl10353: use div_u64 instead of do_div Mauro Carvalho Chehab <mchehab@osg.samsung.com> - 2016-02-12 17:40 +0100
Re: [PATCH] [media] zl10353: use div_u64 instead of do_div Arnd Bergmann <arnd@arndb.de> - 2016-02-12 18:10 +0100
Re: [PATCH] [media] zl10353: use div_u64 instead of do_div Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-02-12 19:30 +0100
Re: [PATCH] [media] zl10353: use div_u64 instead of do_div Arnd Bergmann <arnd@arndb.de> - 2016-02-12 22:10 +0100
Re: [PATCH] [media] zl10353: use div_u64 instead of do_div Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-02-12 22:40 +0100
Re: [PATCH] [media] zl10353: use div_u64 instead of do_div Arnd Bergmann <arnd@arndb.de> - 2016-02-12 22:50 +0100
Re: [PATCH] [media] zl10353: use div_u64 instead of do_div Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-02-13 09:50 +0100
Re: [PATCH] [media] zl10353: use div_u64 instead of do_div Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-02-13 23:00 +0100
Re: [PATCH] [media] zl10353: use div_u64 instead of do_div Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-02-14 09:00 +0100
Re: [PATCH] [media] zl10353: use div_u64 instead of do_div Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-02-14 18:00 +0100
Re: [PATCH] [media] zl10353: use div_u64 instead of do_div Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-02-14 20:10 +0100
csiph-web