tracing: Some more updates for 5.5
Steven Rostedt
maintainercover tracing: Some more updates for 5.5
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next
Head SHA1: 128161f47bc3797b0d068da13e311770685d6e4f
Artem Bityutskiy (1):
tracing: Increase SYNTH_FIELDS_MAX for synthetic_events
Colin Ian King (1):
ftrace/selftests: Fix spelling mistake "wakeing" -> "waking"
Steven Rostedt (VMware) (5):
ftrace: Add modify_ftrace_direct()
ftrace/samples: Add a sample module that implements modify_ftrace_direct()
ftrace: Fix accounting bug with direct->count in register_ftrace_direct()
ftrace: Add another check for match in register_ftrace_direct()
ftrace: Add helper find_direct_entry() to consolidate code
----
include/linux/ftrace.h | 6 ++ kernel/trace/ftrace.c | 119 +++++++++++++++++---- kernel/trace/trace_events_hist.c | 2 +- samples/ftrace/Makefile | 1 + samples/ftrace/ftrace-direct-modify.c | 88 +++++++++++++++ samples/ftrace/ftrace-direct.c | 2 +- .../ftrace/test.d/direct/ftrace-direct.tc | 2 +- .../ftrace/test.d/direct/kprobe-direct.tc | 4 +- 8 files changed, 200 insertions(+), 24 deletions(-) create mode 100644 samples/ftrace/ftrace-direct-modify.c
Steven Rostedt
maintainerPATCH 6/7 ftrace: Add another check for match in register_ftrace_direct()
From: "Steven Rostedt (VMware)" <[email protected]>
As an instruction pointer passed into register_ftrace_direct() may just exist on the ftrace call site, but may not be the start of the call site itself, register_ftrace_direct() still needs to update test if a direct call exists on the normalized site, as only one direct call is allowed at any one time.
--- kernel/trace/ftrace.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/trace/ftrace.c +6 -1
@@ -5030,7 +5030,12 @@ int register_ftrace_direct(unsigned long ip, unsigned long addr) goto out_unlock;/* Make sure the ip points to the exact record */ - ip = rec->ip; +if (ip != rec->ip) { + ip = rec->ip; +/* Need to check this ip for a direct. */ +if (find_rec_direct (ip)) + goto out_unlock; + } ret = -ENOMEM ; if (ftrace_hash_empty(direct_functions) ||
Signature · 1 line
2.24.0
Steven Rostedt
maintainerPATCH 7/7 ftrace: Add helper find_direct_entry() to consolidate code
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
Both unregister_ftrace_direct() and modify_ftrace_direct() needs to normalize the ip passed in to match the rec->ip, as it is acceptable to have the ip on the ftrace call site but not the start. There are also common validity checks with the record found by the ip, these should be done for both unregister_ftrace_direct() and modify_ftrace_direct().
--- kernel/trace/ftrace.c | 59 +++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 30 deletions(-)
kernel/trace/ftrace.c +29 -30
@@ -5112,30 +5112,40 @@ int register_ftrace_direct(unsigned long ip, unsigned long addr) }EXPORT_SYMBOL_GPL (register_ftrace_direct); -int unregister_ftrace_direct (unsigned long ip,unsigned long addr) +static struct ftrace_func_entry *find_direct_entry (unsigned long *ip) {struct ftrace_func_entry *entry; -struct ftrace_direct_func *direct;struct dyn_ftrace *rec; -int ret = -ENODEV ; -mutex_lock (&direct_mutex); + rec =lookup_rec (*ip, *ip); +if (!rec) +return NULL ; - entry =__ftrace_lookup_ip (direct_functions, ip); + entry =__ftrace_lookup_ip (direct_functions, rec->ip);if (!entry) { -/* OK if it is off by a little */ - rec =lookup_rec (ip, ip); -if (!rec || rec->ip == ip) - goto out_unlock; +WARN_ON (rec->flags &FTRACE_FL_DIRECT ); +return NULL ; + } - entry =__ftrace_lookup_ip (direct_functions, rec->ip); -if (!entry) { -WARN_ON (rec->flags &FTRACE_FL_DIRECT ); - goto out_unlock; - } +WARN_ON (!(rec->flags &FTRACE_FL_DIRECT )); -WARN_ON (!(rec->flags &FTRACE_FL_DIRECT )); - } +/* Passed in ip just needs to be on the call site */ + *ip = rec->ip; + +return entry; +} + +int unregister_ftrace_direct (unsigned long ip,unsigned long addr) +{ +struct ftrace_direct_func *direct; +struct ftrace_func_entry *entry; +int ret = -ENODEV ; + +mutex_lock (&direct_mutex); + + entry =find_direct_entry (&ip); +if (!entry) + goto out_unlock;if (direct_functions->count ==1 )unregister_ftrace_function (&direct_ops);
@@ -5187,24 +5197,13 @@ int modify_ftrace_direct(unsigned long ip, unsigned long old_addr, unsigned long new_addr) {struct ftrace_func_entry *entry; -struct dyn_ftrace *rec;int ret = -ENODEV ;mutex_lock (&direct_mutex); - entry =__ftrace_lookup_ip (direct_functions, ip); -if (!entry) { -/* OK if it is off by a little */ - rec =lookup_rec (ip, ip); -if (!rec || rec->ip == ip) - goto out_unlock; - - entry =__ftrace_lookup_ip (direct_functions, rec->ip); -if (!entry) - goto out_unlock; - ip = rec->ip; -WARN_ON (!(rec->flags &FTRACE_FL_DIRECT )); - } + entry =find_direct_entry (&ip); +if (!entry) + goto out_unlock; ret = -EINVAL ;if (entry->direct != old_addr)
Signature · 1 line
2.24.0
Steven Rostedt
maintainerPATCH 3/7 tracing: Increase SYNTH_FIELDS_MAX for synthetic_events
In reply to Steven RostedtFrom: Artem Bityutskiy <[email protected]>
Increase the maximum allowed count of synthetic event fields from 16 to 32 in order to allow for larger-than-usual events.
--- kernel/trace/trace_events_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +1 -1
@@ -23,7 +23,7 @@#include "trace_dynevent.h" #define SYNTH_SYSTEM "synthetic" -#define SYNTH_FIELDS_MAX 16 +#define SYNTH_FIELDS_MAX 32#define STR_VAR_LEN_MAX 32/* must be multiple of sizeof(u64) */
Signature · 1 line
2.24.0
Steven Rostedt
maintainerPATCH 4/7 ftrace/selftests: Fix spelling mistake "wakeing" -> "waking"
In reply to Steven RostedtFrom: Colin Ian King <[email protected]>
There is a spelling mistake in a trace_printk message. As well as in the selftests that search for this string.
--- samples/ftrace/ftrace-direct.c | 2 +- tools/testing/selftests/ftrace/test.d/direct/ftrace-direct.tc | 2 +- tools/testing/selftests/ftrace/test.d/direct/kprobe-direct.tc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
samples/ftrace/ftrace-direct.c +1 -1
@@ -6,7 +6,7 @@void my_direct_func (struct task_struct *p) { -trace_printk ("wakeing up %s-%d\n" , p->comm, p->pid); +trace_printk ("waking up %s-%d\n" , p->comm, p->pid); }extern void my_tramp (void *);
tools/testing/selftests/ftrace/test.d/direct/ftrace-direct.tc +1 -1
@@ -11,7 +11,7 @@ fi echo "Let the module run a little" sleep 1 -grep -q "my_direct_func: wakeing up" trace +grep -q "my_direct_func: waking up" trace rmmod ftrace-direct
tools/testing/selftests/ftrace/test.d/direct/kprobe-direct.tc +2 -2
@@ -16,7 +16,7 @@ fi echo "Let the module run a little" sleep 1 -grep -q "my_direct_func: wakeing up" trace +grep -q "my_direct_func: waking up" trace rmmod ftrace-direct
@@ -26,7 +26,7 @@ start_direct() { echo > trace modprobe ftrace-direct sleep 1 - grep -q "my_direct_func: wakeing up" trace + grep -q "my_direct_func: waking up" trace } stop_direct() {
Signature · 1 line
2.24.0
Steven Rostedt
maintainerPATCH 1/7 ftrace: Add modify_ftrace_direct()
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
Add a new function modify_ftrace_direct() that will allow a user to update an existing direct caller to a new trampoline, without missing hits due to unregistering one and then adding another.
--- include/linux/ftrace.h | 6 ++++ kernel/trace/ftrace.c | 78 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+)
include/linux/ftrace.h +6 -0
@@ -250,6 +250,7 @@ static inline void ftrace_free_mem(struct module *mod, void *start, void *end) {extern int ftrace_direct_func_count;int register_ftrace_direct (unsigned long ip,unsigned long addr);int unregister_ftrace_direct (unsigned long ip,unsigned long addr); +int modify_ftrace_direct (unsigned long ip,unsigned long old_addr,unsigned long new_addr);struct ftrace_direct_func *ftrace_find_direct_func (unsigned long addr);#else # define ftrace_direct_func_count 0
@@ -261,6 +262,11 @@ static inline int unregister_ftrace_direct(unsigned long ip, unsigned long addr) {return -ENODEV ; } +static inline int modify_ftrace_direct (unsigned long ip, +unsigned long old_addr,unsigned long new_addr) +{ +return -ENODEV ; +}static inline struct ftrace_direct_func *ftrace_find_direct_func (unsigned long addr) {return NULL ;
kernel/trace/ftrace.c +78 -0
84 lines not on this page · raw message
Signature · 1 line
2.24.0
Steven Rostedt
maintainerPATCH 2/7 ftrace/samples: Add a sample module that implements modify_ftrace_direct()
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
Add a sample module that tests modify_ftrace_direct(), and this can be used by the selftests as well.
--- samples/ftrace/Makefile | 1 + samples/ftrace/ftrace-direct-modify.c | 88 +++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 samples/ftrace/ftrace-direct-modify.c
samples/ftrace/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_SAMPLE_FTRACE_DIRECT) += ftrace-direct.o obj-$(CONFIG_SAMPLE_FTRACE_DIRECT) += ftrace-direct-too.o +obj-$(CONFIG_SAMPLE_FTRACE_DIRECT) += ftrace-direct-modify.o
samples/ftrace/ftrace-direct-modify.c new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
2.24.0
Steven Rostedt
maintainerPATCH 5/7 ftrace: Fix accounting bug with direct->count in register_ftrace_direct()
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
The direct->count wasn't being updated properly, where it only was updated when the first entry was added, but should be updated every time.
--- kernel/trace/ftrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/trace/ftrace.c +1 -2
@@ -5093,8 +5093,7 @@ int register_ftrace_direct(unsigned long ip, unsigned long addr) ftrace_direct_func_count--; } }else { -if (!direct->count) - direct->count++; + direct->count++; } out_unlock:mutex_unlock (&direct_mutex);
Signature · 1 line
2.24.0