From: Song Liu <song@kernel.org>
To: <linux-kernel@vger.kernel.org>
Cc: <bpf@vger.kernel.org>, <mcgrof@kernel.org>,
<peterz@infradead.org>, <tglx@linutronix.de>, <x86@kernel.org>,
<rppt@kernel.org>, <kent.overstreet@linux.dev>,
Song Liu <song@kernel.org>
Subject: [PATCH 2/3] ftrace: Add swap_func to ftrace_process_locs()
Date: Thu, 25 May 2023 22:15:28 -0700 [thread overview]
Message-ID: <20230526051529.3387103-3-song@kernel.org> (raw)
In-Reply-To: <20230526051529.3387103-1-song@kernel.org>
ftrace_process_locs sorts module mcount, which is inside RO memory. Add a
ftrace_swap_func so that archs can use RO-memory-poke function to do the
sorting.
Signed-off-by: Song Liu <song@kernel.org>
---
include/linux/ftrace.h | 2 ++
kernel/trace/ftrace.c | 13 ++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index b23bdd414394..fe443b8ed32c 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -1166,4 +1166,6 @@ unsigned long arch_syscall_addr(int nr);
#endif /* CONFIG_FTRACE_SYSCALLS */
+void ftrace_swap_func(void *a, void *b, int n);
+
#endif /* _LINUX_FTRACE_H */
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 764668467155..f5ddc9d4cfb6 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -6430,6 +6430,17 @@ static void test_is_sorted(unsigned long *start, unsigned long count)
}
#endif
+void __weak ftrace_swap_func(void *a, void *b, int n)
+{
+ unsigned long t;
+
+ WARN_ON_ONCE(n != sizeof(t));
+
+ t = *((unsigned long *)a);
+ *(unsigned long *)a = *(unsigned long *)b;
+ *(unsigned long *)b = t;
+}
+
static int ftrace_process_locs(struct module *mod,
unsigned long *start,
unsigned long *end)
@@ -6455,7 +6466,7 @@ static int ftrace_process_locs(struct module *mod,
*/
if (!IS_ENABLED(CONFIG_BUILDTIME_MCOUNT_SORT) || mod) {
sort(start, count, sizeof(*start),
- ftrace_cmp_ips, NULL);
+ ftrace_cmp_ips, ftrace_swap_func);
} else {
test_is_sorted(start, count);
}
--
2.34.1
next prev parent reply other threads:[~2023-05-26 5:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 5:15 [PATCH 0/3] Type aware module allocator Song Liu
2023-05-26 5:15 ` [PATCH 1/3] module: Introduce module_alloc_type Song Liu
2023-05-26 6:07 ` Randy Dunlap
2023-05-26 22:29 ` Kent Overstreet
2023-05-26 23:09 ` Song Liu
2023-05-26 23:39 ` Kent Overstreet
2023-05-27 0:03 ` Song Liu
2023-05-27 3:19 ` Kent Overstreet
2023-05-27 6:00 ` Song Liu
2023-05-26 5:15 ` Song Liu [this message]
2023-05-26 5:15 ` [PATCH 3/3] x86/module: Use module_alloc_type Song Liu
2023-05-27 7:04 ` [PATCH 0/3] Type aware module allocator Kent Overstreet
2023-05-28 5:58 ` Song Liu
2023-05-29 10:45 ` Mike Rapoport
2023-05-30 22:37 ` Song Liu
2023-05-31 13:51 ` Mike Rapoport
2023-05-31 17:03 ` Song Liu
2023-05-31 19:54 ` Mike Rapoport
2023-05-29 18:25 ` Kent Overstreet
2023-05-30 22:48 ` Song Liu
2023-06-01 17:53 ` Kent Overstreet
2023-06-01 18:21 ` Kent Overstreet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230526051529.3387103-3-song@kernel.org \
--to=song@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=peterz@infradead.org \
--cc=rppt@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox