tracing: More updates for 5.13
Subsystems (3)
Steven Rostedt
maintainercover tracing: More updates for 5.13
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next
Head SHA1: ceaaa12904df07d07ea8975abbf04c4d60e46956
Linus Torvalds (1):
ftrace: Store the order of pages allocated in ftrace_page
Steven Rostedt (VMware) (1):
ftrace: Simplify the calculation of page number for ftrace_page->records some more
Wan Jiabing (1):
tracing: Remove duplicate struct declaration in trace_events.h
Yordan Karadzhov (VMware) (1):
tracing: Remove unused argument from "ring_buffer_time_stamp()
----
include/linux/ring_buffer.h | 2 +- include/linux/trace_events.h | 1 - kernel/trace/ftrace.c | 45 +++++++++++++++++++------------------------- kernel/trace/ring_buffer.c | 2 +- kernel/trace/trace.c | 8 ++++---- 5 files changed, 25 insertions(+), 33 deletions(-)
Steven Rostedt
maintainerPATCH 1/4 tracing: Remove duplicate struct declaration in trace_events.h
From: Wan Jiabing <[email protected]>
struct trace_array is declared twice. One has been declared at forward declaration. Remove the duplicate.
--- include/linux/trace_events.h | 1 - 1 file changed, 1 deletion(-)
include/linux/trace_events.h +0 -1
@@ -404,7 +404,6 @@ trace_get_fields(struct trace_event_call *event_call)return event_call->class->get_fields (event_call); } -struct trace_array ;struct trace_subsystem_dir ;enum {
Signature · 1 line
2.30.1
Steven Rostedt
maintainerPATCH 2/4 tracing: Remove unused argument from "ring_buffer_time_stamp()
In reply to Steven RostedtFrom: "Yordan Karadzhov (VMware)" <[email protected]>
The "cpu" parameter is not being used by the function.
--- include/linux/ring_buffer.h | 2 +- kernel/trace/ring_buffer.c | 2 +- kernel/trace/trace.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-)
include/linux/ring_buffer.h +1 -1
@@ -181,7 +181,7 @@ unsigned long ring_buffer_commit_overrun_cpu(struct trace_buffer *buffer, int cpunsigned long ring_buffer_dropped_events_cpu (struct trace_buffer *buffer,int cpu);unsigned long ring_buffer_read_events_cpu (struct trace_buffer *buffer,int cpu); -u64 ring_buffer_time_stamp (struct trace_buffer *buffer,int cpu); +u64 ring_buffer_time_stamp (struct trace_buffer *buffer);void ring_buffer_normalize_time_stamp (struct trace_buffer *buffer,int cpu,u64 *ts); void ring_buffer_set_clock(struct trace_buffer *buffer,
kernel/trace/ring_buffer.c +1 -1
@@ -1080,7 +1080,7 @@ static inline u64 rb_time_stamp(struct trace_buffer *buffer)return ts <<DEBUG_SHIFT ; } -u64 ring_buffer_time_stamp (struct trace_buffer *buffer,int cpu) +u64 ring_buffer_time_stamp (struct trace_buffer *buffer) {u64 time;
kernel/trace/trace.c +4 -4
@@ -771,7 +771,7 @@ static u64 buffer_ftrace_now(struct array_buffer *buf, int cpu)if (!buf->buffer)return trace_clock_local (); - ts =ring_buffer_time_stamp (buf->buffer, cpu); + ts =ring_buffer_time_stamp (buf->buffer);ring_buffer_normalize_time_stamp (buf->buffer, cpu, &ts);return ts;
@@ -7174,7 +7174,7 @@ static int tracing_time_stamp_mode_open(struct inode *inode, struct file *file)u64 tracing_event_time_stamp (struct trace_buffer *buffer,struct ring_buffer_event *rbe) {if (rbe ==this_cpu_read (trace_buffered_event)) -return ring_buffer_time_stamp (buffer,smp_processor_id ()); +return ring_buffer_time_stamp (buffer);return ring_buffer_event_time_stamp (buffer, rbe); }
@@ -8088,7 +8088,7 @@ tracing_stats_read(struct file *filp, char __user *ubuf,trace_seq_printf (s,"oldest event ts: %5llu.%06lu\n" , t, usec_rem); - t =ns2usecs (ring_buffer_time_stamp (trace_buf->buffer, cpu)); + t =ns2usecs (ring_buffer_time_stamp (trace_buf->buffer)); usec_rem =do_div (t,USEC_PER_SEC );trace_seq_printf (s,"now ts: %5llu.%06lu\n" , t, usec_rem); }else {
@@ -8097,7 +8097,7 @@ tracing_stats_read(struct file *filp, char __user *ubuf, ring_buffer_oldest_event_ts(trace_buf->buffer, cpu));trace_seq_printf (s,"now ts: %llu\n" , -ring_buffer_time_stamp (trace_buf->buffer, cpu)); +ring_buffer_time_stamp (trace_buf->buffer)); } cnt =ring_buffer_dropped_events_cpu (trace_buf->buffer, cpu);
Signature · 1 line
2.30.1
Steven Rostedt
maintainerPATCH 3/4 ftrace: Store the order of pages allocated in ftrace_page
In reply to Steven RostedtFrom: Linus Torvalds <[email protected]>
Instead of saving the size of the records field of the ftrace_page, store the order it uses to allocate the pages, as that is what is needed to know in order to free the pages. This simplifies the code.
--- kernel/trace/ftrace.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-)
kernel/trace/ftrace.c +17 -18
@@ -1090,7 +1090,7 @@ struct ftrace_page {struct ftrace_page *next;struct dyn_ftrace *records;int index; -int size; +int order; };#define ENTRY_SIZE sizeof(struct dyn_ftrace)
@@ -3181,7 +3181,7 @@ static int ftrace_allocate_records(struct ftrace_page *pg, int count) ftrace_number_of_groups++; cnt = (PAGE_SIZE << order) /ENTRY_SIZE ; - pg->size = cnt; + pg->order = order;if (cnt > count) cnt = count;
@@ -3194,7 +3194,6 @@ ftrace_allocate_pages(unsigned long num_to_init) {struct ftrace_page *start_pg;struct ftrace_page *pg; -int order;int cnt;if (!num_to_init)
@@ -3230,13 +3229,13 @@ ftrace_allocate_pages(unsigned long num_to_init) free_pages: pg = start_pg;while (pg) { - order =get_count_order (pg->size /ENTRIES_PER_PAGE ); -if (order >=0 ) -free_pages ((unsigned long )pg->records, order); +if (pg->records) { +free_pages ((unsigned long )pg->records, pg->order); + ftrace_number_of_pages -=1 << pg->order; + } start_pg = pg->next;kfree (pg); pg = start_pg; - ftrace_number_of_pages -=1 << order; ftrace_number_of_groups--; }pr_info ("ftrace: FAILED to allocate memory for functions\n" );
@@ -6188,6 +6187,7 @@ static int ftrace_process_locs(struct module *mod, p = start; pg = start_pg;while (p < end) { +unsigned long end_offset; addr =ftrace_call_adjust (*p++);/* * Some architecture linkers will pad between
@@ -6198,7 +6198,8 @@ static int ftrace_process_locs(struct module *mod,if (!addr)continue ; -if (pg->index == pg->size) { + end_offset = (pg->index+1 ) *sizeof (pg->records[0 ]); +if (end_offset >PAGE_SIZE << pg->order) {/* We should have allocated enough */ if (WARN_ON (!pg->next))break ;
@@ -6367,7 +6368,6 @@ void ftrace_release_mod(struct module *mod)struct ftrace_page **last_pg;struct ftrace_page *tmp_page =NULL ;struct ftrace_page *pg; -int order;mutex_lock (&ftrace_lock);
@@ -6418,12 +6418,12 @@ void ftrace_release_mod(struct module *mod)/* Needs to be called outside of ftrace_lock */ clear_mod_from_hashes (pg); - order =get_count_order (pg->size /ENTRIES_PER_PAGE ); -if (order >=0 ) -free_pages ((unsigned long )pg->records, order); +if (pg->records) { +free_pages ((unsigned long )pg->records, pg->order); + ftrace_number_of_pages -=1 << pg->order; + } tmp_page = pg->next;kfree (pg); - ftrace_number_of_pages -=1 << order; ftrace_number_of_groups--; } }
@@ -6741,7 +6741,6 @@ void ftrace_free_mem(struct module *mod, void *start_ptr, void *end_ptr)struct ftrace_mod_map *mod_map =NULL ;struct ftrace_init_func *func, *func_next;struct list_head clear_hash; -int order;INIT_LIST_HEAD (&clear_hash);
@@ -6779,10 +6778,10 @@ void ftrace_free_mem(struct module *mod, void *start_ptr, void *end_ptr) ftrace_update_tot_cnt--;if (!pg->index) { *last_pg = pg->next; - order =get_count_order (pg->size /ENTRIES_PER_PAGE ); -if (order >=0 ) -free_pages ((unsigned long )pg->records, order); - ftrace_number_of_pages -=1 << order; +if (pg->records) { +free_pages ((unsigned long )pg->records, pg->order); + ftrace_number_of_pages -=1 << pg->order; + } ftrace_number_of_groups--;kfree (pg); pg = container_of(last_pg, struct ftrace_page, next);
Signature · 1 line
2.30.1
Steven Rostedt
maintainerPATCH 4/4 ftrace: Simplify the calculation of page number for ftrace_page->records some more
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
Commit b40c6eabfcd40 ("ftrace: Simplify the calculation of page number for ftrace_page->records") simplified the calculation of the number of pages needed for each page group without having any empty pages, but it can be simplified even further.
--- kernel/trace/ftrace.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
kernel/trace/ftrace.c +2 -8
@@ -3156,15 +3156,9 @@ static int ftrace_allocate_records(struct ftrace_page *pg, int count)if (WARN_ON (!count))return -EINVAL ; +/* We want to fill as much as possible, with no empty pages */ pages =DIV_ROUND_UP (count,ENTRIES_PER_PAGE ); - order =get_count_order (pages); - -/* -* We want to fill as much as possible. No more than a page -* may be empty. -*/ -if (!is_power_of_2 (pages)) - order--; + order =fls (pages) -1 ; again: pg->records = (void *)__get_free_pages (GFP_KERNEL | __GFP_ZERO, order);
Signature · 1 line
2.30.1