* [for-next][PATCH 0/4] tracing: More updates for 5.13
@ 2021-04-03 14:33 Steven Rostedt
2021-04-03 14:33 ` [for-next][PATCH 1/4] tracing: Remove duplicate struct declaration in trace_events.h Steven Rostedt
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Steven Rostedt @ 2021-04-03 14:33 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton
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(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [for-next][PATCH 1/4] tracing: Remove duplicate struct declaration in trace_events.h
2021-04-03 14:33 [for-next][PATCH 0/4] tracing: More updates for 5.13 Steven Rostedt
@ 2021-04-03 14:33 ` Steven Rostedt
2021-04-03 14:33 ` [for-next][PATCH 2/4] tracing: Remove unused argument from "ring_buffer_time_stamp() Steven Rostedt
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2021-04-03 14:33 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Wan Jiabing
From: Wan Jiabing <wanjiabing@vivo.com>
struct trace_array is declared twice. One has been declared
at forward declaration. Remove the duplicate.
Link: https://lkml.kernel.org/r/20210330034056.2266969-1-wanjiabing@vivo.com
Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
include/linux/trace_events.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 36e27c1f42e0..ad413b382a3c 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -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 {
--
2.30.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [for-next][PATCH 2/4] tracing: Remove unused argument from "ring_buffer_time_stamp()
2021-04-03 14:33 [for-next][PATCH 0/4] tracing: More updates for 5.13 Steven Rostedt
2021-04-03 14:33 ` [for-next][PATCH 1/4] tracing: Remove duplicate struct declaration in trace_events.h Steven Rostedt
@ 2021-04-03 14:33 ` Steven Rostedt
2021-04-03 14:33 ` [for-next][PATCH 3/4] ftrace: Store the order of pages allocated in ftrace_page Steven Rostedt
2021-04-03 14:33 ` [for-next][PATCH 4/4] ftrace: Simplify the calculation of page number for ftrace_page->records some more Steven Rostedt
3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2021-04-03 14:33 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Yordan Karadzhov (VMware)
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
The "cpu" parameter is not being used by the function.
Link: https://lkml.kernel.org/r/20210329130331.199402-1-y.karadz@gmail.com
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
include/linux/ring_buffer.h | 2 +-
kernel/trace/ring_buffer.c | 2 +-
kernel/trace/trace.c | 8 ++++----
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index 057b7ed4fe24..dac53fd3afea 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -181,7 +181,7 @@ unsigned long ring_buffer_commit_overrun_cpu(struct trace_buffer *buffer, int cp
unsigned 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,
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index f4216df58e31..2c0ee6484990 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -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;
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 3834de91fb97..507a30bf26e4 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -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);
--
2.30.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [for-next][PATCH 3/4] ftrace: Store the order of pages allocated in ftrace_page
2021-04-03 14:33 [for-next][PATCH 0/4] tracing: More updates for 5.13 Steven Rostedt
2021-04-03 14:33 ` [for-next][PATCH 1/4] tracing: Remove duplicate struct declaration in trace_events.h Steven Rostedt
2021-04-03 14:33 ` [for-next][PATCH 2/4] tracing: Remove unused argument from "ring_buffer_time_stamp() Steven Rostedt
@ 2021-04-03 14:33 ` Steven Rostedt
2021-04-03 14:33 ` [for-next][PATCH 4/4] ftrace: Simplify the calculation of page number for ftrace_page->records some more Steven Rostedt
3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2021-04-03 14:33 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Linus Torvalds
From: Linus Torvalds <torvalds@linux-foundation.org>
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.
Link: https://lore.kernel.org/lkml/CAHk-=whyMxheOqXAORt9a7JK9gc9eHTgCJ55Pgs4p=X3RrQubQ@mail.gmail.com/
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[ change log written by Steven Rostedt ]
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 22ecaaa13baa..f7bef5a9ada9 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -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);
--
2.30.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [for-next][PATCH 4/4] ftrace: Simplify the calculation of page number for ftrace_page->records some more
2021-04-03 14:33 [for-next][PATCH 0/4] tracing: More updates for 5.13 Steven Rostedt
` (2 preceding siblings ...)
2021-04-03 14:33 ` [for-next][PATCH 3/4] ftrace: Store the order of pages allocated in ftrace_page Steven Rostedt
@ 2021-04-03 14:33 ` Steven Rostedt
3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2021-04-03 14:33 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Linus Torvalds
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
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.
Link: https://lore.kernel.org/lkml/CAHk-=wjt9b7kxQ2J=aDNKbR1QBMB3Hiqb_hYcZbKsxGRSEb+gQ@mail.gmail.com/
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index f7bef5a9ada9..057e962ca5ce 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -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);
--
2.30.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-04-03 14:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-03 14:33 [for-next][PATCH 0/4] tracing: More updates for 5.13 Steven Rostedt
2021-04-03 14:33 ` [for-next][PATCH 1/4] tracing: Remove duplicate struct declaration in trace_events.h Steven Rostedt
2021-04-03 14:33 ` [for-next][PATCH 2/4] tracing: Remove unused argument from "ring_buffer_time_stamp() Steven Rostedt
2021-04-03 14:33 ` [for-next][PATCH 3/4] ftrace: Store the order of pages allocated in ftrace_page Steven Rostedt
2021-04-03 14:33 ` [for-next][PATCH 4/4] ftrace: Simplify the calculation of page number for ftrace_page->records some more Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox