tracing: Fixes for v6.9
Subsystems (3)
Steven Rostedt
maintainercover tracing: Fixes for v6.9
Tracing fixes for 6.9:
- Fix the buffer_percent accounting as it is dependent on three variables:
1) pages_read - number of subbuffers read
2) pages_lost - number of subbuffers lost due to overwrite
3) pages_touched - number of pages that a writer entered These three counters only increment, and to know how many active pages there are on the buffer at any given time, the pages_read and pages_lost are subtracted from pages_touched. But the pages touched was incremented whenever any writer went to the next subbuffer even if it wasn't the only one, so it was incremented more than it should be causing the counter for how many subbuffers currently have content incorrect, which caused the buffer_percent that holds waiters until the ring buffer is filled to a given percentage to wake up early.
- Fix warning of unused functions when PERF_EVENTS is not configured in
- Replace bad tab with space in Kconfig for FTRACE_RECORD_RECURSION_SIZE
- Fix to some kerneldoc function comments in eventfs code.
Arnd Bergmann (1):
tracing: hide unused ftrace_event_id_fops
Prasad Pandit (1):
tracing: Fix FTRACE_RECORD_RECURSION_SIZE Kconfig entry
Steven Rostedt (Google) (1):
ring-buffer: Only update pages_touched when a new page is touched
Yang Li (1):
eventfs: Fix kernel-doc comments to functions
----
fs/tracefs/event_inode.c | 14 ++++++++++---- kernel/trace/Kconfig | 2 +- kernel/trace/ring_buffer.c | 6 +++--- kernel/trace/trace_events.c | 4 ++++ 4 files changed, 18 insertions(+), 8 deletions(-)
Steven Rostedt
maintainerPATCH 1/4 eventfs: Fix kernel-doc comments to functions
From: Yang Li <[email protected]>
This commit fix kernel-doc style comments with complete parameter descriptions for the lookup_file(),lookup_dir_entry() and lookup_file_dentry().
--- fs/tracefs/event_inode.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
fs/tracefs/event_inode.c +10 -4
@@ -336,6 +336,7 @@ static void update_inode_attr(struct dentry *dentry, struct inode *inode,/** * lookup_file - look up a file in the tracefs filesystem +* @parent_ei: Pointer to the eventfs_inode that represents parent of the file * @dentry: the dentry to look up * @mode: the permission that the file should have. * @attr: saved attributes changed by user
@@ -389,6 +390,7 @@ static struct dentry *lookup_file(struct eventfs_inode *parent_ei,/** * lookup_dir_entry - look up a dir in the tracefs filesystem * @dentry: the directory to look up +* @pei: Pointer to the parent eventfs_inode if available * @ei: the eventfs_inode that represents the directory to create * * This function will look up a dentry for a directory represented by
@@ -478,16 +480,20 @@ void eventfs_d_release(struct dentry *dentry)/** * lookup_file_dentry - create a dentry for a file of an eventfs_inode +* @dentry: The parent dentry under which the new file's dentry will be created * @ei: the eventfs_inode that the file will be created under * @idx: the index into the entry_attrs[] of the @ei -* @parent: The parent dentry of the created file. -* @name: The name of the file to create * @mode: The mode of the file. * @data: The data to use to set the inode of the file with on open() * @fops: The fops of the file to be created. * -* Create a dentry for a file of an eventfs_inode @ei and place it into the -* address located at @e_dentry. +* This function creates a dentry for a file associated with an +* eventfs_inode @ei. It uses the entry attributes specified by @idx, +* if available. The file will have the specified @mode and its inode will be +* set up with @data upon open. The file operations will be set to @fops. +* +* Return: Returns a pointer to the newly created file's dentry or an error +* pointer. */ static struct dentry * lookup_file_dentry(struct dentry *dentry,
Signature · 1 line
2.43.0
Steven Rostedt
maintainerPATCH 2/4 tracing: Fix FTRACE_RECORD_RECURSION_SIZE Kconfig entry
In reply to Steven RostedtFrom: Prasad Pandit <[email protected]>
Fix FTRACE_RECORD_RECURSION_SIZE entry, replace tab with a space character. It helps Kconfig parsers to read file without error.
--- kernel/trace/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/Kconfig +1 -1
@@ -965,7 +965,7 @@ config FTRACE_RECORD_RECURSION config FTRACE_RECORD_RECURSION_SIZE int "Max number of recursed functions to record" - default 128 + default 128 depends on FTRACE_RECORD_RECURSION help This defines the limit of number of functions that can be
Signature · 1 line
2.43.0
Steven Rostedt
maintainerPATCH 3/4 tracing: hide unused ftrace_event_id_fops
In reply to Steven RostedtFrom: Arnd Bergmann <[email protected]>
When CONFIG_PERF_EVENTS, a 'make W=1' build produces a warning about the unused ftrace_event_id_fops variable:
kernel/trace/trace_events.c:2155:37: error: 'ftrace_event_id_fops' defined but not used [-Werror=unused-const-variable=]
2155 | static const struct file_operations ftrace_event_id_fops = {
Hide this in the same #ifdef as the reference to it.
--- kernel/trace/trace_events.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/trace/trace_events.c +4 -0
@@ -1670,6 +1670,7 @@ static int trace_format_open(struct inode *inode, struct file *file)return 0 ; } +#ifdef CONFIG_PERF_EVENTS static ssize_t event_id_read (struct file *filp,char __user *ubuf,size_t cnt,loff_t *ppos) {
@@ -1684,6 +1685,7 @@ event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)return simple_read_from_buffer (ubuf, cnt, ppos, buf, len); } +#endif static ssize_t event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
@@ -2152,10 +2154,12 @@ static const struct file_operations ftrace_event_format_fops = { .release = seq_release, }; +#ifdef CONFIG_PERF_EVENTS static const struct file_operations ftrace_event_id_fops = { .read = event_id_read, .llseek = default_llseek, }; +#endif static const struct file_operations ftrace_event_filter_fops = { .open = tracing_open_file_tr,
Signature · 1 line
2.43.0
Steven Rostedt
maintainerPATCH 4/4 ring-buffer: Only update pages_touched when a new page is touched
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
The "buffer_percent" logic that is used by the ring buffer splice code to only wake up the tasks when there's no data after the buffer is filled to the percentage of the "buffer_percent" file is dependent on three variables that determine the amount of data that is in the ring buffer:
1) pages_read - incremented whenever a new sub-buffer is consumed
2) pages_lost - incremented every time a writer overwrites a sub-buffer
3) pages_touched - incremented when a write goes to a new sub-buffer
The percentage is the calculation of:
(pages_touched - (pages_lost + pages_read)) / nr_pages
Basically, the amount of data is the total number of sub-bufs that have been touched, minus the number of sub-bufs lost and sub-bufs consumed. This is divided by the total count to give the buffer percentage. When the percentage is greater than the value in the "buffer_percent" file, it wakes up splice readers waiting for that amount.
It was observed that over time, the amount read from the splice was constantly decreasing the longer the trace was running. That is, if one asked for 60%, it would read over 60% when it first starts tracing, but then it would be woken up at under 60% and would slowly decrease the amount of data read after being woken up, where the amount becomes much less than the buffer percent.
This was due to an accounting of the pages_touched incrementation. This value is incremented whenever a writer transfers to a new sub-buffer. But the place where it was incremented was incorrect. If a writer overflowed the current sub-buffer it would go to the next one. If it gets preempted by an interrupt at that time, and the interrupt performs a trace, it too will end up going to the next sub-buffer. But only one should increment the counter. Unfortunately, that was not the case.
Change the cmpxchg() that does the real switch of the tail-page into a try_cmpxchg(), and on success, perform the increment of pages_touched. This will only increment the counter once for when the writer moves to a new sub-buffer, and not when there's a race and is incremented for when a writer and its preempting writer both move to the same new sub-buffer.
--- kernel/trace/ring_buffer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/ring_buffer.c +3 -3
@@ -1393,7 +1393,6 @@ static void rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer, old_write =local_add_return (RB_WRITE_INTCNT , &next_page->write); old_entries =local_add_return (RB_WRITE_INTCNT , &next_page->entries); -local_inc (&cpu_buffer->pages_touched);/* * Just make sure we have seen our old_write and synchronize * with any interrupts that come in.
@@ -1430,8 +1429,9 @@ static void rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,*/ local_set (&next_page->page->commit,0 ); -/* Again, either we update tail_page or an interrupt does */ - (void )cmpxchg (&cpu_buffer->tail_page, tail_page, next_page); +/* Either we update tail_page or an interrupt does */ +if (try_cmpxchg (&cpu_buffer->tail_page, &tail_page, next_page)) +local_inc (&cpu_buffer->pages_touched); } }
Signature · 1 line
2.43.0