From: Steven Rostedt <rostedt@goodmis.org>
To: Palmer Dabbelt <palmer@dabbelt.com>
Cc: linux-riscv@lists.infradead.org, mingo@redhat.com,
Paul Walmsley <paul.walmsley@sifive.com>,
aou@eecs.berkeley.edu, mhiramat@kernel.org, zong.li@sifive.com,
guoren@linux.alibaba.com, Atish Patra <Atish.Patra@wdc.com>,
linux-kernel@vger.kernel.org, kernel-team@android.com,
Palmer Dabbelt <palmerdabbelt@google.com>,
Changbin Du <changbin.du@gmail.com>
Subject: Re: [PATCH] RISC-V: Don't check text_mutex during stop_machine
Date: Thu, 6 May 2021 09:20:00 -0400 [thread overview]
Message-ID: <20210506092000.26fd392b@gandalf.local.home> (raw)
In-Reply-To: <20210506071041.417854-1-palmer@dabbelt.com>
On Thu, 6 May 2021 00:10:41 -0700
Palmer Dabbelt <palmer@dabbelt.com> wrote:
> diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
> index 7f1e5203de88..da2405652f1d 100644
> --- a/arch/riscv/kernel/ftrace.c
> +++ b/arch/riscv/kernel/ftrace.c
> @@ -11,6 +11,8 @@
> #include <asm/cacheflush.h>
> #include <asm/patch.h>
>
> +int riscv_ftrace_in_stop_machine;
> +
> #ifdef CONFIG_DYNAMIC_FTRACE
> int ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)
> {
> @@ -232,3 +234,16 @@ int ftrace_disable_ftrace_graph_caller(void)
> }
> #endif /* CONFIG_DYNAMIC_FTRACE */
> #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
> +
> +void arch_ftrace_update_code(int command)
> +{
> + /*
> + * The code sequences we use for ftrace can't be patched while the
> + * kernel is running, so we need to use stop_machine() to modify them
> + * for now. This doesn't play nice with text_mutex, we use this flag
> + * to elide the check.
> + */
> + riscv_ftrace_in_stop_machine = true;
> + ftrace_run_stop_machine(command);
> + riscv_ftrace_in_stop_machine = false;
> +}
> diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c
> index 0b552873a577..7983dba477f0 100644
This would work, but my suggestion was to do it without having to add this
arch function. Because the caller of this is:
static void ftrace_run_update_code(int command)
{
int ret;
ret = ftrace_arch_code_modify_prepare();
FTRACE_WARN_ON(ret);
if (ret)
return;
/*
* By default we use stop_machine() to modify the code.
* But archs can do what ever they want as long as it
* is safe. The stop_machine() is the safest, but also
* produces the most overhead.
*/
arch_ftrace_update_code(command);
ret = ftrace_arch_code_modify_post_process();
FTRACE_WARN_ON(ret);
}
Where you already have two hooks that you use to take the text_mutex before
calling arch_ftrace_update_code().
In RISC-V those are:
int ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)
{
mutex_lock(&text_mutex);
return 0;
}
int ftrace_arch_code_modify_post_process(void) __releases(&text_mutex)
{
mutex_unlock(&text_mutex);
return 0;
}
Where all you have to do is change them to:
int ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)
{
mutex_lock(&text_mutex);
riscv_ftrace_in_stop_machine = true;
return 0;
}
int ftrace_arch_code_modify_post_process(void) __releases(&text_mutex)
{
riscv_ftrace_in_stop_machine = false;
mutex_unlock(&text_mutex);
return 0;
}
And you have the exact same affect. Those functions are only used before
calling the stop machine code you have.
-- Steve
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2021-05-06 13:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-06 7:10 [PATCH] RISC-V: Don't check text_mutex during stop_machine Palmer Dabbelt
2021-05-06 12:31 ` kernel test robot
2021-05-06 13:20 ` Steven Rostedt [this message]
2021-05-06 13:25 ` Steven Rostedt
2021-05-22 19:32 ` Palmer Dabbelt
2021-05-28 22:21 ` Steven Rostedt
-- strict thread matches above, loose matches on Subject: below --
2022-03-22 2:23 Palmer Dabbelt
2022-05-01 14:09 ` Changbin Du
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=20210506092000.26fd392b@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=Atish.Patra@wdc.com \
--cc=aou@eecs.berkeley.edu \
--cc=changbin.du@gmail.com \
--cc=guoren@linux.alibaba.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=palmer@dabbelt.com \
--cc=palmerdabbelt@google.com \
--cc=paul.walmsley@sifive.com \
--cc=zong.li@sifive.com \
/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