···185185};186186187187static int ftrace_filtered;188188-static int tracing_on;189188190189static LIST_HEAD(ftrace_new_addrs);191190···505506{506507 int *command = data;507508508508- if (*command & FTRACE_ENABLE_CALLS) {509509+ if (*command & FTRACE_ENABLE_CALLS)509510 ftrace_replace_code(1);510510- tracing_on = 1;511511- } else if (*command & FTRACE_DISABLE_CALLS) {511511+ else if (*command & FTRACE_DISABLE_CALLS)512512 ftrace_replace_code(0);513513- tracing_on = 0;514514- }515513516514 if (*command & FTRACE_UPDATE_TRACE_FUNC)517515 ftrace_update_ftrace_func(ftrace_trace_function);
+101
kernel/trace/ring_buffer.c
···1616#include <linux/list.h>1717#include <linux/fs.h>18181919+#include "trace.h"2020+2121+/* Global flag to disable all recording to ring buffers */2222+static int ring_buffers_off __read_mostly;2323+2424+/**2525+ * tracing_on - enable all tracing buffers2626+ *2727+ * This function enables all tracing buffers that may have been2828+ * disabled with tracing_off.2929+ */3030+void tracing_on(void)3131+{3232+ ring_buffers_off = 0;3333+}3434+3535+/**3636+ * tracing_off - turn off all tracing buffers3737+ *3838+ * This function stops all tracing buffers from recording data.3939+ * It does not disable any overhead the tracers themselves may4040+ * be causing. This function simply causes all recording to4141+ * the ring buffers to fail.4242+ */4343+void tracing_off(void)4444+{4545+ ring_buffers_off = 1;4646+}4747+1948/* Up this if you want to test the TIME_EXTENTS and normalization */2049#define DEBUG_SHIFT 02150···11621133 struct ring_buffer_event *event;11631134 int cpu, resched;1164113511361136+ if (ring_buffers_off)11371137+ return NULL;11381138+11651139 if (atomic_read(&buffer->record_disabled))11661140 return NULL;11671141···12801248 void *body;12811249 int ret = -EBUSY;12821250 int cpu, resched;12511251+12521252+ if (ring_buffers_off)12531253+ return -EBUSY;1283125412841255 if (atomic_read(&buffer->record_disabled))12851256 return -EBUSY;···21052070 return 0;21062071}2107207220732073+static ssize_t20742074+rb_simple_read(struct file *filp, char __user *ubuf,20752075+ size_t cnt, loff_t *ppos)20762076+{20772077+ int *p = filp->private_data;20782078+ char buf[64];20792079+ int r;20802080+20812081+ /* !ring_buffers_off == tracing_on */20822082+ r = sprintf(buf, "%d\n", !*p);20832083+20842084+ return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);20852085+}20862086+20872087+static ssize_t20882088+rb_simple_write(struct file *filp, const char __user *ubuf,20892089+ size_t cnt, loff_t *ppos)20902090+{20912091+ int *p = filp->private_data;20922092+ char buf[64];20932093+ long val;20942094+ int ret;20952095+20962096+ if (cnt >= sizeof(buf))20972097+ return -EINVAL;20982098+20992099+ if (copy_from_user(&buf, ubuf, cnt))21002100+ return -EFAULT;21012101+21022102+ buf[cnt] = 0;21032103+21042104+ ret = strict_strtoul(buf, 10, &val);21052105+ if (ret < 0)21062106+ return ret;21072107+21082108+ /* !ring_buffers_off == tracing_on */21092109+ *p = !val;21102110+21112111+ (*ppos)++;21122112+21132113+ return cnt;21142114+}21152115+21162116+static struct file_operations rb_simple_fops = {21172117+ .open = tracing_open_generic,21182118+ .read = rb_simple_read,21192119+ .write = rb_simple_write,21202120+};21212121+21222122+21232123+static __init int rb_init_debugfs(void)21242124+{21252125+ struct dentry *d_tracer;21262126+ struct dentry *entry;21272127+21282128+ d_tracer = tracing_init_dentry();21292129+21302130+ entry = debugfs_create_file("tracing_on", 0644, d_tracer,21312131+ &ring_buffers_off, &rb_simple_fops);21322132+ if (!entry)21332133+ pr_warning("Could not create debugfs 'tracing_on' entry\n");21342134+21352135+ return 0;21362136+}21372137+21382138+fs_initcall(rb_init_debugfs);