···28592859 to facilitate early boot debugging.28602860 See also Documentation/trace/events.txt2861286128622862+ trace_options=[option-list]28632863+ [FTRACE] Enable or disable tracer options at boot.28642864+ The option-list is a comma delimited list of options28652865+ that can be enabled or disabled just as if you were28662866+ to echo the option name into28672867+28682868+ /sys/kernel/debug/tracing/trace_options28692869+28702870+ For example, to enable stacktrace option (to dump the28712871+ stack trace of each event), add to the command line:28722872+28732873+ trace_options=stacktrace28742874+28752875+ See also Documentation/trace/ftrace.txt "trace options"28762876+ section.28772877+28622878 transparent_hugepage=28632879 [KNL]28642880 Format: [always|madvise|never]
+7-7
include/linux/ftrace_event.h
···127127void trace_current_buffer_unlock_commit(struct ring_buffer *buffer,128128 struct ring_buffer_event *event,129129 unsigned long flags, int pc);130130-void trace_nowake_buffer_unlock_commit(struct ring_buffer *buffer,131131- struct ring_buffer_event *event,132132- unsigned long flags, int pc);133133-void trace_nowake_buffer_unlock_commit_regs(struct ring_buffer *buffer,134134- struct ring_buffer_event *event,135135- unsigned long flags, int pc,136136- struct pt_regs *regs);130130+void trace_buffer_unlock_commit(struct ring_buffer *buffer,131131+ struct ring_buffer_event *event,132132+ unsigned long flags, int pc);133133+void trace_buffer_unlock_commit_regs(struct ring_buffer *buffer,134134+ struct ring_buffer_event *event,135135+ unsigned long flags, int pc,136136+ struct pt_regs *regs);137137void trace_current_buffer_discard_commit(struct ring_buffer *buffer,138138 struct ring_buffer_event *event);139139
···159159void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu);160160void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu);161161162162-unsigned long ring_buffer_oldest_event_ts(struct ring_buffer *buffer, int cpu);162162+u64 ring_buffer_oldest_event_ts(struct ring_buffer *buffer, int cpu);163163unsigned long ring_buffer_bytes_cpu(struct ring_buffer *buffer, int cpu);164164unsigned long ring_buffer_entries(struct ring_buffer *buffer);165165unsigned long ring_buffer_overruns(struct ring_buffer *buffer);166166unsigned long ring_buffer_entries_cpu(struct ring_buffer *buffer, int cpu);167167unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu);168168unsigned long ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu);169169+unsigned long ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu);169170170171u64 ring_buffer_time_stamp(struct ring_buffer *buffer, int cpu);171172void ring_buffer_normalize_time_stamp(struct ring_buffer *buffer,
+1-2
include/trace/ftrace.h
···545545 { assign; } \546546 \547547 if (!filter_current_check_discard(buffer, event_call, entry, event)) \548548- trace_nowake_buffer_unlock_commit(buffer, \549549- event, irq_flags, pc); \548548+ trace_buffer_unlock_commit(buffer, event, irq_flags, pc); \550549}551550/*552551 * The ftrace_test_probe is compiled out, it is only here as a build time check
···28682868{28692869 return register_ftrace_command(&ftrace_mod_cmd);28702870}28712871-device_initcall(ftrace_mod_cmd_init);28712871+core_initcall(ftrace_mod_cmd_init);2872287228732873static void function_trace_probe_call(unsigned long ip, unsigned long parent_ip,28742874 struct ftrace_ops *op, struct pt_regs *pt_regs)···40554055 ftrace_enabled = 1;40564056 return 0;40574057}40584058-device_initcall(ftrace_nodyn_init);40584058+core_initcall(ftrace_nodyn_init);4059405940604060static inline int ftrace_init_dyn_debugfs(struct dentry *d_tracer) { return 0; }40614061static inline void ftrace_startup_enable(int command) { }···43814381 if (strlen(tmp) == 0)43824382 return 1;4383438343844384- ret = strict_strtol(tmp, 10, &val);43844384+ ret = kstrtol(tmp, 10, &val);43854385 if (ret < 0)43864386 return ret;43874387
+40-11
kernel/trace/ring_buffer.c
···460460 unsigned long lost_events;461461 unsigned long last_overrun;462462 local_t entries_bytes;463463- local_t commit_overrun;464464- local_t overrun;465463 local_t entries;464464+ local_t overrun;465465+ local_t commit_overrun;466466+ local_t dropped_events;466467 local_t committing;467468 local_t commits;468469 unsigned long read;···18211820}1822182118231822/**18241824- * ring_buffer_update_event - update event type and data18231823+ * rb_update_event - update event type and data18251824 * @event: the even to update18261825 * @type: the type of event18271826 * @length: the size of the event field in the ring buffer···21562155 * If we are not in overwrite mode,21572156 * this is easy, just stop here.21582157 */21592159- if (!(buffer->flags & RB_FL_OVERWRITE))21582158+ if (!(buffer->flags & RB_FL_OVERWRITE)) {21592159+ local_inc(&cpu_buffer->dropped_events);21602160 goto out_reset;21612161+ }2161216221622163 ret = rb_handle_head_page(cpu_buffer,21632164 tail_page,···27232720 * and not the length of the event which would hold the header.27242721 */27252722int ring_buffer_write(struct ring_buffer *buffer,27262726- unsigned long length,27272727- void *data)27232723+ unsigned long length,27242724+ void *data)27282725{27292726 struct ring_buffer_per_cpu *cpu_buffer;27302727 struct ring_buffer_event *event;···29322929 * @buffer: The ring buffer29332930 * @cpu: The per CPU buffer to read from.29342931 */29352935-unsigned long ring_buffer_oldest_event_ts(struct ring_buffer *buffer, int cpu)29322932+u64 ring_buffer_oldest_event_ts(struct ring_buffer *buffer, int cpu)29362933{29372934 unsigned long flags;29382935 struct ring_buffer_per_cpu *cpu_buffer;29392936 struct buffer_page *bpage;29402940- unsigned long ret;29372937+ u64 ret;2941293829422939 if (!cpumask_test_cpu(cpu, buffer->cpumask))29432940 return 0;···29982995EXPORT_SYMBOL_GPL(ring_buffer_entries_cpu);2999299630002997/**30013001- * ring_buffer_overrun_cpu - get the number of overruns in a cpu_buffer29982998+ * ring_buffer_overrun_cpu - get the number of overruns caused by the ring29992999+ * buffer wrapping around (only if RB_FL_OVERWRITE is on).30023000 * @buffer: The ring buffer30033001 * @cpu: The per CPU buffer to get the number of overruns from30043002 */···30193015EXPORT_SYMBOL_GPL(ring_buffer_overrun_cpu);3020301630213017/**30223022- * ring_buffer_commit_overrun_cpu - get the number of overruns caused by commits30183018+ * ring_buffer_commit_overrun_cpu - get the number of overruns caused by30193019+ * commits failing due to the buffer wrapping around while there are uncommitted30203020+ * events, such as during an interrupt storm.30233021 * @buffer: The ring buffer30243022 * @cpu: The per CPU buffer to get the number of overruns from30253023 */···30403034 return ret;30413035}30423036EXPORT_SYMBOL_GPL(ring_buffer_commit_overrun_cpu);30373037+30383038+/**30393039+ * ring_buffer_dropped_events_cpu - get the number of dropped events caused by30403040+ * the ring buffer filling up (only if RB_FL_OVERWRITE is off).30413041+ * @buffer: The ring buffer30423042+ * @cpu: The per CPU buffer to get the number of overruns from30433043+ */30443044+unsigned long30453045+ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu)30463046+{30473047+ struct ring_buffer_per_cpu *cpu_buffer;30483048+ unsigned long ret;30493049+30503050+ if (!cpumask_test_cpu(cpu, buffer->cpumask))30513051+ return 0;30523052+30533053+ cpu_buffer = buffer->buffers[cpu];30543054+ ret = local_read(&cpu_buffer->dropped_events);30553055+30563056+ return ret;30573057+}30583058+EXPORT_SYMBOL_GPL(ring_buffer_dropped_events_cpu);3043305930443060/**30453061 * ring_buffer_entries - get the number of entries in a buffer···38923864 local_set(&cpu_buffer->reader_page->page->commit, 0);38933865 cpu_buffer->reader_page->read = 0;3894386638953895- local_set(&cpu_buffer->commit_overrun, 0);38963867 local_set(&cpu_buffer->entries_bytes, 0);38973868 local_set(&cpu_buffer->overrun, 0);38693869+ local_set(&cpu_buffer->commit_overrun, 0);38703870+ local_set(&cpu_buffer->dropped_events, 0);38983871 local_set(&cpu_buffer->entries, 0);38993872 local_set(&cpu_buffer->committing, 0);39003873 local_set(&cpu_buffer->commits, 0);
+191-181
kernel/trace/trace.c
···1919#include <linux/seq_file.h>2020#include <linux/notifier.h>2121#include <linux/irqflags.h>2222+#include <linux/irq_work.h>2223#include <linux/debugfs.h>2324#include <linux/pagemap.h>2425#include <linux/hardirq.h>···7776{7877 return 0;7978}7979+8080+/*8181+ * To prevent the comm cache from being overwritten when no8282+ * tracing is active, only save the comm when a trace event8383+ * occurred.8484+ */8585+static DEFINE_PER_CPU(bool, trace_cmdline_save);8686+8787+/*8888+ * When a reader is waiting for data, then this variable is8989+ * set to true.9090+ */9191+static bool trace_wakeup_needed;9292+9393+static struct irq_work trace_work_wakeup;80948195/*8296 * Kill all tracing for good (never come back).···155139}156140__setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops);157141142142+143143+static char trace_boot_options_buf[MAX_TRACER_SIZE] __initdata;144144+static char *trace_boot_options __initdata;145145+146146+static int __init set_trace_boot_options(char *str)147147+{148148+ strncpy(trace_boot_options_buf, str, MAX_TRACER_SIZE);149149+ trace_boot_options = trace_boot_options_buf;150150+ return 0;151151+}152152+__setup("trace_options=", set_trace_boot_options);153153+158154unsigned long long ns2usecs(cycle_t nsec)159155{160156 nsec += 500;···226198227199static DEFINE_PER_CPU(struct trace_array_cpu, max_tr_data);228200229229-/* tracer_enabled is used to toggle activation of a tracer */230230-static int tracer_enabled = 1;231231-232232-/**233233- * tracing_is_enabled - return tracer_enabled status234234- *235235- * This function is used by other tracers to know the status236236- * of the tracer_enabled flag. Tracers may use this function237237- * to know if it should enable their features when starting238238- * up. See irqsoff tracer for an example (start_irqsoff_tracer).239239- */240201int tracing_is_enabled(void)241202{242242- return tracer_enabled;203203+ return tracing_is_on();243204}244205245206/*···350333static int trace_stop_count;351334static DEFINE_RAW_SPINLOCK(tracing_start_lock);352335353353-static void wakeup_work_handler(struct work_struct *work)336336+/**337337+ * trace_wake_up - wake up tasks waiting for trace input338338+ *339339+ * Schedules a delayed work to wake up any task that is blocked on the340340+ * trace_wait queue. These is used with trace_poll for tasks polling the341341+ * trace.342342+ */343343+static void trace_wake_up(struct irq_work *work)354344{355355- wake_up(&trace_wait);356356-}345345+ wake_up_all(&trace_wait);357346358358-static DECLARE_DELAYED_WORK(wakeup_work, wakeup_work_handler);347347+}359348360349/**361350 * tracing_on - enable tracing buffers···416393}417394EXPORT_SYMBOL_GPL(tracing_is_on);418395419419-/**420420- * trace_wake_up - wake up tasks waiting for trace input421421- *422422- * Schedules a delayed work to wake up any task that is blocked on the423423- * trace_wait queue. These is used with trace_poll for tasks polling the424424- * trace.425425- */426426-void trace_wake_up(void)427427-{428428- const unsigned long delay = msecs_to_jiffies(2);429429-430430- if (trace_flags & TRACE_ITER_BLOCK)431431- return;432432- schedule_delayed_work(&wakeup_work, delay);433433-}434434-435396static int __init set_buf_size(char *str)436397{437398 unsigned long buf_size;···438431439432 if (!str)440433 return 0;441441- ret = strict_strtoul(str, 0, &threshold);434434+ ret = kstrtoul(str, 0, &threshold);442435 if (ret < 0)443436 return 0;444437 tracing_thresh = threshold * 1000;···764757}765758#endif /* CONFIG_TRACER_MAX_TRACE */766759760760+static void default_wait_pipe(struct trace_iterator *iter)761761+{762762+ DEFINE_WAIT(wait);763763+764764+ prepare_to_wait(&trace_wait, &wait, TASK_INTERRUPTIBLE);765765+766766+ /*767767+ * The events can happen in critical sections where768768+ * checking a work queue can cause deadlocks.769769+ * After adding a task to the queue, this flag is set770770+ * only to notify events to try to wake up the queue771771+ * using irq_work.772772+ *773773+ * We don't clear it even if the buffer is no longer774774+ * empty. The flag only causes the next event to run775775+ * irq_work to do the work queue wake up. The worse776776+ * that can happen if we race with !trace_empty() is that777777+ * an event will cause an irq_work to try to wake up778778+ * an empty queue.779779+ *780780+ * There's no reason to protect this flag either, as781781+ * the work queue and irq_work logic will do the necessary782782+ * synchronization for the wake ups. The only thing783783+ * that is necessary is that the wake up happens after784784+ * a task has been queued. It's OK for spurious wake ups.785785+ */786786+ trace_wakeup_needed = true;787787+788788+ if (trace_empty(iter))789789+ schedule();790790+791791+ finish_wait(&trace_wait, &wait);792792+}793793+767794/**768795 * register_tracer - register a tracer with the ftrace system.769796 * @type - the plugin for the tracer···914873915874 out_unlock:916875 return ret;917917-}918918-919919-void unregister_tracer(struct tracer *type)920920-{921921- struct tracer **t;922922-923923- mutex_lock(&trace_types_lock);924924- for (t = &trace_types; *t; t = &(*t)->next) {925925- if (*t == type)926926- goto found;927927- }928928- pr_info("Tracer %s not registered\n", type->name);929929- goto out;930930-931931- found:932932- *t = (*t)->next;933933-934934- if (type == current_trace && tracer_enabled) {935935- tracer_enabled = 0;936936- tracing_stop();937937- if (current_trace->stop)938938- current_trace->stop(&global_trace);939939- current_trace = &nop_trace;940940- }941941-out:942942- mutex_unlock(&trace_types_lock);943876}944877945878void tracing_reset(struct trace_array *tr, int cpu)···1146113111471132void tracing_record_cmdline(struct task_struct *tsk)11481133{11491149- if (atomic_read(&trace_record_cmdline_disabled) || !tracer_enabled ||11501150- !tracing_is_on())11341134+ if (atomic_read(&trace_record_cmdline_disabled) || !tracing_is_on())11511135 return;11361136+11371137+ if (!__this_cpu_read(trace_cmdline_save))11381138+ return;11391139+11401140+ __this_cpu_write(trace_cmdline_save, false);1152114111531142 trace_save_cmdline(tsk);11541143}···11971178 return event;11981179}1199118011811181+void11821182+__buffer_unlock_commit(struct ring_buffer *buffer, struct ring_buffer_event *event)11831183+{11841184+ __this_cpu_write(trace_cmdline_save, true);11851185+ if (trace_wakeup_needed) {11861186+ trace_wakeup_needed = false;11871187+ /* irq_work_queue() supplies it's own memory barriers */11881188+ irq_work_queue(&trace_work_wakeup);11891189+ }11901190+ ring_buffer_unlock_commit(buffer, event);11911191+}11921192+12001193static inline void12011194__trace_buffer_unlock_commit(struct ring_buffer *buffer,12021195 struct ring_buffer_event *event,12031203- unsigned long flags, int pc,12041204- int wake)11961196+ unsigned long flags, int pc)12051197{12061206- ring_buffer_unlock_commit(buffer, event);11981198+ __buffer_unlock_commit(buffer, event);1207119912081200 ftrace_trace_stack(buffer, flags, 6, pc);12091201 ftrace_trace_userstack(buffer, flags, pc);12101210-12111211- if (wake)12121212- trace_wake_up();12131202}1214120312151204void trace_buffer_unlock_commit(struct ring_buffer *buffer,12161205 struct ring_buffer_event *event,12171206 unsigned long flags, int pc)12181207{12191219- __trace_buffer_unlock_commit(buffer, event, flags, pc, 1);12081208+ __trace_buffer_unlock_commit(buffer, event, flags, pc);12201209}12101210+EXPORT_SYMBOL_GPL(trace_buffer_unlock_commit);1221121112221212struct ring_buffer_event *12231213trace_current_buffer_lock_reserve(struct ring_buffer **current_rb,···12431215 struct ring_buffer_event *event,12441216 unsigned long flags, int pc)12451217{12461246- __trace_buffer_unlock_commit(buffer, event, flags, pc, 1);12181218+ __trace_buffer_unlock_commit(buffer, event, flags, pc);12471219}12481220EXPORT_SYMBOL_GPL(trace_current_buffer_unlock_commit);1249122112501250-void trace_nowake_buffer_unlock_commit(struct ring_buffer *buffer,12511251- struct ring_buffer_event *event,12521252- unsigned long flags, int pc)12221222+void trace_buffer_unlock_commit_regs(struct ring_buffer *buffer,12231223+ struct ring_buffer_event *event,12241224+ unsigned long flags, int pc,12251225+ struct pt_regs *regs)12531226{12541254- __trace_buffer_unlock_commit(buffer, event, flags, pc, 0);12551255-}12561256-EXPORT_SYMBOL_GPL(trace_nowake_buffer_unlock_commit);12571257-12581258-void trace_nowake_buffer_unlock_commit_regs(struct ring_buffer *buffer,12591259- struct ring_buffer_event *event,12601260- unsigned long flags, int pc,12611261- struct pt_regs *regs)12621262-{12631263- ring_buffer_unlock_commit(buffer, event);12271227+ __buffer_unlock_commit(buffer, event);1264122812651229 ftrace_trace_stack_regs(buffer, flags, 0, pc, regs);12661230 ftrace_trace_userstack(buffer, flags, pc);12671231}12681268-EXPORT_SYMBOL_GPL(trace_nowake_buffer_unlock_commit_regs);12321232+EXPORT_SYMBOL_GPL(trace_buffer_unlock_commit_regs);1269123312701234void trace_current_buffer_discard_commit(struct ring_buffer *buffer,12711235 struct ring_buffer_event *event)···12891269 entry->parent_ip = parent_ip;1290127012911271 if (!filter_check_discard(call, entry, buffer, event))12921292- ring_buffer_unlock_commit(buffer, event);12721272+ __buffer_unlock_commit(buffer, event);12931273}1294127412951275void···13821362 entry->size = trace.nr_entries;1383136313841364 if (!filter_check_discard(call, entry, buffer, event))13851385- ring_buffer_unlock_commit(buffer, event);13651365+ __buffer_unlock_commit(buffer, event);1386136613871367 out:13881368 /* Again, don't let gcc optimize things here */···1478145814791459 save_stack_trace_user(&trace);14801460 if (!filter_check_discard(call, entry, buffer, event))14811481- ring_buffer_unlock_commit(buffer, event);14611461+ __buffer_unlock_commit(buffer, event);1482146214831463 out_drop_count:14841464 __this_cpu_dec(user_stack_count);···15791559 return -ENOMEM;15801560}1581156115621562+static int buffers_allocated;15631563+15821564void trace_printk_init_buffers(void)15831565{15841584- static int buffers_allocated;15851585-15861566 if (buffers_allocated)15871567 return;15881568···1591157115921572 pr_info("ftrace: Allocated trace_printk buffers\n");1593157315741574+ /* Expand the buffers to set size */15751575+ tracing_update_buffers();15761576+15941577 buffers_allocated = 1;15781578+15791579+ /*15801580+ * trace_printk_init_buffers() can be called by modules.15811581+ * If that happens, then we need to start cmdline recording15821582+ * directly here. If the global_trace.buffer is already15831583+ * allocated here, then this was called by module code.15841584+ */15851585+ if (global_trace.buffer)15861586+ tracing_start_cmdline_record();15871587+}15881588+15891589+void trace_printk_start_comm(void)15901590+{15911591+ /* Start tracing comms if trace printk is set */15921592+ if (!buffers_allocated)15931593+ return;15941594+ tracing_start_cmdline_record();15951595+}15961596+15971597+static void trace_printk_start_stop_comm(int enabled)15981598+{15991599+ if (!buffers_allocated)16001600+ return;16011601+16021602+ if (enabled)16031603+ tracing_start_cmdline_record();16041604+ else16051605+ tracing_stop_cmdline_record();15951606}1596160715971608/**···1673162216741623 memcpy(entry->buf, tbuffer, sizeof(u32) * len);16751624 if (!filter_check_discard(call, entry, buffer, event)) {16761676- ring_buffer_unlock_commit(buffer, event);16251625+ __buffer_unlock_commit(buffer, event);16771626 ftrace_trace_stack(buffer, flags, 6, pc);16781627 }16791628···17441693 memcpy(&entry->buf, tbuffer, len);17451694 entry->buf[len] = '\0';17461695 if (!filter_check_discard(call, entry, buffer, event)) {17471747- ring_buffer_unlock_commit(buffer, event);16961696+ __buffer_unlock_commit(buffer, event);17481697 ftrace_trace_stack(buffer, flags, 6, pc);17491698 }17501699 out:···2845279428462795 if (mask == TRACE_ITER_OVERWRITE)28472796 ring_buffer_change_overwrite(global_trace.buffer, enabled);27972797+27982798+ if (mask == TRACE_ITER_PRINTK)27992799+ trace_printk_start_stop_comm(enabled);28482800}2849280128502850-static ssize_t28512851-tracing_trace_options_write(struct file *filp, const char __user *ubuf,28522852- size_t cnt, loff_t *ppos)28022802+static int trace_set_options(char *option)28532803{28542854- char buf[64];28552804 char *cmp;28562805 int neg = 0;28572857- int ret;28062806+ int ret = 0;28582807 int i;2859280828602860- if (cnt >= sizeof(buf))28612861- return -EINVAL;28622862-28632863- if (copy_from_user(&buf, ubuf, cnt))28642864- return -EFAULT;28652865-28662866- buf[cnt] = 0;28672867- cmp = strstrip(buf);28092809+ cmp = strstrip(option);2868281028692811 if (strncmp(cmp, "no", 2) == 0) {28702812 neg = 1;···28762832 mutex_lock(&trace_types_lock);28772833 ret = set_tracer_option(current_trace, cmp, neg);28782834 mutex_unlock(&trace_types_lock);28792879- if (ret)28802880- return ret;28812835 }28362836+28372837+ return ret;28382838+}28392839+28402840+static ssize_t28412841+tracing_trace_options_write(struct file *filp, const char __user *ubuf,28422842+ size_t cnt, loff_t *ppos)28432843+{28442844+ char buf[64];28452845+28462846+ if (cnt >= sizeof(buf))28472847+ return -EINVAL;28482848+28492849+ if (copy_from_user(&buf, ubuf, cnt))28502850+ return -EFAULT;28512851+28522852+ trace_set_options(buf);2882285328832854 *ppos += cnt;28842855···29992940};3000294130012942static ssize_t30023002-tracing_ctrl_read(struct file *filp, char __user *ubuf,30033003- size_t cnt, loff_t *ppos)30043004-{30053005- char buf[64];30063006- int r;30073007-30083008- r = sprintf(buf, "%u\n", tracer_enabled);30093009- return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);30103010-}30113011-30123012-static ssize_t30133013-tracing_ctrl_write(struct file *filp, const char __user *ubuf,30143014- size_t cnt, loff_t *ppos)30153015-{30163016- struct trace_array *tr = filp->private_data;30173017- unsigned long val;30183018- int ret;30193019-30203020- ret = kstrtoul_from_user(ubuf, cnt, 10, &val);30213021- if (ret)30223022- return ret;30233023-30243024- val = !!val;30253025-30263026- mutex_lock(&trace_types_lock);30273027- if (tracer_enabled ^ val) {30283028-30293029- /* Only need to warn if this is used to change the state */30303030- WARN_ONCE(1, "tracing_enabled is deprecated. Use tracing_on");30313031-30323032- if (val) {30333033- tracer_enabled = 1;30343034- if (current_trace->start)30353035- current_trace->start(tr);30363036- tracing_start();30373037- } else {30383038- tracer_enabled = 0;30393039- tracing_stop();30403040- if (current_trace->stop)30413041- current_trace->stop(tr);30423042- }30433043- }30443044- mutex_unlock(&trace_types_lock);30453045-30463046- *ppos += cnt;30473047-30483048- return cnt;30493049-}30503050-30513051-static ssize_t30522943tracing_set_trace_read(struct file *filp, char __user *ubuf,30532944 size_t cnt, loff_t *ppos)30542945{···30383029 * expanding it later.30393030 */30403031 ring_buffer_expanded = 1;30323032+30333033+ /* May be called before buffers are initialized */30343034+ if (!global_trace.buffer)30353035+ return 0;3041303630423037 ret = ring_buffer_resize(global_trace.buffer, size, cpu);30433038 if (ret < 0)···33983385 }33993386}3400338734013401-34023402-void default_wait_pipe(struct trace_iterator *iter)34033403-{34043404- DEFINE_WAIT(wait);34053405-34063406- prepare_to_wait(&trace_wait, &wait, TASK_INTERRUPTIBLE);34073407-34083408- if (trace_empty(iter))34093409- schedule();34103410-34113411- finish_wait(&trace_wait, &wait);34123412-}34133413-34143388/*34153389 * This is a make-shift waitqueue.34163390 * A tracer might use this callback on some rare cases:···34383438 return -EINTR;3439343934403440 /*34413441- * We block until we read something and tracing is disabled.34413441+ * We block until we read something and tracing is enabled.34423442 * We still block if tracing is disabled, but we have never34433443 * read anything. This allows a user to cat this file, and34443444 * then enable tracing. But after we have read something,···34463446 *34473447 * iter->pos will be 0 if we haven't read anything.34483448 */34493449- if (!tracer_enabled && iter->pos)34493449+ if (tracing_is_enabled() && iter->pos)34503450 break;34513451 }34523452···39553955 } else39563956 entry->buf[cnt] = '\0';3957395739583958- ring_buffer_unlock_commit(buffer, event);39583958+ __buffer_unlock_commit(buffer, event);3959395939603960 written = cnt;39613961···40164016 if (max_tr.buffer)40174017 ring_buffer_set_clock(max_tr.buffer, trace_clocks[i].func);4018401840194019+ /*40204020+ * New clock may not be consistent with the previous clock.40214021+ * Reset the buffer so that it doesn't have incomparable timestamps.40224022+ */40234023+ tracing_reset_online_cpus(&global_trace);40244024+ if (max_tr.buffer)40254025+ tracing_reset_online_cpus(&max_tr);40264026+40194027 mutex_unlock(&trace_types_lock);4020402840214029 *fpos += cnt;···40424034 .open = tracing_open_generic,40434035 .read = tracing_max_lat_read,40444036 .write = tracing_max_lat_write,40454045- .llseek = generic_file_llseek,40464046-};40474047-40484048-static const struct file_operations tracing_ctrl_fops = {40494049- .open = tracing_open_generic,40504050- .read = tracing_ctrl_read,40514051- .write = tracing_ctrl_write,40524037 .llseek = generic_file_llseek,40534038};40544039···43854384 t = ns2usecs(ring_buffer_time_stamp(tr->buffer, cpu));43864385 usec_rem = do_div(t, USEC_PER_SEC);43874386 trace_seq_printf(s, "now ts: %5llu.%06lu\n", t, usec_rem);43874387+43884388+ cnt = ring_buffer_dropped_events_cpu(tr->buffer, cpu);43894389+ trace_seq_printf(s, "dropped events: %ld\n", cnt);4388439043894391 count = simple_read_from_buffer(ubuf, count, ppos, s->buffer, s->len);43904392···4819481548204816 d_tracer = tracing_init_dentry();4821481748224822- trace_create_file("tracing_enabled", 0644, d_tracer,48234823- &global_trace, &tracing_ctrl_fops);48244824-48254818 trace_create_file("trace_options", 0644, d_tracer,48264819 NULL, &tracing_iter_fops);48274820···5090508950915090 /* Only allocate trace_printk buffers if a trace_printk exists */50925091 if (__stop___trace_bprintk_fmt != __start___trace_bprintk_fmt)50925092+ /* Must be called before global_trace.buffer is allocated */50935093 trace_printk_init_buffers();5094509450955095 /* To save memory, keep the ring buffer size to its minimum */···51385136#endif5139513751405138 trace_init_cmdlines();51395139+ init_irq_work(&trace_work_wakeup, trace_wake_up);5141514051425141 register_tracer(&nop_trace);51435142 current_trace = &nop_trace;···51495146 &trace_panic_notifier);5150514751515148 register_die_notifier(&trace_die_notifier);51495149+51505150+ while (trace_boot_options) {51515151+ char *option;51525152+51535153+ option = strsep(&trace_boot_options, ",");51545154+ trace_set_options(option);51555155+ }5152515651535157 return 0;51545158
···10001000 }10011001 } else {10021002 if (field->is_signed)10031003- ret = strict_strtoll(pred->regex.pattern, 0, &val);10031003+ ret = kstrtoll(pred->regex.pattern, 0, &val);10041004 else10051005- ret = strict_strtoull(pred->regex.pattern, 0, &val);10051005+ ret = kstrtoull(pred->regex.pattern, 0, &val);10061006 if (ret) {10071007 parse_error(ps, FILT_ERR_ILLEGAL_INTVAL, 0);10081008 return -EINVAL;
+2-3
kernel/trace/trace_functions.c
···366366 * We use the callback data field (which is a pointer)367367 * as our counter.368368 */369369- ret = strict_strtoul(number, 0, (unsigned long *)&count);369369+ ret = kstrtoul(number, 0, (unsigned long *)&count);370370 if (ret)371371 return ret;372372···411411 init_func_cmd_traceon();412412 return register_tracer(&function_trace);413413}414414-device_initcall(init_function_trace);415415-414414+core_initcall(init_function_trace);
···320320 int (*func)(void))321321{322322 int save_ftrace_enabled = ftrace_enabled;323323- int save_tracer_enabled = tracer_enabled;324323 unsigned long count;325324 char *func_name;326325 int ret;···330331331332 /* enable tracing, and record the filter function */332333 ftrace_enabled = 1;333333- tracer_enabled = 1;334334335335 /* passed in by parameter to fool gcc from optimizing */336336 func();···393395394396 out:395397 ftrace_enabled = save_ftrace_enabled;396396- tracer_enabled = save_tracer_enabled;397398398399 /* Enable tracing on all functions again */399400 ftrace_set_global_filter(NULL, 0, 1);···449452trace_selftest_function_recursion(void)450453{451454 int save_ftrace_enabled = ftrace_enabled;452452- int save_tracer_enabled = tracer_enabled;453455 char *func_name;454456 int len;455457 int ret;···461465462466 /* enable tracing, and record the filter function */463467 ftrace_enabled = 1;464464- tracer_enabled = 1;465468466469 /* Handle PPC64 '.' name */467470 func_name = "*" __stringify(DYN_FTRACE_TEST_NAME);···529534 ret = 0;530535out:531536 ftrace_enabled = save_ftrace_enabled;532532- tracer_enabled = save_tracer_enabled;533537534538 return ret;535539}···563569trace_selftest_function_regs(void)564570{565571 int save_ftrace_enabled = ftrace_enabled;566566- int save_tracer_enabled = tracer_enabled;567572 char *func_name;568573 int len;569574 int ret;···579586580587 /* enable tracing, and record the filter function */581588 ftrace_enabled = 1;582582- tracer_enabled = 1;583589584590 /* Handle PPC64 '.' name */585591 func_name = "*" __stringify(DYN_FTRACE_TEST_NAME);···640648 ret = 0;641649out:642650 ftrace_enabled = save_ftrace_enabled;643643- tracer_enabled = save_tracer_enabled;644651645652 return ret;646653}···653662trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)654663{655664 int save_ftrace_enabled = ftrace_enabled;656656- int save_tracer_enabled = tracer_enabled;657665 unsigned long count;658666 int ret;659667···661671662672 /* start the tracing */663673 ftrace_enabled = 1;664664- tracer_enabled = 1;665674666675 ret = tracer_init(trace, tr);667676 if (ret) {···697708 ret = trace_selftest_function_regs();698709 out:699710 ftrace_enabled = save_ftrace_enabled;700700- tracer_enabled = save_tracer_enabled;701711702712 /* kill ftrace totally if we failed */703713 if (ret)···10941106 tracing_stop();10951107 /* check both trace buffers */10961108 ret = trace_test_buffer(tr, NULL);11091109+ printk("ret = %d\n", ret);10971110 if (!ret)10981111 ret = trace_test_buffer(&max_tr, &count);10991112
···252252 if (ret)253253 goto fail_address_parse;254254255255- ret = strict_strtoul(arg, 0, &offset);255255+ ret = kstrtoul(arg, 0, &offset);256256 if (ret)257257 goto fail_address_parse;258258