* [PATCH -next 0/3] Optimize code for ftrace
@ 2022-11-09 9:44 Wang Wensheng
2022-11-09 9:44 ` [PATCH -next 1/3] ftrace: Fix the possible incorrect kernel message Wang Wensheng
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Wang Wensheng @ 2022-11-09 9:44 UTC (permalink / raw)
To: linux-kernel, rostedt, mhiramat, mark.rutland
Cc: xuqiang36, weiyongjun1, wangwensheng4
Those are small optimizations discovered by code review.
Wang Wensheng (3):
ftrace: Fix the possible incorrect kernel message
ftrace: Optimize the allocation for mcount entries
ftrace: Delete unused variable ftrace_update_time
kernel/trace/ftrace.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH -next 1/3] ftrace: Fix the possible incorrect kernel message
2022-11-09 9:44 [PATCH -next 0/3] Optimize code for ftrace Wang Wensheng
@ 2022-11-09 9:44 ` Wang Wensheng
2022-11-09 9:44 ` [PATCH -next 2/3] ftrace: Optimize the allocation for mcount entries Wang Wensheng
2022-11-09 9:44 ` [PATCH -next 3/3] ftrace: Delete unused variable ftrace_update_time Wang Wensheng
2 siblings, 0 replies; 5+ messages in thread
From: Wang Wensheng @ 2022-11-09 9:44 UTC (permalink / raw)
To: linux-kernel, rostedt, mhiramat, mark.rutland
Cc: xuqiang36, weiyongjun1, wangwensheng4
If the number of mcount entries is an integer multiple of
ENTRIES_PER_PAGE, the page count showing on the console would be wrong.
Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com>
---
kernel/trace/ftrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index fbf2543111c0..c571c2813c11 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -7401,7 +7401,7 @@ void __init ftrace_init(void)
}
pr_info("ftrace: allocating %ld entries in %ld pages\n",
- count, count / ENTRIES_PER_PAGE + 1);
+ count, DIV_ROUND_UP(count, ENTRIES_PER_PAGE));
ret = ftrace_process_locs(NULL,
__start_mcount_loc,
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH -next 2/3] ftrace: Optimize the allocation for mcount entries
2022-11-09 9:44 [PATCH -next 0/3] Optimize code for ftrace Wang Wensheng
2022-11-09 9:44 ` [PATCH -next 1/3] ftrace: Fix the possible incorrect kernel message Wang Wensheng
@ 2022-11-09 9:44 ` Wang Wensheng
2022-11-09 9:44 ` [PATCH -next 3/3] ftrace: Delete unused variable ftrace_update_time Wang Wensheng
2 siblings, 0 replies; 5+ messages in thread
From: Wang Wensheng @ 2022-11-09 9:44 UTC (permalink / raw)
To: linux-kernel, rostedt, mhiramat, mark.rutland
Cc: xuqiang36, weiyongjun1, wangwensheng4
If we can't allocate this size, try something smaller with half of the
size. Its order should be decreased by one instead of divided by two.
Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com>
---
kernel/trace/ftrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index c571c2813c11..43a958b28022 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3200,7 +3200,7 @@ static int ftrace_allocate_records(struct ftrace_page *pg, int count)
/* if we can't allocate this size, try something smaller */
if (!order)
return -ENOMEM;
- order >>= 1;
+ order--;
goto again;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH -next 3/3] ftrace: Delete unused variable ftrace_update_time
2022-11-09 9:44 [PATCH -next 0/3] Optimize code for ftrace Wang Wensheng
2022-11-09 9:44 ` [PATCH -next 1/3] ftrace: Fix the possible incorrect kernel message Wang Wensheng
2022-11-09 9:44 ` [PATCH -next 2/3] ftrace: Optimize the allocation for mcount entries Wang Wensheng
@ 2022-11-09 9:44 ` Wang Wensheng
2022-11-17 20:36 ` Steven Rostedt
2 siblings, 1 reply; 5+ messages in thread
From: Wang Wensheng @ 2022-11-09 9:44 UTC (permalink / raw)
To: linux-kernel, rostedt, mhiramat, mark.rutland
Cc: xuqiang36, weiyongjun1, wangwensheng4
ftrace_update_time is not used anywhere else after initialization. So
delete it together with its initial code.
Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com>
---
kernel/trace/ftrace.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 43a958b28022..3e102c44b117 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3110,7 +3110,6 @@ int ftrace_shutdown(struct ftrace_ops *ops, int command)
return 0;
}
-static u64 ftrace_update_time;
unsigned long ftrace_update_tot_cnt;
unsigned long ftrace_number_of_pages;
unsigned long ftrace_number_of_groups;
@@ -3130,13 +3129,10 @@ static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs)
bool init_nop = ftrace_need_init_nop();
struct ftrace_page *pg;
struct dyn_ftrace *p;
- u64 start, stop;
unsigned long update_cnt = 0;
unsigned long rec_flags = 0;
int i;
- start = ftrace_now(raw_smp_processor_id());
-
/*
* When a module is loaded, this function is called to convert
* the calls to mcount in its text to nops, and also to create
@@ -3173,8 +3169,6 @@ static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs)
}
}
- stop = ftrace_now(raw_smp_processor_id());
- ftrace_update_time = stop - start;
ftrace_update_tot_cnt += update_cnt;
return 0;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH -next 3/3] ftrace: Delete unused variable ftrace_update_time
2022-11-09 9:44 ` [PATCH -next 3/3] ftrace: Delete unused variable ftrace_update_time Wang Wensheng
@ 2022-11-17 20:36 ` Steven Rostedt
0 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2022-11-17 20:36 UTC (permalink / raw)
To: Wang Wensheng
Cc: linux-kernel, mhiramat, mark.rutland, xuqiang36, weiyongjun1
On Wed, 9 Nov 2022 09:44:34 +0000
Wang Wensheng <wangwensheng4@huawei.com> wrote:
> ftrace_update_time is not used anywhere else after initialization. So
> delete it together with its initial code.
Thanks for the first two patches. They are definitely fixes and I plan on
testing and adding them to my next pull request.
As for this one, this has been more of a reminder for me to one day (I
know, it's been years!) to export this to see from user space. I sometimes
do it manually with a printk(), but it should probably be always shown.
Perhaps in dyn_ftrace_total_info ?
-- Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-11-17 20:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 9:44 [PATCH -next 0/3] Optimize code for ftrace Wang Wensheng
2022-11-09 9:44 ` [PATCH -next 1/3] ftrace: Fix the possible incorrect kernel message Wang Wensheng
2022-11-09 9:44 ` [PATCH -next 2/3] ftrace: Optimize the allocation for mcount entries Wang Wensheng
2022-11-09 9:44 ` [PATCH -next 3/3] ftrace: Delete unused variable ftrace_update_time Wang Wensheng
2022-11-17 20:36 ` Steven Rostedt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.