lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 24 Jan 2018 12:51:31 +0100
From:   Jiri Olsa <jolsa@...nel.org>
To:     Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Ingo Molnar <mingo@...nel.org>
Cc:     lkml <linux-kernel@...r.kernel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        David Ahern <dsahern@...il.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Andy Lutomirski <luto@...capital.net>,
        Arnaldo Carvalho de Melo <acme@...nel.org>
Subject: [PATCH 09/21] perf: Export running sample length values through debugfs

Exporting running_sample_length value through the debugfs,
via per cpu files:
  /sys/kernel/debug/irq/cpuX/sample_length

and reset file to zero it:
  /sys/kernel/debug/irq/reset

to allow some basic meassurements of the NMI time length.

Link: http://lkml.kernel.org/n/tip-uodlhfk3zc55fyajtlczr5wd@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
 kernel/events/core.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 4676fbf681c7..582913b7aba9 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -51,6 +51,7 @@
 #include <linux/proc_ns.h>
 #include <linux/mount.h>
 #include <linux/task_work.h>
+#include <linux/debugfs.h>
 
 #include "internal.h"
 
@@ -554,6 +555,72 @@ void perf_sample_event_took(u64 sample_len_ns)
 	}
 }
 
+static int get_sample_length(void *data, u64 *val)
+{
+	unsigned long cpu = (unsigned long) data;
+
+	*val = per_cpu(running_sample_length, cpu);
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(sample_length_fops, get_sample_length, NULL, "%llu\n");
+
+
+static int reset_sample_length(void *data, u64 val)
+{
+	int cpu;
+
+	for_each_possible_cpu(cpu) {
+		per_cpu(running_sample_length, cpu) = val;
+	}
+
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(reset_fops, NULL, reset_sample_length, "%llu\n");
+
+static __init int init_perf_debugfs(void)
+{
+	struct dentry *root, *irq, *icpu, *file;
+	int cpu, ret = 0;
+
+	root = debugfs_create_dir("perf", NULL);
+	if (!root)
+		return -1;
+
+	irq = debugfs_create_dir("irq", root);
+	if (!irq)
+		return -1;
+
+	for_each_possible_cpu(cpu) {
+		char buf[50];
+
+		snprintf(buf, sizeof(buf), "cpu%d", cpu);
+
+		icpu = debugfs_create_dir(buf, irq);
+		if (!icpu)
+			return -1;
+
+		file = debugfs_create_file("sample_length", 0444, icpu,
+					   (void *)(unsigned long) cpu,
+					   &sample_length_fops);
+		if (!file) {
+			ret = -1;
+			break;
+		}
+	}
+
+	if (!ret) {
+		file = debugfs_create_file("reset", S_IWUSR, irq, NULL, &reset_fops);
+		if (!file)
+			ret = -1;
+	}
+
+	return ret;
+}
+
+late_initcall(init_perf_debugfs);
+
 static atomic64_t perf_event_id;
 
 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
-- 
2.13.6

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