Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2462662ybk; Sun, 17 May 2020 22:55:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8I8UIIUnguyoi8T1CVxW2Lc/iaAx2Y+yrIZY/beIsEXXahzi2oepUZfELQfjQ4zoB21zd X-Received: by 2002:a05:6402:1aca:: with SMTP id ba10mr7594265edb.100.1589781301516; Sun, 17 May 2020 22:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589781301; cv=none; d=google.com; s=arc-20160816; b=d0Qo6uOnelQTw/uHzrCXRpzHpjx9C0/T9wz+xq0decBp83H/yXkVTtt6uE/lhQSQvj aIIdfrtVyd1SYyLNafmnHgTkhcmvxeUkCcHRL7joAPGikt3rm+Bf9u5EMfGvwUeKUfjV 4bli0Tf7z2F2B2JrIgJTYs2r25/DEBdSB8VWizH6Kc2TsbASueUBdwgJL+bgXqv+dc7c 0kuDbiCUj9wTM+QxEfd+6TJrtnnk+zyODD7NLlqxl+iTpKTETBCLsg+gBOFv0B8advZc 03QZ/qhxiipcV3uMy3DhU+4s1zcD7rRvCup/8oYOQAMK0MRhki5OiU/RB3ghfI0sbNAJ 4L0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=tC0nNT6tSywsrPppLEAHGIZMgwhJqwwse0R00AfZEeU=; b=vd8hWRI3jTUzKc6JYYOKG5YKmgqbrjYNbvorZ37kaKEnzSBblL+1zZi+EElteOVHCZ Ytl8T4L35DWlTtHhn75m4dhCdYGTmljKYCucaDAX0dPEUOmFv/UXzxPo0kOwCNDAQwwM XAbiCWCGjlK/qHl+/mBeej9ONBi6+wZApA/yhrWcJ7Z+wv3WRfnGg/Qn+FNi2CBkMEvf PDUddchqeAsCm3JJ3l8DNnJadeCc0pcErGmiev7GfIG8HXIrx63YkA93FhhknMTLSMs8 k7smnaxonilkPyP9aeK8L3KP+Pqt0rd+SatKNACXzbo5XkD0Oggkof9iE+vJw5qQ55Nx CMDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OMZgNa7s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z97si4858336ede.412.2020.05.17.22.54.37; Sun, 17 May 2020 22:55:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OMZgNa7s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726417AbgERFvL (ORCPT + 99 others); Mon, 18 May 2020 01:51:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:53160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726040AbgERFvK (ORCPT ); Mon, 18 May 2020 01:51:10 -0400 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A8B4A20829 for ; Mon, 18 May 2020 05:51:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589781069; bh=dz1NLA05YEt3Wk/LMdrxBkIZ9j2HNwOH9sYub6ThKBM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OMZgNa7serQ3AlhQ0KLdX6Q8iUMPXb89N8zTspXY5UZVzChoffmff75OcdhqnvTPh /iuOT/Kqk4k7ef40PAqDLVuHZA2mJMNz7MGWPchUX+Z77nBjlkga82RuIBCpWx3J/v OHam1f+0Jkt9eCmaTPF0w6/Q7p9+w63OWi65mF0k= Received: by mail-wm1-f50.google.com with SMTP id z72so8814979wmc.2 for ; Sun, 17 May 2020 22:51:09 -0700 (PDT) X-Gm-Message-State: AOAM531eubBHPUuu5OB6yuvtFb81KUY48R/I7MwKV4tgcjEXZI4uzLCs Ze3BLV4QkylLV2duJ/dmQddHWco9iR+TPn3DtheyBQ== X-Received: by 2002:a05:600c:2299:: with SMTP id 25mr17514996wmf.138.1589781068047; Sun, 17 May 2020 22:51:08 -0700 (PDT) MIME-Version: 1.0 References: <20200515234547.710474468@linutronix.de> <20200515235124.783722942@linutronix.de> <87zha7c5h5.fsf@nanos.tec.linutronix.de> In-Reply-To: <87zha7c5h5.fsf@nanos.tec.linutronix.de> From: Andy Lutomirski Date: Sun, 17 May 2020 22:50:56 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [patch V6 04/37] x86: Make hardware latency tracing explicit To: Thomas Gleixner Cc: Andy Lutomirski , LKML , X86 ML , "Paul E. McKenney" , Alexandre Chartre , Frederic Weisbecker , Paolo Bonzini , Sean Christopherson , Masami Hiramatsu , Petr Mladek , Steven Rostedt , Joel Fernandes , Boris Ostrovsky , Juergen Gross , Brian Gerst , Mathieu Desnoyers , Josh Poimboeuf , Will Deacon , Tom Lendacky , Wei Liu , Michael Kelley , Jason Chen CJ , Zhao Yakui , "Peter Zijlstra (Intel)" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 17, 2020 at 1:48 AM Thomas Gleixner wrote: > > Andy Lutomirski writes: > > On Fri, May 15, 2020 at 5:10 PM Thomas Gleixner wrote: > >> > >> > >> The hardware latency tracer calls into trace_sched_clock and ends up in > >> various instrumentable functions which is problemeatic vs. the kprobe > >> handling especially the text poke machinery. It's invoked from > >> nmi_enter/exit(), i.e. non-instrumentable code. > >> > >> Use nmi_enter/exit_notrace() instead. These variants do not invoke the > >> hardware latency tracer which avoids chasing down complex callchains to > >> make them non-instrumentable. > >> > >> The real interesting measurement is the actual NMI handler. Add an explicit > >> invocation for the hardware latency tracer to it. > >> > >> #DB and #BP are uninteresting as they really should not be in use when > >> analzying hardware induced latencies. > >> > > > >> @@ -849,7 +851,7 @@ static void noinstr handle_debug(struct > >> static __always_inline void exc_debug_kernel(struct pt_regs *regs, > >> unsigned long dr6) > >> { > >> - nmi_enter(); > >> + nmi_enter_notrace(); > > > > Why can't exc_debug_kernel() handle instrumentation? We shouldn't > > recurse into #DB since we've already cleared DR7, right? > > It can later on. The point is that the trace stuff calls into the world > and some more before the entry handling is complete. > > Remember this is about ensuring that all the state is properly > established before any of this instrumentation muck can happen. > > DR7 handling is specific to #DB and done even before nmi_enter to > prevent recursion. So why is this change needed?