lkml.org 
[lkml]   [2017]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: in_irq_or_nmi()
On Mon, Mar 27, 2017 at 09:58:17AM -0700, Matthew Wilcox wrote:
> On Mon, Mar 27, 2017 at 05:15:00PM +0200, Jesper Dangaard Brouer wrote:
> > And I also verified it worked:
> >
> > 0.63 │ mov __preempt_count,%eax
> > │ free_hot_cold_page():
> > 1.25 │ test $0x1f0000,%eax
> > │ ↓ jne 1e4
> >
> > And this simplification also made the compiler change this into a
> > unlikely branch, which is a micro-optimization (that I will leave up to
> > the compiler).
>
> Excellent! That said, I think we should define in_irq_or_nmi() in
> preempt.h, rather than hiding it in the memory allocator. And since we're
> doing that, we might as well make it look like the other definitions:
>
> diff --git a/include/linux/preempt.h b/include/linux/preempt.h
> index 7eeceac52dea..af98c29abd9d 100644
> --- a/include/linux/preempt.h
> +++ b/include/linux/preempt.h
> @@ -81,6 +81,7 @@
> #define in_interrupt() (irq_count())
> #define in_serving_softirq() (softirq_count() & SOFTIRQ_OFFSET)
> #define in_nmi() (preempt_count() & NMI_MASK)
> +#define in_irq_or_nmi() (preempt_count() & (HARDIRQ_MASK | NMI_MASK))
> #define in_task() (!(preempt_count() & \
> (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET)))
>

No, that's horrible. Also, wth is this about? A memory allocator that
needs in_nmi()? That sounds beyond broken.

\
 
 \ /
  Last update: 2017-03-29 10:16    [W:0.067 / U:1.636 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site