aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ras
diff options
context:
space:
mode:
authorChen, Gong <gong.chen@linux.intel.com>2014-06-11 17:02:20 -0400
committerTony Luck <tony.luck@intel.com>2014-06-25 14:22:03 -0400
commitd963cd95bea93b7db9390a71d1e2cabbb3b2c3ea (patch)
treeb6d25da65a161f6c38207a2f15515c3b795d3396 /drivers/ras
parent3760cd20402d4c131e1994c968ecb055fa0f74bc (diff)
RAS, debugfs: Add debugfs interface for RAS subsystem
Implement a new debugfs interface for RAS susbsystem. A file named daemon_active is added there accordingly. This file is used to track if user space daemon accesses perf/trace interface or not. One can track which daemon opens it via "lsof /path/to/debugfs/ras/daemon_active". Signed-off-by: Chen, Gong <gong.chen@linux.intel.com> Link: http://lkml.kernel.org/r/1402475691-30045-5-git-send-email-gong.chen@linux.intel.com Signed-off-by: Borislav Petkov <bp@suse.de> Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'drivers/ras')
-rw-r--r--drivers/ras/Makefile2
-rw-r--r--drivers/ras/debugfs.c56
-rw-r--r--drivers/ras/ras.c14
3 files changed, 71 insertions, 1 deletions
diff --git a/drivers/ras/Makefile b/drivers/ras/Makefile
index 223e806fa5bf..d7f73341ced3 100644
--- a/drivers/ras/Makefile
+++ b/drivers/ras/Makefile
@@ -1 +1 @@
obj-$(CONFIG_RAS) += ras.o obj-$(CONFIG_RAS) += ras.o debugfs.o
diff --git a/drivers/ras/debugfs.c b/drivers/ras/debugfs.c
new file mode 100644
index 000000000000..0322acf67ea5
--- /dev/null
+++ b/drivers/ras/debugfs.c
@@ -0,0 +1,56 @@
1#include <linux/debugfs.h>
2
3static struct dentry *ras_debugfs_dir;
4
5static atomic_t trace_count = ATOMIC_INIT(0);
6
7int ras_userspace_consumers(void)
8{
9 return atomic_read(&trace_count);
10}
11EXPORT_SYMBOL_GPL(ras_userspace_consumers);
12
13static int trace_show(struct seq_file *m, void *v)
14{
15 return atomic_read(&trace_count);
16}
17
18static int trace_open(struct inode *inode, struct file *file)
19{
20 atomic_inc(&trace_count);
21 return single_open(file, trace_show, NULL);
22}
23
24static int trace_release(struct inode *inode, struct file *file)
25{
26 atomic_dec(&trace_count);
27 return single_release(inode, file);
28}
29
30static const struct file_operations trace_fops = {
31 .open = trace_open,
32 .read = seq_read,
33 .llseek = seq_lseek,
34 .release = trace_release,
35};
36
37int __init ras_add_daemon_trace(void)
38{
39 struct dentry *fentry;
40
41 if (!ras_debugfs_dir)
42 return -ENOENT;
43
44 fentry = debugfs_create_file("daemon_active", S_IRUSR, ras_debugfs_dir,
45 NULL, &trace_fops);
46 if (!fentry)
47 return -ENODEV;
48
49 return 0;
50
51}
52
53void __init ras_debugfs_init(void)
54{
55 ras_debugfs_dir = debugfs_create_dir("ras", NULL);
56}
diff --git a/drivers/ras/ras.c b/drivers/ras/ras.c
index b0c6ed1d8e77..4cac43a1e25c 100644
--- a/drivers/ras/ras.c
+++ b/drivers/ras/ras.c
@@ -5,8 +5,22 @@
5 * Chen, Gong <gong.chen@linux.intel.com> 5 * Chen, Gong <gong.chen@linux.intel.com>
6 */ 6 */
7 7
8#include <linux/init.h>
9#include <linux/ras.h>
10
8#define CREATE_TRACE_POINTS 11#define CREATE_TRACE_POINTS
9#define TRACE_INCLUDE_PATH ../../include/ras 12#define TRACE_INCLUDE_PATH ../../include/ras
10#include <ras/ras_event.h> 13#include <ras/ras_event.h>
11 14
15static int __init ras_init(void)
16{
17 int rc = 0;
18
19 ras_debugfs_init();
20 rc = ras_add_daemon_trace();
21
22 return rc;
23}
24subsys_initcall(ras_init);
25
12EXPORT_TRACEPOINT_SYMBOL_GPL(mc_event); 26EXPORT_TRACEPOINT_SYMBOL_GPL(mc_event);