From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753592AbdHWIM0 (ORCPT ); Wed, 23 Aug 2017 04:12:26 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36945 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753445AbdHWIMY (ORCPT ); Wed, 23 Aug 2017 04:12:24 -0400 Date: Wed, 23 Aug 2017 10:12:19 +0200 From: Ingo Molnar To: Peter Zijlstra Cc: Jesper Dangaard Brouer , Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, Jiri Olsa Subject: Re: [PATCH] trace: adjust code layout in get_recursion_context Message-ID: <20170823081219.27tdvloc3h35l5w7@gmail.com> References: <150341282404.1960.2812166781523027528.stgit@firesoul> <20170822151410.xroe4mrkk32tlrxv@hirez.programming.kicks-ass.net> <20170822152025.wl664322yuu6esq4@hirez.programming.kicks-ass.net> <20170822190039.519c25bc@redhat.com> <20170822175512.GJ32112@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170822175512.GJ32112@worktop.programming.kicks-ass.net> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Peter Zijlstra wrote: > diff --git a/kernel/events/internal.h b/kernel/events/internal.h > index 486fd78eb8d5..981e4163e16c 100644 > --- a/kernel/events/internal.h > +++ b/kernel/events/internal.h > @@ -206,16 +206,15 @@ static inline unsigned long perf_aux_size(struct ring_buffer *rb) > > static inline int get_recursion_context(int *recursion) > { > - int rctx; > - > - if (in_nmi()) > - rctx = 3; > - else if (in_irq()) > - rctx = 2; > - else if (in_softirq()) > - rctx = 1; > - else > - rctx = 0; > + unsigned int pc = preempt_count(); > + int rctx = 0; > + > + if (pc & SOFTIRQ_OFFSET) > + rctx++; > + if (pc & HARDIRQ_MASK) > + rctx++; > + if (pc & NMI_MASK) > + rctx++; Just a nit: if this ever gets beyond the proof of concent stage please rename 'pc' to something like 'count', because 'pc' stands for so many other things (program counter, etc.) which makes it all look a bit weird ... Thanks, Ingo