From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422703AbcHEOwN (ORCPT ); Fri, 5 Aug 2016 10:52:13 -0400 Received: from smtprelay0049.hostedemail.com ([216.40.44.49]:37295 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1422677AbcHEOwM convert rfc822-to-8bit (ORCPT ); Fri, 5 Aug 2016 10:52:12 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::::::,RULES_HIT:41:152:355:379:541:599:800:960:981:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1513:1515:1516:1518:1521:1534:1542:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:3138:3139:3140:3141:3142:3354:3622:3743:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:5007:6261:7875:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12296:12438:12517:12519:12555:12663:12740:14096:14097:14181:14659:14721:21080:21433:21451:30012:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: wrist97_6a19aec555328 X-Filterd-Recvd-Size: 3655 Date: Fri, 5 Aug 2016 10:52:07 -0400 From: Steven Rostedt To: Sebastian Andrzej Siewior Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Ingo Molnar , Andrew Morton , Clark Williams , Thomas Gleixner , Jon Masters , Daniel Wagner , Carsten Emde Subject: Re: [RFC][PATCH 4/3] tracing: Add NMI tracing in hwlat detector Message-ID: <20160805105207.16e26a41@gandalf.local.home> In-Reply-To: <20160805143555.GB21312@linutronix.de> References: <20160804145708.158968389@goodmis.org> <20160804125618.6db9b5b3@gandalf.local.home> <20160804131645.1ba3244a@gandalf.local.home> <20160805143555.GB21312@linutronix.de> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 5 Aug 2016 16:35:55 +0200 Sebastian Andrzej Siewior wrote: > * Steven Rostedt | 2016-08-04 13:16:45 [-0400]: > > >diff --git a/include/linux/ftrace_irq.h b/include/linux/ftrace_irq.h > >index dca7bf8cffe2..4ec2c9b205f2 100644 > >--- a/include/linux/ftrace_irq.h > >+++ b/include/linux/ftrace_irq.h > >@@ -3,11 +3,34 @@ > … > >+static inline void ftrace_nmi_enter(void) > >+{ > >+#ifdef CONFIG_HWLAT_TRACER > >+ if (trace_hwlat_callback_enabled) > >+ trace_hwlat_callback(true); > > so we take a tracepoint while we enter an nmi It's not technically a tracepoint. I'm not sure tracepoints (jumplabels) may be located this early in the NMI handler. This is before some of the magic of having NMIs dealing with page faults and break points. > > >--- a/kernel/trace/trace_hwlat.c > >+++ b/kernel/trace/trace_hwlat.c > >@@ -64,6 +64,15 @@ static struct dentry *hwlat_sample_window; /* sample window us */ > > /* Save the previous tracing_thresh value */ > > static unsigned long save_tracing_thresh; > > > >+/* NMI timestamp counters */ > >+static u64 nmi_ts_start; > >+static u64 nmi_total_ts; > >+static int nmi_count; > >+static int nmi_cpu; > > and this is always limited to one CPU at a time? Yes. Hence the "nmi_cpu". > > … > >@@ -125,6 +138,19 @@ static void trace_hwlat_sample(struct hwlat_sample *sample) > > #define init_time(a, b) (a = b) > > #define time_u64(a) a > > > >+void trace_hwlat_callback(bool enter) > >+{ > >+ if (smp_processor_id() != nmi_cpu) > >+ return; > >+ > >+ if (enter) > >+ nmi_ts_start = time_get(); > > but more interestingly: trace_clock_local() -> sched_clock() > and of kernel/time/sched_clock.c we do raw_read_seqcount(&cd.seq) which > means we are busted if the NMI triggers during update_clock_read_data(). Hmm, interesting. Because this is true for general tracing from an NMI. /me looks at code. Ah, this is when we have GENERIC_SCHED_CLOCK, which would break tracing if any arch that has this also has NMIs. Probably need to look at arm64. For x86, it has its own NMI safe sched_clock. I could make this "NMI" code depend on: #ifndef CONFIG_GENERIC_SCHED_CLOCK -- Steve > > >+ else { > >+ nmi_total_ts = time_get() - nmi_ts_start; > >+ nmi_count++; > >+ } > >+} > > Sebastian