Re: [PATCH] trace: adjust code layout in get_recursion_context
From: Peter Zijlstra
Date: Tue Aug 22 2017 - 11:14:21 EST
On Tue, Aug 22, 2017 at 04:40:24PM +0200, Jesper Dangaard Brouer wrote:
> In an XDP redirect applications using tracepoint xdp:xdp_redirect to
> diagnose TX overrun, I noticed perf_swevent_get_recursion_context()
> was consuming 2% CPU. This was reduced to 1.6% with this simple
> change.
It is also incorrect. What do you suppose it now returns when the NMI
hits a hard IRQ which hit during a Soft IRQ?
> @@ -208,12 +208,12 @@ static inline int get_recursion_context(int *recursion)
> {
> int rctx;
>
> + if (in_softirq())
> + rctx = 1;
> else if (in_irq())
> rctx = 2;
> + else if (in_nmi())
> + rctx = 3;
> else
> rctx = 0;
>
>