Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1609991

in_irq_or_nmi()

From Matthew Wilcox <willy@infradead.org>
Newsgroups linux.kernel
Subject in_irq_or_nmi()
Date 2017-03-27 19:00 +0200
Message-ID <tpG9Q-2Hb-11@gated-at.bofh.it> (permalink)
References (5 earlier) <tpG9Q-2Hb-23@gated-at.bofh.it> <tpG9Q-2Hb-25@gated-at.bofh.it> <tpG9Q-2Hb-27@gated-at.bofh.it> <tpG9Q-2Hb-29@gated-at.bofh.it> <tpG9Q-2Hb-31@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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)))
 

I think there are some genuine questions to be asked about the other
users of in_irq() whether they really want to use in_irq_or_nmi().
There's fewer than a hundred of them, so somebody sufficiently motivated
could take a look in a few days.

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

in_irq_or_nmi() Matthew Wilcox <willy@infradead.org> - 2017-03-27 19:00 +0200
  Re: in_irq_or_nmi() Peter Zijlstra <peterz@infradead.org> - 2017-03-29 10:20 +0200
    Re: in_irq_or_nmi() Jesper Dangaard Brouer <brouer@redhat.com> - 2017-03-29 11:10 +0200
      Re: in_irq_or_nmi() Peter Zijlstra <peterz@infradead.org> - 2017-03-29 11:30 +0200
        Re: in_irq_or_nmi() Matthew Wilcox <willy@infradead.org> - 2017-03-29 20:20 +0200
          Re: in_irq_or_nmi() Jesper Dangaard Brouer <brouer@redhat.com> - 2017-03-29 21:20 +0200
            Re: in_irq_or_nmi() and RFC patch Jesper Dangaard Brouer <brouer@redhat.com> - 2017-03-29 21:50 +0200
              Re: in_irq_or_nmi() and RFC patch Peter Zijlstra <peterz@infradead.org> - 2017-03-30 09:00 +0200
                Re: in_irq_or_nmi() and RFC patch Jesper Dangaard Brouer <brouer@redhat.com> - 2017-03-30 09:20 +0200
                Re: in_irq_or_nmi() and RFC patch Peter Zijlstra <peterz@infradead.org> - 2017-03-30 09:40 +0200
                Re: in_irq_or_nmi() and RFC patch Jesper Dangaard Brouer <brouer@redhat.com> - 2017-03-30 11:50 +0200
              Re: in_irq_or_nmi() and RFC patch Mel Gorman <mgorman@techsingularity.net> - 2017-03-30 15:10 +0200
                Re: in_irq_or_nmi() and RFC patch Jesper Dangaard Brouer <brouer@redhat.com> - 2017-03-30 17:10 +0200
                Re: in_irq_or_nmi() and RFC patch Mel Gorman <mgorman@techsingularity.net> - 2017-04-03 14:10 +0200
                Re: in_irq_or_nmi() and RFC patch Mel Gorman <mgorman@techsingularity.net> - 2017-04-05 11:00 +0200

csiph-web