Received: by 10.223.185.116 with SMTP id b49csp1480634wrg; Fri, 16 Feb 2018 21:52:14 -0800 (PST) X-Google-Smtp-Source: AH8x224EPlcKSdtH9VfoENDobrPHJavw1l/t3Q/EOP/0qtX9kr/NwraxjMYqQTbIw+xp27nLrwnq X-Received: by 10.98.34.139 with SMTP id p11mr8376209pfj.119.1518846734324; Fri, 16 Feb 2018 21:52:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518846734; cv=none; d=google.com; s=arc-20160816; b=0lvjMK2+vn90zyN4j9JvhtjL9RxVaAYZcC4P0jIhoBYMwgkgShDTcTsFj9ON56ZJcR W3lXFpuI8oTmwzgbiBm+ilw8Jmrs59ygXlftWTu2+JZxbiH/q3zn46FlAKmL7+L1yZQM RnBBFHS2KfqzzabBoO4LrGNAqaAwN//V+AZXft/UJvSJ4V+ttiDOv/DxuLN54JqxrLaq MwKtpcVro0McjwI3BJF27q8saRk5MmBEi7c9z/OAfhYhlpzEFv8u9pFTISPvCiNbKB5U R2C+nDqsr074rlePT1cK5cZdimWbCaUBT3tPBY/yCGdU3dfFn3S+82OYXhYxf2orKda5 96Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=qWQdA/VqQ0mJiZKHzGp+huLOGy1BaPgPf3Y5bTJih+E=; b=YK/c08pnljviRbJLS9P5tTc30YZ0D/ktv7Mt8c0ORmRGi/xMMOHctIFXd/3Ugq7/bH Y1TVdf74vxWcZxr16ZdE2XwqgdEQZGiyTzv1/Aj0yX+xk+lZUZAExSv5PXvU0+M6IiG3 r+OMY6eGdQtmcAhbIYXWw4sjyHziCJfYazzIg7IRfAn/ig7EfxXQq7+JdnTk0C9iB+BD j08k+exVGFfseFCegAbmHRScvzP1vb3G0l/z/WjrAiolZsdHz1nUVX7ITI+4QqVSCLKc d5fYD+oK9qId+Q2uh7PpJxyFoI0SPhsFduuDNXjrUzEpnN9peJ7RW998CsqWlCAP65dh YcCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 186si4234689pfe.411.2018.02.16.21.51.33; Fri, 16 Feb 2018 21:52:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751325AbeBQFuO (ORCPT + 99 others); Sat, 17 Feb 2018 00:50:14 -0500 Received: from mga02.intel.com ([134.134.136.20]:59982 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751132AbeBQFtZ (ORCPT ); Sat, 17 Feb 2018 00:49:25 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Feb 2018 21:49:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,523,1511856000"; d="scan'208";a="20863408" Received: from gvt-dell.bj.intel.com (HELO gvt-dell-host.bj.intel.com) ([10.238.154.59]) by fmsmga002.fm.intel.com with ESMTP; 16 Feb 2018 21:49:23 -0800 From: changbin.du@intel.com To: corbet@lwn.net, rostedt@goodmis.org Cc: mingo@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Changbin Du Subject: [PATCH 14/17] trace doc: convert trace/mmiotrace.txt to rst format Date: Sat, 17 Feb 2018 13:39:47 +0800 Message-Id: <1518845990-20733-15-git-send-email-changbin.du@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518845990-20733-1-git-send-email-changbin.du@intel.com> References: <1518845990-20733-1-git-send-email-changbin.du@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Changbin Du This converts the plain text documentation to reStructuredText format and add it into Sphinx TOC tree. No essential content change. Cc: Steven Rostedt Signed-off-by: Changbin Du --- Documentation/trace/index.rst | 1 + .../trace/{mmiotrace.txt => mmiotrace.rst} | 86 +++++++++++++--------- 2 files changed, 54 insertions(+), 33 deletions(-) rename Documentation/trace/{mmiotrace.txt => mmiotrace.rst} (78%) diff --git a/Documentation/trace/index.rst b/Documentation/trace/index.rst index 307468d..4b3d690 100644 --- a/Documentation/trace/index.rst +++ b/Documentation/trace/index.rst @@ -17,3 +17,4 @@ Linux Tracing Technologies events-power events-nmi events-msr + mmiotrace diff --git a/Documentation/trace/mmiotrace.txt b/Documentation/trace/mmiotrace.rst similarity index 78% rename from Documentation/trace/mmiotrace.txt rename to Documentation/trace/mmiotrace.rst index 664e738..5116e8c 100644 --- a/Documentation/trace/mmiotrace.txt +++ b/Documentation/trace/mmiotrace.rst @@ -1,4 +1,6 @@ - In-kernel memory-mapped I/O tracing +=================================== +In-kernel memory-mapped I/O tracing +=================================== Home page and links to optional user space tools: @@ -31,30 +33,35 @@ is no way to automatically detect if you are losing events due to CPUs racing. Usage Quick Reference --------------------- +:: -$ mount -t debugfs debugfs /sys/kernel/debug -$ echo mmiotrace > /sys/kernel/debug/tracing/current_tracer -$ cat /sys/kernel/debug/tracing/trace_pipe > mydump.txt & -Start X or whatever. -$ echo "X is up" > /sys/kernel/debug/tracing/trace_marker -$ echo nop > /sys/kernel/debug/tracing/current_tracer -Check for lost events. + $ mount -t debugfs debugfs /sys/kernel/debug + $ echo mmiotrace > /sys/kernel/debug/tracing/current_tracer + $ cat /sys/kernel/debug/tracing/trace_pipe > mydump.txt & + Start X or whatever. + $ echo "X is up" > /sys/kernel/debug/tracing/trace_marker + $ echo nop > /sys/kernel/debug/tracing/current_tracer + Check for lost events. Usage ----- Make sure debugfs is mounted to /sys/kernel/debug. -If not (requires root privileges): -$ mount -t debugfs debugfs /sys/kernel/debug +If not (requires root privileges):: + + $ mount -t debugfs debugfs /sys/kernel/debug Check that the driver you are about to trace is not loaded. -Activate mmiotrace (requires root privileges): -$ echo mmiotrace > /sys/kernel/debug/tracing/current_tracer +Activate mmiotrace (requires root privileges):: + + $ echo mmiotrace > /sys/kernel/debug/tracing/current_tracer + +Start storing the trace:: + + $ cat /sys/kernel/debug/tracing/trace_pipe > mydump.txt & -Start storing the trace: -$ cat /sys/kernel/debug/tracing/trace_pipe > mydump.txt & The 'cat' process should stay running (sleeping) in the background. Load the driver you want to trace and use it. Mmiotrace will only catch MMIO @@ -66,30 +73,42 @@ This makes it easier to see which part of the (huge) trace corresponds to which action. It is recommended to place descriptive markers about what you do. -Shut down mmiotrace (requires root privileges): -$ echo nop > /sys/kernel/debug/tracing/current_tracer +Shut down mmiotrace (requires root privileges):: + + $ echo nop > /sys/kernel/debug/tracing/current_tracer + The 'cat' process exits. If it does not, kill it by issuing 'fg' command and pressing ctrl+c. -Check that mmiotrace did not lose events due to a buffer filling up. Either -$ grep -i lost mydump.txt -which tells you exactly how many events were lost, or use -$ dmesg +Check that mmiotrace did not lose events due to a buffer filling up. Either:: + + $ grep -i lost mydump.txt + +which tells you exactly how many events were lost, or use:: + + $ dmesg + to view your kernel log and look for "mmiotrace has lost events" warning. If events were lost, the trace is incomplete. You should enlarge the buffers and try again. Buffers are enlarged by first seeing how large the current buffers -are: -$ cat /sys/kernel/debug/tracing/buffer_size_kb +are:: + + $ cat /sys/kernel/debug/tracing/buffer_size_kb + gives you a number. Approximately double this number and write it back, for -instance: -$ echo 128000 > /sys/kernel/debug/tracing/buffer_size_kb +instance:: + + $ echo 128000 > /sys/kernel/debug/tracing/buffer_size_kb + Then start again from the top. If you are doing a trace for a driver project, e.g. Nouveau, you should also -do the following before sending your results: -$ lspci -vvv > lspci.txt -$ dmesg > dmesg.txt -$ tar zcf pciid-nick-mmiotrace.tar.gz mydump.txt lspci.txt dmesg.txt +do the following before sending your results:: + + $ lspci -vvv > lspci.txt + $ dmesg > dmesg.txt + $ tar zcf pciid-nick-mmiotrace.tar.gz mydump.txt lspci.txt dmesg.txt + and then send the .tar.gz file. The trace compresses considerably. Replace "pciid" and "nick" with the PCI ID or model name of your piece of hardware under investigation and your nickname. @@ -148,17 +167,18 @@ zero if it is not recorded. PID is always zero as tracing MMIO accesses originating in user space memory is not yet supported. For instance, the following awk filter will pass all 32-bit writes that target -physical addresses in the range [0xfb73ce40, 0xfb800000[ +physical addresses in the range [0xfb73ce40, 0xfb800000] +:: -$ awk '/W 4 / { adr=strtonum($5); if (adr >= 0xfb73ce40 && -adr < 0xfb800000) print; }' + $ awk '/W 4 / { adr=strtonum($5); if (adr >= 0xfb73ce40 && + adr < 0xfb800000) print; }' Tools for Developers -------------------- The user space tools include utilities for: -- replacing numeric addresses and values with hardware register names -- replaying MMIO logs, i.e., re-executing the recorded writes + - replacing numeric addresses and values with hardware register names + - replaying MMIO logs, i.e., re-executing the recorded writes -- 2.7.4