Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'trace-v4.6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing updates from Steven Rostedt:
"Nothing major this round. Mostly small clean ups and fixes.

Some visible changes:

- A new flag was added to distinguish traces done in NMI context.

- Preempt tracer now shows functions where preemption is disabled but
interrupts are still enabled.

Other notes:

- Updates were done to function tracing to allow better performance
with perf.

- Infrastructure code has been added to allow for a new histogram
feature for recording live trace event histograms that can be
configured by simple user commands. The feature itself was just
finished, but needs a round in linux-next before being pulled.

This only includes some infrastructure changes that will be needed"

* tag 'trace-v4.6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (22 commits)
tracing: Record and show NMI state
tracing: Fix trace_printk() to print when not using bprintk()
tracing: Remove redundant reset per-CPU buff in irqsoff tracer
x86: ftrace: Fix the misleading comment for arch/x86/kernel/ftrace.c
tracing: Fix crash from reading trace_pipe with sendfile
tracing: Have preempt(irqs)off trace preempt disabled functions
tracing: Fix return while holding a lock in register_tracer()
ftrace: Use kasprintf() in ftrace_profile_tracefs()
ftrace: Update dynamic ftrace calls only if necessary
ftrace: Make ftrace_hash_rec_enable return update bool
tracing: Fix typoes in code comment and printk in trace_nop.c
tracing, writeback: Replace cgroup path to cgroup ino
tracing: Use flags instead of bool in trigger structure
tracing: Add an unreg_all() callback to trigger commands
tracing: Add needs_rec flag to event triggers
tracing: Add a per-event-trigger 'paused' field
tracing: Add get_syscall_name()
tracing: Add event record param to trigger_ops.func()
tracing: Make event trigger functions available
tracing: Make ftrace_event_field checking functions available
...

