···185};186187static int ftrace_filtered;188-static int tracing_on;189190static LIST_HEAD(ftrace_new_addrs);191···505{506 int *command = data;507508- if (*command & FTRACE_ENABLE_CALLS) {509 ftrace_replace_code(1);510- tracing_on = 1;511- } else if (*command & FTRACE_DISABLE_CALLS) {512 ftrace_replace_code(0);513- tracing_on = 0;514- }515516 if (*command & FTRACE_UPDATE_TRACE_FUNC)517 ftrace_update_ftrace_func(ftrace_trace_function);
···185};186187static int ftrace_filtered;0188189static LIST_HEAD(ftrace_new_addrs);190···506{507 int *command = data;508509+ if (*command & FTRACE_ENABLE_CALLS)510 ftrace_replace_code(1);511+ else if (*command & FTRACE_DISABLE_CALLS)0512 ftrace_replace_code(0);00513514 if (*command & FTRACE_UPDATE_TRACE_FUNC)515 ftrace_update_ftrace_func(ftrace_trace_function);
+101
kernel/trace/ring_buffer.c
···16#include <linux/list.h>17#include <linux/fs.h>180000000000000000000000000000019/* Up this if you want to test the TIME_EXTENTS and normalization */20#define DEBUG_SHIFT 021···1162 struct ring_buffer_event *event;1163 int cpu, resched;11640001165 if (atomic_read(&buffer->record_disabled))1166 return NULL;1167···1280 void *body;1281 int ret = -EBUSY;1282 int cpu, resched;00012831284 if (atomic_read(&buffer->record_disabled))1285 return -EBUSY;···2105 return 0;2106}2107000000000000000000000000000000000000000000000000000000000000000000
···16#include <linux/list.h>17#include <linux/fs.h>1819+#include "trace.h"20+21+/* Global flag to disable all recording to ring buffers */22+static int ring_buffers_off __read_mostly;23+24+/**25+ * tracing_on - enable all tracing buffers26+ *27+ * This function enables all tracing buffers that may have been28+ * disabled with tracing_off.29+ */30+void tracing_on(void)31+{32+ ring_buffers_off = 0;33+}34+35+/**36+ * tracing_off - turn off all tracing buffers37+ *38+ * This function stops all tracing buffers from recording data.39+ * It does not disable any overhead the tracers themselves may40+ * be causing. This function simply causes all recording to41+ * the ring buffers to fail.42+ */43+void tracing_off(void)44+{45+ ring_buffers_off = 1;46+}47+48/* Up this if you want to test the TIME_EXTENTS and normalization */49#define DEBUG_SHIFT 050···1133 struct ring_buffer_event *event;1134 int cpu, resched;11351136+ if (ring_buffers_off)1137+ return NULL;1138+1139 if (atomic_read(&buffer->record_disabled))1140 return NULL;1141···1248 void *body;1249 int ret = -EBUSY;1250 int cpu, resched;1251+1252+ if (ring_buffers_off)1253+ return -EBUSY;12541255 if (atomic_read(&buffer->record_disabled))1256 return -EBUSY;···2070 return 0;2071}20722073+static ssize_t2074+rb_simple_read(struct file *filp, char __user *ubuf,2075+ size_t cnt, loff_t *ppos)2076+{2077+ int *p = filp->private_data;2078+ char buf[64];2079+ int r;2080+2081+ /* !ring_buffers_off == tracing_on */2082+ r = sprintf(buf, "%d\n", !*p);2083+2084+ return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);2085+}2086+2087+static ssize_t2088+rb_simple_write(struct file *filp, const char __user *ubuf,2089+ size_t cnt, loff_t *ppos)2090+{2091+ int *p = filp->private_data;2092+ char buf[64];2093+ long val;2094+ int ret;2095+2096+ if (cnt >= sizeof(buf))2097+ return -EINVAL;2098+2099+ if (copy_from_user(&buf, ubuf, cnt))2100+ return -EFAULT;2101+2102+ buf[cnt] = 0;2103+2104+ ret = strict_strtoul(buf, 10, &val);2105+ if (ret < 0)2106+ return ret;2107+2108+ /* !ring_buffers_off == tracing_on */2109+ *p = !val;2110+2111+ (*ppos)++;2112+2113+ return cnt;2114+}2115+2116+static struct file_operations rb_simple_fops = {2117+ .open = tracing_open_generic,2118+ .read = rb_simple_read,2119+ .write = rb_simple_write,2120+};2121+2122+2123+static __init int rb_init_debugfs(void)2124+{2125+ struct dentry *d_tracer;2126+ struct dentry *entry;2127+2128+ d_tracer = tracing_init_dentry();2129+2130+ entry = debugfs_create_file("tracing_on", 0644, d_tracer,2131+ &ring_buffers_off, &rb_simple_fops);2132+ if (!entry)2133+ pr_warning("Could not create debugfs 'tracing_on' entry\n");2134+2135+ return 0;2136+}2137+2138+fs_initcall(rb_init_debugfs);