* Vegard Nossum <[email protected]> wrote:

> On 27 July 2016 at 11:15, Ingo Molnar <[email protected]> wrote:
> >
> > * Vegard Nossum <[email protected]> wrote:
> [...]
> 
> > These two blocks could be merged trivially, avoiding an #ifdef pair ...
> 
> >> @@ -7541,6 +7550,9 @@ EXPORT_SYMBOL(__might_sleep);
> >>  void ___might_sleep(const char *file, int line, int preempt_offset)
> >>  {
> >>       static unsigned long prev_jiffy;        /* ratelimiting */
> >> +#ifdef CONFIG_DEBUG_PREEMPT
> >> +     unsigned long preempt_disable_ip;
> >> +#endif
> >>
> >>       rcu_sleep_check(); /* WARN_ON_ONCE() by default, no rate limit reqd. 
> >> */
> >>       if ((preempt_count_equals(preempt_offset) && !irqs_disabled() &&
> >> @@ -7551,6 +7563,11 @@ void ___might_sleep(const char *file, int line, int 
> >> preempt_offset)
> >>               return;
> >>       prev_jiffy = jiffies;
> >>
> >> +#ifdef CONFIG_DEBUG_PREEMPT
> >> +     /* Save this before calling printk(), since that will clobber it */
> >> +     preempt_disable_ip = current->preempt_disable_ip;
> >> +#endif
> >
> > Ditto.
> 
> I'm assuming you want to declare and initialise preempt_disable_ip at
> once here, but it generates slightly worse code since it dereferences
> current->preempt_disable_ip in the "fast path" (i.e. a sleeping
> function is NOT called from an invalid context).

Could you please add a likely() branch to see whether GCC will delay the 
initialization?

The 4 #ifdefs were really ugly, so yes, it would be nice to at least reduce 
them 
to 2.

Thanks,

        Ingo

Reply via email to