+280 -235
+1 -1
arch/x86/kernel/ftrace.c
··· 1 1 /* 2 - * Code for replacing ftrace calls with jumps. 2 + * Dynamic function tracing support. 3 3 * 4 4 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com> 5 5 *
+3 -3
include/linux/kernel.h
··· 618 618 619 619 #define do_trace_printk(fmt, args...) \ 620 620 do { \ 621 - static const char *trace_printk_fmt \ 621 + static const char *trace_printk_fmt __used \ 622 622 __attribute__((section("__trace_printk_fmt"))) = \ 623 623 __builtin_constant_p(fmt) ? fmt : NULL; \ 624 624 \ ··· 662 662 */ 663 663 664 664 #define trace_puts(str) ({ \ 665 - static const char *trace_printk_fmt \ 665 + static const char *trace_printk_fmt __used \ 666 666 __attribute__((section("__trace_printk_fmt"))) = \ 667 667 __builtin_constant_p(str) ? str : NULL; \ 668 668 \ ··· 684 684 #define ftrace_vprintk(fmt, vargs) \ 685 685 do { \ 686 686 if (__builtin_constant_p(fmt)) { \ 687 - static const char *trace_printk_fmt \ 687 + static const char *trace_printk_fmt __used \ 688 688 __attribute__((section("__trace_printk_fmt"))) = \ 689 689 __builtin_constant_p(fmt) ? fmt : NULL; \ 690 690 \
+4 -3
include/linux/trace_events.h
··· 420 420 extern enum event_trigger_type event_triggers_call(struct trace_event_file *file, 421 421 void *rec); 422 422 extern void event_triggers_post_call(struct trace_event_file *file, 423 - enum event_trigger_type tt); 423 + enum event_trigger_type tt, 424 + void *rec); 424 425 425 426 bool trace_event_ignore_this_pid(struct trace_event_file *trace_file); 426 427 ··· 508 507 trace_buffer_unlock_commit(file->tr, buffer, event, irq_flags, pc); 509 508 510 509 if (tt) 511 - event_triggers_post_call(file, tt); 510 + event_triggers_post_call(file, tt, entry); 512 511 } 513 512 514 513 /** ··· 541 540 irq_flags, pc, regs); 542 541 543 542 if (tt) 544 - event_triggers_post_call(file, tt); 543 + event_triggers_post_call(file, tt, entry); 545 544 } 546 545 547 546 #ifdef CONFIG_BPF_EVENTS
+4 -38
include/trace/events/kmem.h
··· 140 140 TP_ARGS(call_site, ptr) 141 141 ); 142 142 143 - DEFINE_EVENT_CONDITION(kmem_free, kmem_cache_free, 143 + DEFINE_EVENT(kmem_free, kmem_cache_free, 144 144 145 145 TP_PROTO(unsigned long call_site, const void *ptr), 146 146 147 - TP_ARGS(call_site, ptr), 148 - 149 - /* 150 - * This trace can be potentially called from an offlined cpu. 151 - * Since trace points use RCU and RCU should not be used from 152 - * offline cpus, filter such calls out. 153 - * While this trace can be called from a preemptable section, 154 - * it has no impact on the condition since tasks can migrate 155 - * only from online cpus to other online cpus. Thus its safe 156 - * to use raw_smp_processor_id. 157 - */ 158 - TP_CONDITION(cpu_online(raw_smp_processor_id())) 147 + TP_ARGS(call_site, ptr) 159 148 ); 160 149 161 - TRACE_EVENT_CONDITION(mm_page_free, 150 + TRACE_EVENT(mm_page_free, 162 151 163 152 TP_PROTO(struct page *page, unsigned int order), 164 153 165 154 TP_ARGS(page, order), 166 - 167 - 168 - /* 169 - * This trace can be potentially called from an offlined cpu. 170 - * Since trace points use RCU and RCU should not be used from 171 - * offline cpus, filter such calls out. 172 - * While this trace can be called from a preemptable section, 173 - * it has no impact on the condition since tasks can migrate 174 - * only from online cpus to other online cpus. Thus its safe 175 - * to use raw_smp_processor_id. 176 - */ 177 - TP_CONDITION(cpu_online(raw_smp_processor_id())), 178 155 179 156 TP_STRUCT__entry( 180 157 __field( unsigned long, pfn ) ··· 253 276 TP_ARGS(page, order, migratetype) 254 277 ); 255 278 256 - TRACE_EVENT_CONDITION(mm_page_pcpu_drain, 279 + TRACE_EVENT(mm_page_pcpu_drain, 257 280 258 281 TP_PROTO(struct page *page, unsigned int order, int migratetype), 259 282 260 283 TP_ARGS(page, order, migratetype), 261 - 262 - /* 263 - * This trace can be potentially called from an offlined cpu. 264 - * Since trace points use RCU and RCU should not be used from 265 - * offline cpus, filter such calls out. 266 - * While this trace can be called from a preemptable section, 267 - * it has no impact on the condition since tasks can migrate 268 - * only from online cpus to other online cpus. Thus its safe 269 - * to use raw_smp_processor_id. 270 - */ 271 - TP_CONDITION(cpu_online(raw_smp_processor_id())), 272 284 273 285 TP_STRUCT__entry( 274 286 __field( unsigned long, pfn )
+1 -3
include/trace/events/tlb.h
··· 34 34 #define EM(a,b) { a, b }, 35 35 #define EMe(a,b) { a, b } 36 36 37 - TRACE_EVENT_CONDITION(tlb_flush, 37 + TRACE_EVENT(tlb_flush, 38 38 39 39 TP_PROTO(int reason, unsigned long pages), 40 40 TP_ARGS(reason, pages), 41 - 42 - TP_CONDITION(cpu_online(smp_processor_id())), 43 41 44 42 TP_STRUCT__entry( 45 43 __field( int, reason)
+45 -76
include/trace/events/writeback.h
··· 134 134 #ifdef CREATE_TRACE_POINTS 135 135 #ifdef CONFIG_CGROUP_WRITEBACK 136 136 137 - static inline size_t __trace_wb_cgroup_size(struct bdi_writeback *wb) 137 + static inline unsigned int __trace_wb_assign_cgroup(struct bdi_writeback *wb) 138 138 { 139 - return kernfs_path_len(wb->memcg_css->cgroup->kn) + 1; 139 + return wb->memcg_css->cgroup->kn->ino; 140 140 } 141 141 142 - static inline void __trace_wb_assign_cgroup(char *buf, struct bdi_writeback *wb) 143 - { 144 - struct cgroup *cgrp = wb->memcg_css->cgroup; 145 - char *path; 146 - 147 - path = cgroup_path(cgrp, buf, kernfs_path_len(cgrp->kn) + 1); 148 - WARN_ON_ONCE(path != buf); 149 - } 150 - 151 - static inline size_t __trace_wbc_cgroup_size(struct writeback_control *wbc) 142 + static inline unsigned int __trace_wbc_assign_cgroup(struct writeback_control *wbc) 152 143 { 153 144 if (wbc->wb) 154 - return __trace_wb_cgroup_size(wbc->wb); 145 + return __trace_wb_assign_cgroup(wbc->wb); 155 146 else 156 - return 2; 147 + return -1U; 157 148 } 158 - 159 - static inline void __trace_wbc_assign_cgroup(char *buf, 160 - struct writeback_control *wbc) 161 - { 162 - if (wbc->wb) 163 - __trace_wb_assign_cgroup(buf, wbc->wb); 164 - else 165 - strcpy(buf, "/"); 166 - } 167 - 168 149 #else /* CONFIG_CGROUP_WRITEBACK */ 169 150 170 - static inline size_t __trace_wb_cgroup_size(struct bdi_writeback *wb) 151 + static inline unsigned int __trace_wb_assign_cgroup(struct bdi_writeback *wb) 171 152 { 172 - return 2; 153 + return -1U; 173 154 } 174 155 175 - static inline void __trace_wb_assign_cgroup(char *buf, struct bdi_writeback *wb) 156 + static inline unsigned int __trace_wbc_assign_cgroup(struct writeback_control *wbc) 176 157 { 177 - strcpy(buf, "/"); 178 - } 179 - 180 - static inline size_t __trace_wbc_cgroup_size(struct writeback_control *wbc) 181 - { 182 - return 2; 183 - } 184 - 185 - static inline void __trace_wbc_assign_cgroup(char *buf, 186 - struct writeback_control *wbc) 187 - { 188 - strcpy(buf, "/"); 158 + return -1U; 189 159 } 190 160 191 161 #endif /* CONFIG_CGROUP_WRITEBACK */ ··· 171 201 __array(char, name, 32) 172 202 __field(unsigned long, ino) 173 203 __field(int, sync_mode) 174 - __dynamic_array(char, cgroup, __trace_wbc_cgroup_size(wbc)) 204 + __field(unsigned int, cgroup_ino) 175 205 ), 176 206 177 207 TP_fast_assign( ··· 179 209 dev_name(inode_to_bdi(inode)->dev), 32); 180 210 __entry->ino = inode->i_ino; 181 211 __entry->sync_mode = wbc->sync_mode; 182 - __trace_wbc_assign_cgroup(__get_str(cgroup), wbc); 212 + __entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc); 183 213 ), 184 214 185 - TP_printk("bdi %s: ino=%lu sync_mode=%d cgroup=%s", 215 + TP_printk("bdi %s: ino=%lu sync_mode=%d cgroup_ino=%u", 186 216 __entry->name, 187 217 __entry->ino, 188 218 __entry->sync_mode, 189 - __get_str(cgroup) 219 + __entry->cgroup_ino 190 220 ) 191 221 ); 192 222 ··· 216 246 __field(int, range_cyclic) 217 247 __field(int, for_background) 218 248 __field(int, reason) 219 - __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb)) 249 + __field(unsigned int, cgroup_ino) 220 250 ), 221 251 TP_fast_assign( 222 252 strncpy(__entry->name, ··· 228 258 __entry->range_cyclic = work->range_cyclic; 229 259 __entry->for_background = work->for_background; 230 260 __entry->reason = work->reason; 231 - __trace_wb_assign_cgroup(__get_str(cgroup), wb); 261 + __entry->cgroup_ino = __trace_wb_assign_cgroup(wb); 232 262 ), 233 263 TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d " 234 - "kupdate=%d range_cyclic=%d background=%d reason=%s cgroup=%s", 264 + "kupdate=%d range_cyclic=%d background=%d reason=%s cgroup_ino=%u", 235 265 __entry->name, 236 266 MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev), 237 267 __entry->nr_pages, ··· 240 270 __entry->range_cyclic, 241 271 __entry->for_background, 242 272 __print_symbolic(__entry->reason, WB_WORK_REASON), 243 - __get_str(cgroup) 273 + __entry->cgroup_ino 244 274 ) 245 275 ); 246 276 #define DEFINE_WRITEBACK_WORK_EVENT(name) \ ··· 270 300 TP_ARGS(wb), 271 301 TP_STRUCT__entry( 272 302 __array(char, name, 32) 273 - __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb)) 303 + __field(unsigned int, cgroup_ino) 274 304 ), 275 305 TP_fast_assign( 276 306 strncpy(__entry->name, dev_name(wb->bdi->dev), 32); 277 - __trace_wb_assign_cgroup(__get_str(cgroup), wb); 307 + __entry->cgroup_ino = __trace_wb_assign_cgroup(wb); 278 308 ), 279 - TP_printk("bdi %s: cgroup=%s", 309 + TP_printk("bdi %s: cgroup_ino=%u", 280 310 __entry->name, 281 - __get_str(cgroup) 311 + __entry->cgroup_ino 282 312 ) 283 313 ); 284 314 #define DEFINE_WRITEBACK_EVENT(name) \ ··· 317 347 __field(int, range_cyclic) 318 348 __field(long, range_start) 319 349 __field(long, range_end) 320 - __dynamic_array(char, cgroup, __trace_wbc_cgroup_size(wbc)) 350 + __field(unsigned int, cgroup_ino) 321 351 ), 322 352 323 353 TP_fast_assign( ··· 331 361 __entry->range_cyclic = wbc->range_cyclic; 332 362 __entry->range_start = (long)wbc->range_start; 333 363 __entry->range_end = (long)wbc->range_end; 334 - __trace_wbc_assign_cgroup(__get_str(cgroup), wbc); 364 + __entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc); 335 365 ), 336 366 337 367 TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d " 338 368 "bgrd=%d reclm=%d cyclic=%d " 339 - "start=0x%lx end=0x%lx cgroup=%s", 369 + "start=0x%lx end=0x%lx cgroup_ino=%u", 340 370 __entry->name, 341 371 __entry->nr_to_write, 342 372 __entry->pages_skipped, ··· 347 377 __entry->range_cyclic, 348 378 __entry->range_start, 349 379 __entry->range_end, 350 - __get_str(cgroup) 380 + __entry->cgroup_ino 351 381 ) 352 382 ) 353 383 ··· 368 398 __field(long, age) 369 399 __field(int, moved) 370 400 __field(int, reason) 371 - __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb)) 401 + __field(unsigned int, cgroup_ino) 372 402 ), 373 403 TP_fast_assign( 374 404 unsigned long *older_than_this = work->older_than_this; ··· 378 408 (jiffies - *older_than_this) * 1000 / HZ : -1; 379 409 __entry->moved = moved; 380 410 __entry->reason = work->reason; 381 - __trace_wb_assign_cgroup(__get_str(cgroup), wb); 411 + __entry->cgroup_ino = __trace_wb_assign_cgroup(wb); 382 412 ), 383 - TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s cgroup=%s", 413 + TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s cgroup_ino=%u", 384 414 __entry->name, 385 415 __entry->older, /* older_than_this in jiffies */ 386 416 __entry->age, /* older_than_this in relative milliseconds */ 387 417 __entry->moved, 388 418 __print_symbolic(__entry->reason, WB_WORK_REASON), 389 - __get_str(cgroup) 419 + __entry->cgroup_ino 390 420 ) 391 421 ); 392 422 ··· 454 484 __field(unsigned long, dirty_ratelimit) 455 485 __field(unsigned long, task_ratelimit) 456 486 __field(unsigned long, balanced_dirty_ratelimit) 457 - __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb)) 487 + __field(unsigned int, cgroup_ino) 458 488 ), 459 489 460 490 TP_fast_assign( ··· 466 496 __entry->task_ratelimit = KBps(task_ratelimit); 467 497 __entry->balanced_dirty_ratelimit = 468 498 KBps(wb->balanced_dirty_ratelimit); 469 - __trace_wb_assign_cgroup(__get_str(cgroup), wb); 499 + __entry->cgroup_ino = __trace_wb_assign_cgroup(wb); 470 500 ), 471 501 472 502 TP_printk("bdi %s: " 473 503 "write_bw=%lu awrite_bw=%lu dirty_rate=%lu " 474 504 "dirty_ratelimit=%lu task_ratelimit=%lu " 475 - "balanced_dirty_ratelimit=%lu cgroup=%s", 505 + "balanced_dirty_ratelimit=%lu cgroup_ino=%u", 476 506 __entry->bdi, 477 507 __entry->write_bw, /* write bandwidth */ 478 508 __entry->avg_write_bw, /* avg write bandwidth */ ··· 480 510 __entry->dirty_ratelimit, /* base ratelimit */ 481 511 __entry->task_ratelimit, /* ratelimit with position control */ 482 512 __entry->balanced_dirty_ratelimit, /* the balanced ratelimit */ 483 - __get_str(cgroup) 513 + __entry->cgroup_ino 484 514 ) 485 515 ); 486 516 ··· 518 548 __field( long, pause) 519 549 __field(unsigned long, period) 520 550 __field( long, think) 521 - __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb)) 551 + __field(unsigned int, cgroup_ino) 522 552 ), 523 553 524 554 TP_fast_assign( ··· 541 571 __entry->period = period * 1000 / HZ; 542 572 __entry->pause = pause * 1000 / HZ; 543 573 __entry->paused = (jiffies - start_time) * 1000 / HZ; 544 - __trace_wb_assign_cgroup(__get_str(cgroup), wb); 574 + __entry->cgroup_ino = __trace_wb_assign_cgroup(wb); 545 575 ), 546 576 547 577 ··· 550 580 "bdi_setpoint=%lu bdi_dirty=%lu " 551 581 "dirty_ratelimit=%lu task_ratelimit=%lu " 552 582 "dirtied=%u dirtied_pause=%u " 553 - "paused=%lu pause=%ld period=%lu think=%ld cgroup=%s", 583 + "paused=%lu pause=%ld period=%lu think=%ld cgroup_ino=%u", 554 584 __entry->bdi, 555 585 __entry->limit, 556 586 __entry->setpoint, ··· 565 595 __entry->pause, /* ms */ 566 596 __entry->period, /* ms */ 567 597 __entry->think, /* ms */ 568 - __get_str(cgroup) 598 + __entry->cgroup_ino 569 599 ) 570 600 ); 571 601 ··· 579 609 __field(unsigned long, ino) 580 610 __field(unsigned long, state) 581 611 __field(unsigned long, dirtied_when) 582 - __dynamic_array(char, cgroup, 583 - __trace_wb_cgroup_size(inode_to_wb(inode))) 612 + __field(unsigned int, cgroup_ino) 584 613 ), 585 614 586 615 TP_fast_assign( ··· 588 619 __entry->ino = inode->i_ino; 589 620 __entry->state = inode->i_state; 590 621 __entry->dirtied_when = inode->dirtied_when; 591 - __trace_wb_assign_cgroup(__get_str(cgroup), inode_to_wb(inode)); 622 + __entry->cgroup_ino = __trace_wb_assign_cgroup(inode_to_wb(inode)); 592 623 ), 593 624 594 - TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu cgroup=%s", 625 + TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu cgroup_ino=%u", 595 626 __entry->name, 596 627 __entry->ino, 597 628 show_inode_state(__entry->state), 598 629 __entry->dirtied_when, 599 630 (jiffies - __entry->dirtied_when) / HZ, 600 - __get_str(cgroup) 631 + __entry->cgroup_ino 601 632 ) 602 633 ); 603 634 ··· 653 684 __field(unsigned long, writeback_index) 654 685 __field(long, nr_to_write) 655 686 __field(unsigned long, wrote) 656 - __dynamic_array(char, cgroup, __trace_wbc_cgroup_size(wbc)) 687 + __field(unsigned int, cgroup_ino) 657 688 ), 658 689 659 690 TP_fast_assign( ··· 665 696 __entry->writeback_index = inode->i_mapping->writeback_index; 666 697 __entry->nr_to_write = nr_to_write; 667 698 __entry->wrote = nr_to_write - wbc->nr_to_write; 668 - __trace_wbc_assign_cgroup(__get_str(cgroup), wbc); 699 + __entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc); 669 700 ), 670 701 671 702 TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu " 672 - "index=%lu to_write=%ld wrote=%lu cgroup=%s", 703 + "index=%lu to_write=%ld wrote=%lu cgroup_ino=%u", 673 704 __entry->name, 674 705 __entry->ino, 675 706 show_inode_state(__entry->state), ··· 678 709 __entry->writeback_index, 679 710 __entry->nr_to_write, 680 711 __entry->wrote, 681 - __get_str(cgroup) 712 + __entry->cgroup_ino 682 713 ) 683 714 ); 684 715
+23 -18
kernel/trace/ftrace.c
··· 1030 1030 for_each_possible_cpu(cpu) { 1031 1031 stat = &per_cpu(ftrace_profile_stats, cpu); 1032 1032 1033 - /* allocate enough for function name + cpu number */ 1034 - name = kmalloc(32, GFP_KERNEL); 1033 + name = kasprintf(GFP_KERNEL, "function%d", cpu); 1035 1034 if (!name) { 1036 1035 /* 1037 1036 * The files created are permanent, if something happens ··· 1042 1043 return; 1043 1044 } 1044 1045 stat->stat = function_stats; 1045 - snprintf(name, 32, "function%d", cpu); 1046 1046 stat->stat.name = name; 1047 1047 ret = register_stat_tracer(&stat->stat); 1048 1048 if (ret) { ··· 1607 1609 return keep_regs; 1608 1610 } 1609 1611 1610 - static void __ftrace_hash_rec_update(struct ftrace_ops *ops, 1612 + static bool __ftrace_hash_rec_update(struct ftrace_ops *ops, 1611 1613 int filter_hash, 1612 1614 bool inc) 1613 1615 { ··· 1615 1617 struct ftrace_hash *other_hash; 1616 1618 struct ftrace_page *pg; 1617 1619 struct dyn_ftrace *rec; 1620 + bool update = false; 1618 1621 int count = 0; 1619 1622 int all = 0; 1620 1623 1621 1624 /* Only update if the ops has been registered */ 1622 1625 if (!(ops->flags & FTRACE_OPS_FL_ENABLED)) 1623 - return; 1626 + return false; 1624 1627 1625 1628 /* 1626 1629 * In the filter_hash case: ··· 1648 1649 * then there's nothing to do. 1649 1650 */ 1650 1651 if (ftrace_hash_empty(hash)) 1651 - return; 1652 + return false; 1652 1653 } 1653 1654 1654 1655 do_for_each_ftrace_rec(pg, rec) { ··· 1692 1693 if (inc) { 1693 1694 rec->flags++; 1694 1695 if (FTRACE_WARN_ON(ftrace_rec_count(rec) == FTRACE_REF_MAX)) 1695 - return; 1696 + return false; 1696 1697 1697 1698 /* 1698 1699 * If there's only a single callback registered to a ··· 1718 1719 rec->flags |= FTRACE_FL_REGS; 1719 1720 } else { 1720 1721 if (FTRACE_WARN_ON(ftrace_rec_count(rec) == 0)) 1721 - return; 1722 + return false; 1722 1723 rec->flags--; 1723 1724 1724 1725 /* ··· 1751 1752 */ 1752 1753 } 1753 1754 count++; 1755 + 1756 + /* Must match FTRACE_UPDATE_CALLS in ftrace_modify_all_code() */ 1757 + update |= ftrace_test_record(rec, 1) != FTRACE_UPDATE_IGNORE; 1758 + 1754 1759 /* Shortcut, if we handled all records, we are done. */ 1755 1760 if (!all && count == hash->count) 1756 - return; 1761 + return update; 1757 1762 } while_for_each_ftrace_rec(); 1763 + 1764 + return update; 1758 1765 } 1759 1766 1760 - static void ftrace_hash_rec_disable(struct ftrace_ops *ops, 1767 + static bool ftrace_hash_rec_disable(struct ftrace_ops *ops, 1761 1768 int filter_hash) 1762 1769 { 1763 - __ftrace_hash_rec_update(ops, filter_hash, 0); 1770 + return __ftrace_hash_rec_update(ops, filter_hash, 0); 1764 1771 } 1765 1772 1766 - static void ftrace_hash_rec_enable(struct ftrace_ops *ops, 1773 + static bool ftrace_hash_rec_enable(struct ftrace_ops *ops, 1767 1774 int filter_hash) 1768 1775 { 1769 - __ftrace_hash_rec_update(ops, filter_hash, 1); 1776 + return __ftrace_hash_rec_update(ops, filter_hash, 1); 1770 1777 } 1771 1778 1772 1779 static void ftrace_hash_rec_update_modify(struct ftrace_ops *ops, ··· 2648 2643 return ret; 2649 2644 2650 2645 ftrace_start_up++; 2651 - command |= FTRACE_UPDATE_CALLS; 2652 2646 2653 2647 /* 2654 2648 * Note that ftrace probes uses this to start up ··· 2668 2664 return ret; 2669 2665 } 2670 2666 2671 - ftrace_hash_rec_enable(ops, 1); 2667 + if (ftrace_hash_rec_enable(ops, 1)) 2668 + command |= FTRACE_UPDATE_CALLS; 2672 2669 2673 2670 ftrace_startup_enable(command); 2674 2671 ··· 2699 2694 2700 2695 /* Disabling ipmodify never fails */ 2701 2696 ftrace_hash_ipmodify_disable(ops); 2702 - ftrace_hash_rec_disable(ops, 1); 2697 + 2698 + if (ftrace_hash_rec_disable(ops, 1)) 2699 + command |= FTRACE_UPDATE_CALLS; 2703 2700 2704 2701 ops->flags &= ~FTRACE_OPS_FL_ENABLED; 2705 - 2706 - command |= FTRACE_UPDATE_CALLS; 2707 2702 2708 2703 if (saved_ftrace_func != ftrace_trace_function) { 2709 2704 saved_ftrace_func = ftrace_trace_function;
+21 -15
kernel/trace/trace.c
··· 74 74 { } 75 75 }; 76 76 77 - static struct tracer_flags dummy_tracer_flags = { 78 - .val = 0, 79 - .opts = dummy_tracer_opt 80 - }; 81 - 82 77 static int 83 78 dummy_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set) 84 79 { ··· 1253 1258 1254 1259 if (!type->set_flag) 1255 1260 type->set_flag = &dummy_set_flag; 1256 - if (!type->flags) 1257 - type->flags = &dummy_tracer_flags; 1258 - else 1261 + if (!type->flags) { 1262 + /*allocate a dummy tracer_flags*/ 1263 + type->flags = kmalloc(sizeof(*type->flags), GFP_KERNEL); 1264 + if (!type->flags) { 1265 + ret = -ENOMEM; 1266 + goto out; 1267 + } 1268 + type->flags->val = 0; 1269 + type->flags->opts = dummy_tracer_opt; 1270 + } else 1259 1271 if (!type->flags->opts) 1260 1272 type->flags->opts = dummy_tracer_opt; 1273 + 1274 + /* store the tracer for __set_tracer_option */ 1275 + type->flags->trace = type; 1261 1276 1262 1277 ret = run_tracer_selftest(type); 1263 1278 if (ret < 0) ··· 1664 1659 #else 1665 1660 TRACE_FLAG_IRQS_NOSUPPORT | 1666 1661 #endif 1662 + ((pc & NMI_MASK ) ? TRACE_FLAG_NMI : 0) | 1667 1663 ((pc & HARDIRQ_MASK) ? TRACE_FLAG_HARDIRQ : 0) | 1668 1664 ((pc & SOFTIRQ_MASK) ? TRACE_FLAG_SOFTIRQ : 0) | 1669 1665 (tif_need_resched() ? TRACE_FLAG_NEED_RESCHED : 0) | ··· 3511 3505 struct tracer_flags *tracer_flags, 3512 3506 struct tracer_opt *opts, int neg) 3513 3507 { 3514 - struct tracer *trace = tr->current_trace; 3508 + struct tracer *trace = tracer_flags->trace; 3515 3509 int ret; 3516 3510 3517 3511 ret = trace->set_flag(tr, tracer_flags->val, opts->bit, !neg); ··· 4955 4949 4956 4950 spd.nr_pages = i; 4957 4951 4958 - ret = splice_to_pipe(pipe, &spd); 4952 + if (i) 4953 + ret = splice_to_pipe(pipe, &spd); 4954 + else 4955 + ret = 0; 4959 4956 out: 4960 4957 splice_shrink_spd(&spd); 4961 4958 return ret; ··· 6400 6391 return; 6401 6392 6402 6393 for (i = 0; i < tr->nr_topts; i++) { 6403 - /* 6404 - * Check if these flags have already been added. 6405 - * Some tracers share flags. 6406 - */ 6407 - if (tr->topts[i].tracer->flags == tracer->flags) 6394 + /* Make sure there's no duplicate flags. */ 6395 + if (WARN_ON_ONCE(tr->topts[i].tracer->flags == tracer->flags)) 6408 6396 return; 6409 6397 } 6410 6398
+90 -23
kernel/trace/trace.h
··· 125 125 TRACE_FLAG_HARDIRQ = 0x08, 126 126 TRACE_FLAG_SOFTIRQ = 0x10, 127 127 TRACE_FLAG_PREEMPT_RESCHED = 0x20, 128 + TRACE_FLAG_NMI = 0x40, 128 129 }; 129 130 130 131 #define TRACE_BUF_SIZE 1024 ··· 346 345 struct tracer_flags { 347 346 u32 val; 348 347 struct tracer_opt *opts; 348 + struct tracer *trace; 349 349 }; 350 350 351 351 /* Makes more easy to define a tracer opt */ ··· 1113 1111 unsigned short right; 1114 1112 }; 1115 1113 1114 + static inline bool is_string_field(struct ftrace_event_field *field) 1115 + { 1116 + return field->filter_type == FILTER_DYN_STRING || 1117 + field->filter_type == FILTER_STATIC_STRING || 1118 + field->filter_type == FILTER_PTR_STRING; 1119 + } 1120 + 1121 + static inline bool is_function_field(struct ftrace_event_field *field) 1122 + { 1123 + return field->filter_type == FILTER_TRACE_FN; 1124 + } 1125 + 1116 1126 extern enum regex_type 1117 1127 filter_parse_regex(char *buff, int len, char **search, int *not); 1118 1128 extern void print_event_filter(struct trace_event_file *file, ··· 1173 1159 struct event_filter __rcu *filter; 1174 1160 char *filter_str; 1175 1161 void *private_data; 1162 + bool paused; 1176 1163 struct list_head list; 1177 1164 }; 1165 + 1166 + extern void trigger_data_free(struct event_trigger_data *data); 1167 + extern int event_trigger_init(struct event_trigger_ops *ops, 1168 + struct event_trigger_data *data); 1169 + extern int trace_event_trigger_enable_disable(struct trace_event_file *file, 1170 + int trigger_enable); 1171 + extern void update_cond_flag(struct trace_event_file *file); 1172 + extern void unregister_trigger(char *glob, struct event_trigger_ops *ops, 1173 + struct event_trigger_data *test, 1174 + struct trace_event_file *file); 1175 + extern int set_trigger_filter(char *filter_str, 1176 + struct event_trigger_data *trigger_data, 1177 + struct trace_event_file *file); 1178 + extern int register_event_command(struct event_command *cmd); 1178 1179 1179 1180 /** 1180 1181 * struct event_trigger_ops - callbacks for trace event triggers ··· 1203 1174 * @func: The trigger 'probe' function called when the triggering 1204 1175 * event occurs. The data passed into this callback is the data 1205 1176 * that was supplied to the event_command @reg() function that 1206 - * registered the trigger (see struct event_command). 1177 + * registered the trigger (see struct event_command) along with 1178 + * the trace record, rec. 1207 1179 * 1208 1180 * @init: An optional initialization function called for the trigger 1209 1181 * when the trigger is registered (via the event_command reg() ··· 1229 1199 * (see trace_event_triggers.c). 1230 1200 */ 1231 1201 struct event_trigger_ops { 1232 - void (*func)(struct event_trigger_data *data); 1202 + void (*func)(struct event_trigger_data *data, 1203 + void *rec); 1233 1204 int (*init)(struct event_trigger_ops *ops, 1234 1205 struct event_trigger_data *data); 1235 1206 void (*free)(struct event_trigger_ops *ops, ··· 1274 1243 * values are defined by adding new values to the trigger_type 1275 1244 * enum in include/linux/trace_events.h. 1276 1245 * 1277 - * @post_trigger: A flag that says whether or not this command needs 1278 - * to have its action delayed until after the current event has 1279 - * been closed. Some triggers need to avoid being invoked while 1280 - * an event is currently in the process of being logged, since 1281 - * the trigger may itself log data into the trace buffer. Thus 1282 - * we make sure the current event is committed before invoking 1283 - * those triggers. To do that, the trigger invocation is split 1284 - * in two - the first part checks the filter using the current 1285 - * trace record; if a command has the @post_trigger flag set, it 1286 - * sets a bit for itself in the return value, otherwise it 1287 - * directly invokes the trigger. Once all commands have been 1288 - * either invoked or set their return flag, the current record is 1289 - * either committed or discarded. At that point, if any commands 1290 - * have deferred their triggers, those commands are finally 1291 - * invoked following the close of the current event. In other 1292 - * words, if the event_trigger_ops @func() probe implementation 1293 - * itself logs to the trace buffer, this flag should be set, 1294 - * otherwise it can be left unspecified. 1246 + * @flags: See the enum event_command_flags below. 1295 1247 * 1296 - * All the methods below, except for @set_filter(), must be 1297 - * implemented. 1248 + * All the methods below, except for @set_filter() and @unreg_all(), 1249 + * must be implemented. 1298 1250 * 1299 1251 * @func: The callback function responsible for parsing and 1300 1252 * registering the trigger written to the 'trigger' file by the ··· 1302 1288 * This is usually implemented by the generic utility function 1303 1289 * @unregister_trigger() (see trace_event_triggers.c). 1304 1290 * 1291 + * @unreg_all: An optional function called to remove all the triggers 1292 + * from the list of triggers associated with the event. Called 1293 + * when a trigger file is opened in truncate mode. 1294 + * 1305 1295 * @set_filter: An optional function called to parse and set a filter 1306 1296 * for the trigger. If no @set_filter() method is set for the 1307 1297 * event command, filters set by the user for the command will be ··· 1319 1301 struct list_head list; 1320 1302 char *name; 1321 1303 enum event_trigger_type trigger_type; 1322 - bool post_trigger; 1304 + int flags; 1323 1305 int (*func)(struct event_command *cmd_ops, 1324 1306 struct trace_event_file *file, 1325 1307 char *glob, char *cmd, char *params); ··· 1331 1313 struct event_trigger_ops *ops, 1332 1314 struct event_trigger_data *data, 1333 1315 struct trace_event_file *file); 1316 + void (*unreg_all)(struct trace_event_file *file); 1334 1317 int (*set_filter)(char *filter_str, 1335 1318 struct event_trigger_data *data, 1336 1319 struct trace_event_file *file); 1337 1320 struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param); 1338 1321 }; 1322 + 1323 + /** 1324 + * enum event_command_flags - flags for struct event_command 1325 + * 1326 + * @POST_TRIGGER: A flag that says whether or not this command needs 1327 + * to have its action delayed until after the current event has 1328 + * been closed. Some triggers need to avoid being invoked while 1329 + * an event is currently in the process of being logged, since 1330 + * the trigger may itself log data into the trace buffer. Thus 1331 + * we make sure the current event is committed before invoking 1332 + * those triggers. To do that, the trigger invocation is split 1333 + * in two - the first part checks the filter using the current 1334 + * trace record; if a command has the @post_trigger flag set, it 1335 + * sets a bit for itself in the return value, otherwise it 1336 + * directly invokes the trigger. Once all commands have been 1337 + * either invoked or set their return flag, the current record is 1338 + * either committed or discarded. At that point, if any commands 1339 + * have deferred their triggers, those commands are finally 1340 + * invoked following the close of the current event. In other 1341 + * words, if the event_trigger_ops @func() probe implementation 1342 + * itself logs to the trace buffer, this flag should be set, 1343 + * otherwise it can be left unspecified. 1344 + * 1345 + * @NEEDS_REC: A flag that says whether or not this command needs 1346 + * access to the trace record in order to perform its function, 1347 + * regardless of whether or not it has a filter associated with 1348 + * it (filters make a trigger require access to the trace record 1349 + * but are not always present). 1350 + */ 1351 + enum event_command_flags { 1352 + EVENT_CMD_FL_POST_TRIGGER = 1, 1353 + EVENT_CMD_FL_NEEDS_REC = 2, 1354 + }; 1355 + 1356 + static inline bool event_command_post_trigger(struct event_command *cmd_ops) 1357 + { 1358 + return cmd_ops->flags & EVENT_CMD_FL_POST_TRIGGER; 1359 + } 1360 + 1361 + static inline bool event_command_needs_rec(struct event_command *cmd_ops) 1362 + { 1363 + return cmd_ops->flags & EVENT_CMD_FL_NEEDS_REC; 1364 + } 1339 1365 1340 1366 extern int trace_event_enable_disable(struct trace_event_file *file, 1341 1367 int enable, int soft_disable); ··· 1427 1365 1428 1366 #ifdef CONFIG_FTRACE_SYSCALLS 1429 1367 void init_ftrace_syscalls(void); 1368 + const char *get_syscall_name(int syscall); 1430 1369 #else 1431 1370 static inline void init_ftrace_syscalls(void) { } 1371 + static inline const char *get_syscall_name(int syscall) 1372 + { 1373 + return NULL; 1374 + } 1432 1375 #endif 1433 1376 1434 1377 #ifdef CONFIG_EVENT_TRACING
-12
kernel/trace/trace_events_filter.c
··· 961 961 return FILTER_OTHER; 962 962 } 963 963 964 - static bool is_function_field(struct ftrace_event_field *field) 965 - { 966 - return field->filter_type == FILTER_TRACE_FN; 967 - } 968 - 969 - static bool is_string_field(struct ftrace_event_field *field) 970 - { 971 - return field->filter_type == FILTER_DYN_STRING || 972 - field->filter_type == FILTER_STATIC_STRING || 973 - field->filter_type == FILTER_PTR_STRING; 974 - } 975 - 976 964 static bool is_legal_op(struct ftrace_event_field *field, int op) 977 965 { 978 966 if (is_string_field(field) &&
+53 -35
kernel/trace/trace_events_trigger.c
··· 28 28 static LIST_HEAD(trigger_commands); 29 29 static DEFINE_MUTEX(trigger_cmd_mutex); 30 30 31 - static void 32 - trigger_data_free(struct event_trigger_data *data) 31 + void trigger_data_free(struct event_trigger_data *data) 33 32 { 34 33 if (data->cmd_ops->set_filter) 35 34 data->cmd_ops->set_filter(NULL, data, NULL); ··· 72 73 return tt; 73 74 74 75 list_for_each_entry_rcu(data, &file->triggers, list) { 76 + if (data->paused) 77 + continue; 75 78 if (!rec) { 76 - data->ops->func(data); 79 + data->ops->func(data, rec); 77 80 continue; 78 81 } 79 82 filter = rcu_dereference_sched(data->filter); 80 83 if (filter && !filter_match_preds(filter, rec)) 81 84 continue; 82 - if (data->cmd_ops->post_trigger) { 85 + if (event_command_post_trigger(data->cmd_ops)) { 83 86 tt |= data->cmd_ops->trigger_type; 84 87 continue; 85 88 } 86 - data->ops->func(data); 89 + data->ops->func(data, rec); 87 90 } 88 91 return tt; 89 92 } ··· 95 94 * event_triggers_post_call - Call 'post_triggers' for a trace event 96 95 * @file: The trace_event_file associated with the event 97 96 * @tt: enum event_trigger_type containing a set bit for each trigger to invoke 97 + * @rec: The trace entry for the event 98 98 * 99 99 * For each trigger associated with an event, invoke the trigger 100 100 * function registered with the associated trigger command, if the ··· 106 104 */ 107 105 void 108 106 event_triggers_post_call(struct trace_event_file *file, 109 - enum event_trigger_type tt) 107 + enum event_trigger_type tt, 108 + void *rec) 110 109 { 111 110 struct event_trigger_data *data; 112 111 113 112 list_for_each_entry_rcu(data, &file->triggers, list) { 113 + if (data->paused) 114 + continue; 114 115 if (data->cmd_ops->trigger_type & tt) 115 - data->ops->func(data); 116 + data->ops->func(data, rec); 116 117 } 117 118 } 118 119 EXPORT_SYMBOL_GPL(event_triggers_post_call); ··· 191 186 if (unlikely(!event_file_data(file))) { 192 187 mutex_unlock(&event_mutex); 193 188 return -ENODEV; 189 + } 190 + 191 + if ((file->f_mode & FMODE_WRITE) && 192 + (file->f_flags & O_TRUNC)) { 193 + struct trace_event_file *event_file; 194 + struct event_command *p; 195 + 196 + event_file = event_file_data(file); 197 + 198 + list_for_each_entry(p, &trigger_commands, list) { 199 + if (p->unreg_all) 200 + p->unreg_all(event_file); 201 + } 194 202 } 195 203 196 204 if (file->f_mode & FMODE_READ) { ··· 324 306 * Currently we only register event commands from __init, so mark this 325 307 * __init too. 326 308 */ 327 - static __init int register_event_command(struct event_command *cmd) 309 + __init int register_event_command(struct event_command *cmd) 328 310 { 329 311 struct event_command *p; 330 312 int ret = 0; ··· 413 395 * 414 396 * Return: 0 on success, errno otherwise 415 397 */ 416 - static int 417 - event_trigger_init(struct event_trigger_ops *ops, 418 - struct event_trigger_data *data) 398 + int event_trigger_init(struct event_trigger_ops *ops, 399 + struct event_trigger_data *data) 419 400 { 420 401 data->ref++; 421 402 return 0; ··· 442 425 trigger_data_free(data); 443 426 } 444 427 445 - static int trace_event_trigger_enable_disable(struct trace_event_file *file, 446 - int trigger_enable) 428 + int trace_event_trigger_enable_disable(struct trace_event_file *file, 429 + int trigger_enable) 447 430 { 448 431 int ret = 0; 449 432 ··· 500 483 * its TRIGGER_COND bit set, otherwise the TRIGGER_COND bit should be 501 484 * cleared. 502 485 */ 503 - static void update_cond_flag(struct trace_event_file *file) 486 + void update_cond_flag(struct trace_event_file *file) 504 487 { 505 488 struct event_trigger_data *data; 506 489 bool set_cond = false; 507 490 508 491 list_for_each_entry_rcu(data, &file->triggers, list) { 509 - if (data->filter || data->cmd_ops->post_trigger) { 492 + if (data->filter || event_command_post_trigger(data->cmd_ops) || 493 + event_command_needs_rec(data->cmd_ops)) { 510 494 set_cond = true; 511 495 break; 512 496 } ··· 578 560 * Usually used directly as the @unreg method in event command 579 561 * implementations. 580 562 */ 581 - static void unregister_trigger(char *glob, struct event_trigger_ops *ops, 582 - struct event_trigger_data *test, 583 - struct trace_event_file *file) 563 + void unregister_trigger(char *glob, struct event_trigger_ops *ops, 564 + struct event_trigger_data *test, 565 + struct trace_event_file *file) 584 566 { 585 567 struct event_trigger_data *data; 586 568 bool unregistered = false; ··· 714 696 * 715 697 * Return: 0 on success, errno otherwise 716 698 */ 717 - static int set_trigger_filter(char *filter_str, 718 - struct event_trigger_data *trigger_data, 719 - struct trace_event_file *file) 699 + int set_trigger_filter(char *filter_str, 700 + struct event_trigger_data *trigger_data, 701 + struct trace_event_file *file) 720 702 { 721 703 struct event_trigger_data *data = trigger_data; 722 704 struct event_filter *filter = NULL, *tmp; ··· 765 747 } 766 748 767 749 static void 768 - traceon_trigger(struct event_trigger_data *data) 750 + traceon_trigger(struct event_trigger_data *data, void *rec) 769 751 { 770 752 if (tracing_is_on()) 771 753 return; ··· 774 756 } 775 757 776 758 static void 777 - traceon_count_trigger(struct event_trigger_data *data) 759 + traceon_count_trigger(struct event_trigger_data *data, void *rec) 778 760 { 779 761 if (tracing_is_on()) 780 762 return; ··· 789 771 } 790 772 791 773 static void 792 - traceoff_trigger(struct event_trigger_data *data) 774 + traceoff_trigger(struct event_trigger_data *data, void *rec) 793 775 { 794 776 if (!tracing_is_on()) 795 777 return; ··· 798 780 } 799 781 800 782 static void 801 - traceoff_count_trigger(struct event_trigger_data *data) 783 + traceoff_count_trigger(struct event_trigger_data *data, void *rec) 802 784 { 803 785 if (!tracing_is_on()) 804 786 return; ··· 894 876 895 877 #ifdef CONFIG_TRACER_SNAPSHOT 896 878 static void 897 - snapshot_trigger(struct event_trigger_data *data) 879 + snapshot_trigger(struct event_trigger_data *data, void *rec) 898 880 { 899 881 tracing_snapshot(); 900 882 } 901 883 902 884 static void 903 - snapshot_count_trigger(struct event_trigger_data *data) 885 + snapshot_count_trigger(struct event_trigger_data *data, void *rec) 904 886 { 905 887 if (!data->count) 906 888 return; ··· 908 890 if (data->count != -1) 909 891 (data->count)--; 910 892 911 - snapshot_trigger(data); 893 + snapshot_trigger(data, rec); 912 894 } 913 895 914 896 static int ··· 987 969 #define STACK_SKIP 3 988 970 989 971 static void 990 - stacktrace_trigger(struct event_trigger_data *data) 972 + stacktrace_trigger(struct event_trigger_data *data, void *rec) 991 973 { 992 974 trace_dump_stack(STACK_SKIP); 993 975 } 994 976 995 977 static void 996 - stacktrace_count_trigger(struct event_trigger_data *data) 978 + stacktrace_count_trigger(struct event_trigger_data *data, void *rec) 997 979 { 998 980 if (!data->count) 999 981 return; ··· 1001 983 if (data->count != -1) 1002 984 (data->count)--; 1003 985 1004 - stacktrace_trigger(data); 986 + stacktrace_trigger(data, rec); 1005 987 } 1006 988 1007 989 static int ··· 1035 1017 static struct event_command trigger_stacktrace_cmd = { 1036 1018 .name = "stacktrace", 1037 1019 .trigger_type = ETT_STACKTRACE, 1038 - .post_trigger = true, 1020 + .flags = EVENT_CMD_FL_POST_TRIGGER, 1039 1021 .func = event_trigger_callback, 1040 1022 .reg = register_trigger, 1041 1023 .unreg = unregister_trigger, ··· 1072 1054 }; 1073 1055 1074 1056 static void 1075 - event_enable_trigger(struct event_trigger_data *data) 1057 + event_enable_trigger(struct event_trigger_data *data, void *rec) 1076 1058 { 1077 1059 struct enable_trigger_data *enable_data = data->private_data; 1078 1060 ··· 1083 1065 } 1084 1066 1085 1067 static void 1086 - event_enable_count_trigger(struct event_trigger_data *data) 1068 + event_enable_count_trigger(struct event_trigger_data *data, void *rec) 1087 1069 { 1088 1070 struct enable_trigger_data *enable_data = data->private_data; 1089 1071 ··· 1097 1079 if (data->count != -1) 1098 1080 (data->count)--; 1099 1081 1100 - event_enable_trigger(data); 1082 + event_enable_trigger(data, rec); 1101 1083 } 1102 1084 1103 1085 static int
+6
kernel/trace/trace_functions.c
··· 219 219 unregister_ftrace_function(tr->ops); 220 220 } 221 221 222 + static struct tracer function_trace; 223 + 222 224 static int 223 225 func_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set) 224 226 { ··· 228 226 case TRACE_FUNC_OPT_STACK: 229 227 /* do nothing if already set */ 230 228 if (!!set == !!(func_flags.val & TRACE_FUNC_OPT_STACK)) 229 + break; 230 + 231 + /* We can change this flag when not running. */ 232 + if (tr->current_trace != &function_trace) 231 233 break; 232 234 233 235 unregister_ftrace_function(tr->ops);
+6 -3
kernel/trace/trace_irqsoff.c
··· 109 109 return 0; 110 110 111 111 local_save_flags(*flags); 112 - /* slight chance to get a false positive on tracing_cpu */ 113 - if (!irqs_disabled_flags(*flags)) 112 + /* 113 + * Slight chance to get a false positive on tracing_cpu, 114 + * although I'm starting to think there isn't a chance. 115 + * Leave this for now just to be paranoid. 116 + */ 117 + if (!irqs_disabled_flags(*flags) && !preempt_count()) 114 118 return 0; 115 119 116 120 *data = per_cpu_ptr(tr->trace_buffer.data, cpu); ··· 626 622 irqsoff_trace = tr; 627 623 /* make sure that the tracer is visible */ 628 624 smp_wmb(); 629 - tracing_reset_online_cpus(&tr->trace_buffer); 630 625 631 626 ftrace_init_array_ops(tr, irqsoff_tracer_call); 632 627
+2 -2
kernel/trace/trace_nop.c
··· 56 56 } 57 57 58 58 /* It only serves as a signal handler and a callback to 59 - * accept or refuse tthe setting of a flag. 59 + * accept or refuse the setting of a flag. 60 60 * If you don't implement it, then the flag setting will be 61 61 * automatically accepted. 62 62 */ ··· 75 75 76 76 if (bit == TRACE_NOP_OPT_REFUSE) { 77 77 printk(KERN_DEBUG "nop_test_refuse flag set to %d: we refuse." 78 - "Now cat trace_options to see the result\n", 78 + " Now cat trace_options to see the result\n", 79 79 set); 80 80 return -EINVAL; 81 81 }
+7 -3
kernel/trace/trace_output.c
··· 389 389 char irqs_off; 390 390 int hardirq; 391 391 int softirq; 392 + int nmi; 392 393 394 + nmi = entry->flags & TRACE_FLAG_NMI; 393 395 hardirq = entry->flags & TRACE_FLAG_HARDIRQ; 394 396 softirq = entry->flags & TRACE_FLAG_SOFTIRQ; 395 397 ··· 417 415 } 418 416 419 417 hardsoft_irq = 418 + (nmi && hardirq) ? 'Z' : 419 + nmi ? 'z' : 420 420 (hardirq && softirq) ? 'H' : 421 - hardirq ? 'h' : 422 - softirq ? 's' : 423 - '.'; 421 + hardirq ? 'h' : 422 + softirq ? 's' : 423 + '.' ; 424 424 425 425 trace_seq_printf(s, "%c%c%c", 426 426 irqs_off, need_resched, hardsoft_irq);
+3
kernel/trace/trace_printk.c
··· 296 296 const char *str = *fmt; 297 297 int i; 298 298 299 + if (!*fmt) 300 + return 0; 301 + 299 302 seq_printf(m, "0x%lx : \"", *(unsigned long *)fmt); 300 303 301 304 /*
+11
kernel/trace/trace_syscalls.c
··· 106 106 return syscalls_metadata[nr]; 107 107 } 108 108 109 + const char *get_syscall_name(int syscall) 110 + { 111 + struct syscall_metadata *entry; 112 + 113 + entry = syscall_nr_to_meta(syscall); 114 + if (!entry) 115 + return NULL; 116 + 117 + return entry->name; 118 + } 119 + 109 120 static enum print_line_t 110 121 print_syscall_enter(struct trace_iterator *iter, int flags, 111 122 struct trace_event *event)