lkml.org 
[lkml]   [2020]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 4/6] perf: Optimize get_recursion_context()
    On Fri, Oct 30, 2020 at 04:22:48PM -0400, Steven Rostedt wrote:
    > As this is something that ftrace recursion also does, perhaps we should
    > move this into interrupt.h so that anyone that needs a counter can get
    > it quickly, and not keep re-implementing it.

    Works for me, however:

    > /*
    > * Quickly find what context you are in.
    > * 0 - normal
    > * 1 - softirq
    > * 2 - hard interrupt
    > * 3 - NMI
    > */
    > static inline int irq_context()
    > {
    > unsigned int pc = preempt_count();
    > int rctx = 0;

    unsigned

    >
    > if (pc & (NMI_MASK))
    > rctx++;
    > if (pc & (NMI_MASK | HARDIRQ_MASK))
    > rctx++;
    > if (pc & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET))
    > rctx++;
    >
    > return rctx;
    > }

    otherwise you'll get an extra instruction to sign extend it, which is
    daft (yes, i've been staring at GCC output far too much).

    Also, gcc-9 does worse (like 1 byte iirc) with:

    rctx += !!(pc & (NMI_MASK));
    rctx += !!(pc & (NMI_MASK | HARDIRQ_MASK));
    rctx += !!(pc & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET));

    but gcc-10 doesn't seem to care.

    \
     
     \ /
      Last update: 2020-10-31 00:03    [W:2.604 / U:0.732 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site