tracing: Updates for 6.6
Linus,
[ Note, there's a minor conflict which should be fixed by:
mutex_lock(&trace_types_lock);
- if (unlikely(tr->current_trace && iter->trace->name != tr->current_trace->name)) {
+ if (unlikely(tr->current_trace != iter->trace))
+ /* Close iter->trace before switching to the new current tracer */
+ if (iter->trace->close)
+ iter->trace->close(iter);
- *iter->trace = *tr->current_trace;
+ iter->trace = tr->current_trace;
+ /* Reopen the new current tracer */
+ if (iter->trace->open)
+ iter->trace->open(iter);
+ }
mutex_unlock(&trace_types_lock);]
Tracing updates for 6.6:
User visible changes:
- Added a way to easier filter with cpumasks:
# echo 'cpumask & CPUS{17-42}' > /sys/kernel/tracing/events/ipi_send_cpumask/filter - Show actual size of ring buffer after modifying the ring buffer size via buffer_size_kb. Currently it just returns what was written, but the actual size rounds up to the sub buffer size. Show that real size instead.
Major changes:
- Added "eventfs". This is the code that handles the inodes and dentries of tracefs/events directory. As there are thousands of events, and each event has several inodes and dentries that currently exist even when tracing is never used, they take up precious memory. Instead, eventfs will allocate the inodes and dentries in a JIT way (similar to what procfs does). There is now metadata that handles the events and subdirectories, and will create the inodes and dentries when they are used.
Note, I also have patches that remove the subdirectory meta data, but will wait till the next merge window before applying them. It's a little more complex, and I want to make sure the dynamic code works properly before adding more complexity, making it easier to revert if need be.
Minor changes:
- Optimization to user event list traversal.
- Remove intermediate permission of tracefs files (note the intermediate permission removes all access to the files so it is not a security concern, but just a clean up.)
- Add the complex fix to FORTIFY_SOURCE to the kernel stack event logic.
- Other minor clean ups.
Please pull the latest trace-v6.6 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace-v6.6
Tag SHA1: 1065c0c85cfdb141b5cc2064b6e379fd564f0779 Head SHA1: 8c96b70171584f38940eb2ba65b84eee38b549ba
Ajay Kaher (9):
eventfs: Implement tracefs_inode_cache
tracefs: Rename and export some tracefs functions
eventfs: Implement eventfs dir creation functions
eventfs: Implement eventfs file add functions
eventfs: Implement eventfs lookup, read, open functions
eventfs: Implement functions to create files and dirs when accessed
eventfs: Implement removal of meta data from eventfs
eventfs: Move tracing/events to eventfs
test: ftrace: Fix kprobe test for eventfs
Eric Vaughn (1):
tracing/user_events: Optimize safe list traversals
Sishuai Gong (1):
tracefs: Avoid changing i_mode to a temp value
Steven Rostedt (Google) (5):
tracing: Add back FORTIFY_SOURCE logic to kernel_stack event structure
tracing: Remove unnecessary copying of tr->current_trace
tracing: Add free_trace_iter_content() helper function
tracing: Require all trace events to have a TRACE_SYSTEM
tracefs: Remove kerneldoc from struct eventfs_file
Uros Bizjak (1):
ring_buffer: Use try_cmpxchg instead of cmpxchg
Valentin Schneider (9):
tracing/filters: Dynamically allocate filter_pred.regex
tracing/filters: Enable filtering a cpumask field by another cpumask tracing/filters: Enable filtering a scalar field by a cpumask tracing/filters: Enable filtering the CPU common field by a cpumask tracing/filters: Optimise cpumask vs cpumask filtering when user mask is a single CPU tracing/filters: Optimise scalar vs cpumask filtering when the user mask is a single CPU tracing/filters: Optimise CPU vs cpumask filtering when the user mask is a single CPU tracing/filters: Further optimise scalar vs cpumask comparison tracing/filters: Document cpumask filtering
Yue Haibing (1):
tracing: Remove unused function declarations
Zhang Zekun (1):
ftrace: Remove empty declaration ftrace_enable_daemon() and ftrace_disable_daemon()
Zheng Yejian (1):
tracing: Set actual size after ring buffer resize
----
Documentation/trace/events.rst | 14 + fs/tracefs/Makefile | 1 + fs/tracefs/event_inode.c | 807 +++++++++++++++++++++ fs/tracefs/inode.c | 157 +++- fs/tracefs/internal.h | 29 + include/linux/ftrace.h | 5 - include/linux/trace_events.h | 2 + include/linux/tracefs.h | 23 + kernel/trace/ring_buffer.c | 20 +- kernel/trace/trace.c | 99 +-- kernel/trace/trace.h | 14 +- kernel/trace/trace_entries.h | 2 +- kernel/trace/trace_events.c | 76 +- kernel/trace/trace_events_filter.c | 302 +++++++- kernel/trace/trace_events_user.c | 15 +- kernel/trace/trace_export.c | 9 + .../ftrace/test.d/kprobe/kprobe_args_char.tc | 9 +- .../ftrace/test.d/kprobe/kprobe_args_string.tc | 9 +- 18 files changed, 1424 insertions(+), 169 deletions(-) create mode 100644 fs/tracefs/event_inode.c create mode 100644 fs/tracefs/internal.h
---------------------------
Hi,
Quoted 18 lines · Steven Rostedt
Linus,
[ Note, there's a minor conflict which should be fixed by:
mutex_lock(&trace_types_lock);(quoted diff) +2
-2- if (unlikely(tr->current_trace && iter->trace->name != tr->current_trace->name)) { + if (unlikely(tr->current_trace != iter->trace)) + /* Close iter->trace before switching to the new current tracer */ + if (iter->trace->close) + iter->trace->close(iter); - *iter->trace = *tr->current_trace; + iter->trace = tr->current_trace; + /* Reopen the new current tracer */ + if (iter->trace->open) + iter->trace->open(iter); + } mutex_unlock(&trace_types_lock);]
Quoted 7 lines
Tracing updates for 6.6:
User visible changes:
- Added a way to easier filter with cpumasks:
# echo 'cpumask & CPUS{17-42}' > /sys/kernel/tracing/events/ipi_send_cpumask/filter
It looks like the patches included are from v2 of [1], which still had some (small) issues to fix. I have addressed these in [2], but I haven't sent this out yet as I'm still working on the context_tracking/vmalloc part of the series.
I'm happy to send just the tracing bits, if that helps - or just send the deltas as separate fixes, whatever makes it easier.
Apologies for not bringing this up when the patches were picked up in [3], I've only just come back from PTO/moving abroad and have started catching up.
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://gitlab.com/vschneid/linux/-/commits/redhat/isolirq/defer/v3-wip
[3]: https://lore.kernel.org/all/[email protected]/
For reference, the git range-diff between the patches in tracing/trace/for-next and those in my v3 is appended below (pure changelog diffs removed)
---
2: 39f7c41c908bc ! 2: e58d79bd79da2 tracing/filters: Enable filtering a cpumask field by another cpumask
## include/linux/trace_events.h ##
@@ include/linux/trace_events.h: enum {
@@ kernel/trace/trace_events_filter.c: static void filter_free_subsystem_filters(st
+ return FILTER_DYN_STRING;
+ if (strstr(type, "cpumask_t"))
+ return FILTER_CPUMASK;
-+ }
++ }
if (strstr(type, "__rel_loc") && strstr(type, "char"))
return FILTER_RDYN_STRING;
@@ kernel/trace/trace_events_filter.c: static int parse_pred(const char *str, void
+ maskstart = i;
+
+ /* Walk the cpulist until closing } */
-+ for (; str[i] && str[i] != '}'; i++);
++ for (; str[i] && str[i] != '}'; i++)
++ ;
++
+ if (str[i] != '}') {
+ parse_error(pe, FILT_ERR_MISSING_BRACE_CLOSE, pos + i);
+ goto err_free;
@@ kernel/trace/trace_events_filter.c: static int parse_pred(const char *str, void
+
+ /* Copy the cpulist between { and } */
+ tmp = kmalloc((i - maskstart) + 1, GFP_KERNEL);
-+ strscpy(tmp, str + maskstart, (i - maskstart) + 1);
++ if (!tmp)
++ goto err_mem;
+
++ strscpy(tmp, str + maskstart, (i - maskstart) + 1);
+ pred->mask = kzalloc(cpumask_size(), GFP_KERNEL);
-+ if (!pred->mask)
++ if (!pred->mask) {
++ kfree(tmp);
+ goto err_mem;
++ }
+
+ /* Now parse it */
+ if (cpulist_parse(tmp, pred->mask)) {
++ kfree(tmp);
+ parse_error(pe, FILT_ERR_INVALID_CPULIST, pos + i);
+ goto err_free;
+ }
++ kfree(tmp);
+
+ /* Move along */
+ i++;
5: fe4fa4ec9b464 ! 5: 03eefdab555b2 tracing/filters: Optimise cpumask vs cpumask filtering when user mask is a single CPU
## kernel/trace/trace_events_filter.c ##
@@ kernel/trace/trace_events_filter.c: enum filter_pred_fn {
@@ kernel/trace/trace_events_filter.c: static int parse_pred(const char *str, void
+ if (single && field->filter_type == FILTER_CPUMASK) {
+ pred->val = cpumask_first(pred->mask);
+ kfree(pred->mask);
++ pred->mask = NULL;
+ }
+
if (field->filter_type == FILTER_CPUMASK) {
6: ca77dd8ce4658 ! 6: f75aee048ce5a tracing/filters: Optimise scalar vs cpumask filtering when the user mask is a single CPU
@@ Commit message
## kernel/trace/trace_events_filter.c ##
@@ kernel/trace/trace_events_filter.c: static int parse_pred(const char *str, void *data,
@@ kernel/trace/trace_events_filter.c: static int parse_pred(const char *str, void
+ if (single && field->filter_type != FILTER_CPU) {
pred->val = cpumask_first(pred->mask);
kfree(pred->mask);
- }
+ pred->mask = NULL;
@@ kernel/trace/trace_events_filter.c: static int parse_pred(const char *str, void *data,
FILTER_PRED_FN_CPUMASK;
} else if (field->filter_type == FILTER_CPU) {
pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK;
+ } else if (single) {
-+ pred->op = pred->op == OP_BAND ? OP_EQ : pred->op;
++ if (pred->op == OP_BAND)
++ pred->op = OP_EQ;
++
+ pred->fn_num = select_comparison_fn(pred->op, field->size, false);
+ if (pred->op == OP_NE)
+ pred->not = 1;
7: 1cffbe6c62f10 ! 7: 6a78ed47b0b06 tracing/filters: Optimise CPU vs cpumask filtering when the user mask is a single CPU
## kernel/trace/trace_events_filter.c ##
@@ kernel/trace/trace_events_filter.c: static int parse_pred(const char *str, void *data,
@@ kernel/trace/trace_events_filter.c: static int parse_pred(const char *str, void
+ if (single) {
pred->val = cpumask_first(pred->mask);
kfree(pred->mask);
- }
+ pred->mask = NULL;
@@ kernel/trace/trace_events_filter.c: static int parse_pred(const char *str, void *data,
FILTER_PRED_FN_CPUMASK_CPU :
FILTER_PRED_FN_CPUMASK;
} else if (field->filter_type == FILTER_CPU) {
- pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK;
+ if (single) {
-+ pred->op = pred->op == OP_BAND ? OP_EQ : pred->op;
++ if (pred->op == OP_BAND)
++ pred->op = OP_EQ;
++
+ pred->fn_num = FILTER_PRED_FN_CPU;
+ } else {
+ pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK;
+ }
} else if (single) {
- pred->op = pred->op == OP_BAND ? OP_EQ : pred->op;
- pred->fn_num = select_comparison_fn(pred->op, field->size, false);
+ if (pred->op == OP_BAND)
+ pred->op = OP_EQ;Quoted 8 lines · On Fri, 01 Sep 2023 11:20:31 +0200 Valentin Schneider <[email protected]>…
Quoted 7 lines
Tracing updates for 6.6:
User visible changes:
- Added a way to easier filter with cpumasks:
# echo 'cpumask & CPUS{17-42}' > /sys/kernel/tracing/events/ipi_send_cpumask/filter
Quoted 7 lines
It looks like the patches included are from v2 of [1], which still had some (small) issues to fix. I have addressed these in [2], but I haven't sent this out yet as I'm still working on the context_tracking/vmalloc part of the series.
I'm happy to send just the tracing bits, if that helps - or just send the deltas as separate fixes, whatever makes it easier.
I put these patches into linux-next for a while, so I'm not going to rebase them. Can you send delta patches on top of this. This shouldn't stop this pull request.
Quoted 4 lines
Apologies for not bringing this up when the patches were picked up in [3], I've only just come back from PTO/moving abroad and have started catching up.
I'm still trying to get home from my PTO, which I spent in Tampa and was suppose to fly home on Tuesday. But they closed the airport in preparation for Idalia, which forced my wife and I to hunker down in a hotel room for the last few days :-p (we are now in a to hotel room in Syracuse, and are about to drive home).
-- Steve
Quoted 15 lines · Steven Rostedt
Quoted 13 lines · On Fri, 01 Sep 2023 11:20:31 +0200 Valentin Schneider <[email protected]>…
Quoted 7 lines
Tracing updates for 6.6:
User visible changes:
- Added a way to easier filter with cpumasks:
# echo 'cpumask & CPUS{17-42}' > /sys/kernel/tracing/events/ipi_send_cpumask/filterIt looks like the patches included are from v2 of [1], which still had some (small) issues to fix. I have addressed these in [2], but I haven't sent this out yet as I'm still working on the context_tracking/vmalloc part of the series.
Quoted 7 lines
Quoted 2 lines
I'm happy to send just the tracing bits, if that helps - or just send the deltas as separate fixes, whatever makes it easier.
I put these patches into linux-next for a while, so I'm not going to rebase them. Can you send delta patches on top of this. This shouldn't stop this pull request.
Noted, I'll get on with this.
Quoted 11 lines
Quoted 4 lines
Apologies for not bringing this up when the patches were picked up in [3], I've only just come back from PTO/moving abroad and have started catching up.
I'm still trying to get home from my PTO, which I spent in Tampa and was suppose to fly home on Tuesday. But they closed the airport in preparation for Idalia, which forced my wife and I to hunker down in a hotel room for the last few days :-p (we are now in a to hotel room in Syracuse, and are about to drive home).
Sounds like you've had an "interesting" journey :)
Quoted 1 line
-- Steve
The pull request you sent on Thu, 31 Aug 2023 11:56:35 -0400:
The pull request you sent on Thu, 31 Aug 2023 11:56:35 -0400:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.gittrace-v6.6
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/34232fcfe9a383bea802af682baae5c99f22376c
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html