aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-12-31 14:46:59 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-12-31 14:46:59 -0500
commit495d714ad140e1732e66c45d0409054b24c1a0d6 (patch)
tree373ec6619adea47d848d36f140b32def27164bbd /include
parentf12e840c819bab42621685558a01d3f46ab9a226 (diff)
parent3d739c1f6156c70eb0548aa288dcfbac9e0bd162 (diff)
Merge tag 'trace-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing updates from Steven Rostedt: - Rework of the kprobe/uprobe and synthetic events to consolidate all the dynamic event code. This will make changes in the future easier. - Partial rewrite of the function graph tracing infrastructure. This will allow for multiple users of hooking onto functions to get the callback (return) of the function. This is the ground work for having kprobes and function graph tracer using one code base. - Clean up of the histogram code that will facilitate adding more features to the histograms in the future. - Addition of str_has_prefix() and a few use cases. There currently is a similar function strstart() that is used in a few places, but only returns a bool and not a length. These instances will be removed in the future to use str_has_prefix() instead. - A few other various clean ups as well. * tag 'trace-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (57 commits) tracing: Use the return of str_has_prefix() to remove open coded numbers tracing: Have the historgram use the result of str_has_prefix() for len of prefix tracing: Use str_has_prefix() instead of using fixed sizes tracing: Use str_has_prefix() helper for histogram code string.h: Add str_has_prefix() helper function tracing: Make function ‘ftrace_exports’ static tracing: Simplify printf'ing in seq_print_sym tracing: Avoid -Wformat-nonliteral warning tracing: Merge seq_print_sym_short() and seq_print_sym_offset() tracing: Add hist trigger comments for variable-related fields tracing: Remove hist trigger synth_var_refs tracing: Use hist trigger's var_ref array to destroy var_refs tracing: Remove open-coding of hist trigger var_ref management tracing: Use var_refs[] for hist trigger reference checking tracing: Change strlen to sizeof for hist trigger static strings tracing: Remove unnecessary hist trigger struct field tracing: Fix ftrace_graph_get_ret_stack() to use task and not current seq_buf: Use size_t for len in seq_buf_puts() seq_buf: Make seq_buf_puts() null-terminate the buffer arm64: Use ftrace_graph_get_ret_stack() instead of curr_ret_stack ...
Diffstat (limited to 'include')
-rw-r--r--include/linux/ftrace.h36
-rw-r--r--include/linux/ring_buffer.h4
-rw-r--r--include/linux/string.h20
3 files changed, 38 insertions, 22 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 5c990e891d6a..730876187344 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -389,6 +389,7 @@ enum {
389 FTRACE_UPDATE_TRACE_FUNC = (1 << 2), 389 FTRACE_UPDATE_TRACE_FUNC = (1 << 2),
390 FTRACE_START_FUNC_RET = (1 << 3), 390 FTRACE_START_FUNC_RET = (1 << 3),
391 FTRACE_STOP_FUNC_RET = (1 << 4), 391 FTRACE_STOP_FUNC_RET = (1 << 4),
392 FTRACE_MAY_SLEEP = (1 << 5),
392}; 393};
393 394
394/* 395/*
@@ -752,6 +753,11 @@ typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */
752 753
753#ifdef CONFIG_FUNCTION_GRAPH_TRACER 754#ifdef CONFIG_FUNCTION_GRAPH_TRACER
754 755
756struct fgraph_ops {
757 trace_func_graph_ent_t entryfunc;
758 trace_func_graph_ret_t retfunc;
759};
760
755/* 761/*
756 * Stack of return addresses for functions 762 * Stack of return addresses for functions
757 * of a thread. 763 * of a thread.
@@ -783,6 +789,9 @@ extern int
783function_graph_enter(unsigned long ret, unsigned long func, 789function_graph_enter(unsigned long ret, unsigned long func,
784 unsigned long frame_pointer, unsigned long *retp); 790 unsigned long frame_pointer, unsigned long *retp);
785 791
792struct ftrace_ret_stack *
793ftrace_graph_get_ret_stack(struct task_struct *task, int idx);
794
786unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx, 795unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
787 unsigned long ret, unsigned long *retp); 796 unsigned long ret, unsigned long *retp);
788 797
@@ -793,11 +802,11 @@ unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
793 */ 802 */
794#define __notrace_funcgraph notrace 803#define __notrace_funcgraph notrace
795 804
796#define FTRACE_NOTRACE_DEPTH 65536
797#define FTRACE_RETFUNC_DEPTH 50 805#define FTRACE_RETFUNC_DEPTH 50
798#define FTRACE_RETSTACK_ALLOC_SIZE 32 806#define FTRACE_RETSTACK_ALLOC_SIZE 32
799extern int register_ftrace_graph(trace_func_graph_ret_t retfunc, 807
800 trace_func_graph_ent_t entryfunc); 808extern int register_ftrace_graph(struct fgraph_ops *ops);
809extern void unregister_ftrace_graph(struct fgraph_ops *ops);
801 810
802extern bool ftrace_graph_is_dead(void); 811extern bool ftrace_graph_is_dead(void);
803extern void ftrace_graph_stop(void); 812extern void ftrace_graph_stop(void);
@@ -806,17 +815,10 @@ extern void ftrace_graph_stop(void);
806extern trace_func_graph_ret_t ftrace_graph_return; 815extern trace_func_graph_ret_t ftrace_graph_return;
807extern trace_func_graph_ent_t ftrace_graph_entry; 816extern trace_func_graph_ent_t ftrace_graph_entry;
808 817
809extern void unregister_ftrace_graph(void);
810
811extern void ftrace_graph_init_task(struct task_struct *t); 818extern void ftrace_graph_init_task(struct task_struct *t);
812extern void ftrace_graph_exit_task(struct task_struct *t); 819extern void ftrace_graph_exit_task(struct task_struct *t);
813extern void ftrace_graph_init_idle_task(struct task_struct *t, int cpu); 820extern void ftrace_graph_init_idle_task(struct task_struct *t, int cpu);
814 821
815static inline int task_curr_ret_stack(struct task_struct *t)
816{
817 return t->curr_ret_stack;
818}
819
820static inline void pause_graph_tracing(void) 822static inline void pause_graph_tracing(void)
821{ 823{
822 atomic_inc(&current->tracing_graph_pause); 824 atomic_inc(&current->tracing_graph_pause);
@@ -834,17 +836,9 @@ static inline void ftrace_graph_init_task(struct task_struct *t) { }
834static inline void ftrace_graph_exit_task(struct task_struct *t) { } 836static inline void ftrace_graph_exit_task(struct task_struct *t) { }
835static inline void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) { } 837static inline void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) { }
836 838
837static inline int register_ftrace_graph(trace_func_graph_ret_t retfunc, 839/* Define as macros as fgraph_ops may not be defined */
838 trace_func_graph_ent_t entryfunc) 840#define register_ftrace_graph(ops) ({ -1; })
839{ 841#define unregister_ftrace_graph(ops) do { } while (0)
840 return -1;
841}
842static inline void unregister_ftrace_graph(void) { }
843
844static inline int task_curr_ret_stack(struct task_struct *tsk)
845{
846 return -1;
847}
848 842
849static inline unsigned long 843static inline unsigned long
850ftrace_graph_ret_addr(struct task_struct *task, int *idx, unsigned long ret, 844ftrace_graph_ret_addr(struct task_struct *task, int *idx, unsigned long ret,
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index 0940fda59872..5b9ae62272bb 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -97,7 +97,7 @@ __ring_buffer_alloc(unsigned long size, unsigned flags, struct lock_class_key *k
97 __ring_buffer_alloc((size), (flags), &__key); \ 97 __ring_buffer_alloc((size), (flags), &__key); \
98}) 98})
99 99
100int ring_buffer_wait(struct ring_buffer *buffer, int cpu, bool full); 100int ring_buffer_wait(struct ring_buffer *buffer, int cpu, int full);
101__poll_t ring_buffer_poll_wait(struct ring_buffer *buffer, int cpu, 101__poll_t ring_buffer_poll_wait(struct ring_buffer *buffer, int cpu,
102 struct file *filp, poll_table *poll_table); 102 struct file *filp, poll_table *poll_table);
103 103
@@ -189,6 +189,8 @@ bool ring_buffer_time_stamp_abs(struct ring_buffer *buffer);
189 189
190size_t ring_buffer_page_len(void *page); 190size_t ring_buffer_page_len(void *page);
191 191
192size_t ring_buffer_nr_pages(struct ring_buffer *buffer, int cpu);
193size_t ring_buffer_nr_dirty_pages(struct ring_buffer *buffer, int cpu);
192 194
193void *ring_buffer_alloc_read_page(struct ring_buffer *buffer, int cpu); 195void *ring_buffer_alloc_read_page(struct ring_buffer *buffer, int cpu);
194void ring_buffer_free_read_page(struct ring_buffer *buffer, int cpu, void *data); 196void ring_buffer_free_read_page(struct ring_buffer *buffer, int cpu, void *data);
diff --git a/include/linux/string.h b/include/linux/string.h
index 27d0482e5e05..7927b875f80c 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -456,4 +456,24 @@ static inline void memcpy_and_pad(void *dest, size_t dest_len,
456 memcpy(dest, src, dest_len); 456 memcpy(dest, src, dest_len);
457} 457}
458 458
459/**
460 * str_has_prefix - Test if a string has a given prefix
461 * @str: The string to test
462 * @prefix: The string to see if @str starts with
463 *
464 * A common way to test a prefix of a string is to do:
465 * strncmp(str, prefix, sizeof(prefix) - 1)
466 *
467 * But this can lead to bugs due to typos, or if prefix is a pointer
468 * and not a constant. Instead use str_has_prefix().
469 *
470 * Returns: 0 if @str does not start with @prefix
471 strlen(@prefix) if @str does start with @prefix
472 */
473static __always_inline size_t str_has_prefix(const char *str, const char *prefix)
474{
475 size_t len = strlen(prefix);
476 return strncmp(str, prefix, len) == 0 ? len : 0;
477}
478
459#endif /* _LINUX_STRING_H_ */ 479#endif /* _LINUX_STRING_H_ */