From: "Björn Töpel" <bjorn@kernel.org> To: "Puranjay Mohan" <puranjay12@gmail.com>, "Paul Walmsley" <paul.walmsley@sifive.com>, "Palmer Dabbelt" <palmer@dabbelt.com>, "Albert Ou" <aou@eecs.berkeley.edu>, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, "Björn Töpel" <bjorn@rivosinc.com> Cc: puranjay12@gmail.com Subject: Re: [PATCH 1/2] riscv: stacktrace: use arch_stack_walk() in place of walk_stackframe Date: Tue, 02 Apr 2024 15:19:29 +0200 [thread overview] Message-ID: <87zfubrjfi.fsf@all.your.base.are.belong.to.us> (raw) In-Reply-To: <20240328184020.34278-2-puranjay12@gmail.com> Puranjay Mohan <puranjay12@gmail.com> writes: > Currently, dump_backtrace(), __get_wchan(), and perf_callchain_kernel() > directly call walk_stackframe(). Make then call arch_stack_walk() which > is a wrapper around walk_stackframe() and make walk_stackframe() static. > > This allows making changes to walk_stackframe() without disturbing the > users of arch_stack_walk() which is the exposed function. > > Signed-off-by: Puranjay Mohan <puranjay12@gmail.com> > --- > arch/riscv/include/asm/stacktrace.h | 2 -- > arch/riscv/kernel/perf_callchain.c | 2 +- > arch/riscv/kernel/stacktrace.c | 26 ++++++++++++++------------ > 3 files changed, 15 insertions(+), 15 deletions(-) > > diff --git a/arch/riscv/include/asm/stacktrace.h b/arch/riscv/include/asm/stacktrace.h > index b1495a7e06ce6..32213e37c379f 100644 > --- a/arch/riscv/include/asm/stacktrace.h > +++ b/arch/riscv/include/asm/stacktrace.h > @@ -11,8 +11,6 @@ struct stackframe { > unsigned long ra; > }; > > -extern void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, > - bool (*fn)(void *, unsigned long), void *arg); > extern void dump_backtrace(struct pt_regs *regs, struct task_struct *task, > const char *loglvl); > > diff --git a/arch/riscv/kernel/perf_callchain.c b/arch/riscv/kernel/perf_callchain.c > index 3348a61de7d99..c023e0b1eb814 100644 > --- a/arch/riscv/kernel/perf_callchain.c > +++ b/arch/riscv/kernel/perf_callchain.c > @@ -74,5 +74,5 @@ static bool fill_callchain(void *entry, unsigned long pc) > void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, > struct pt_regs *regs) > { > - walk_stackframe(NULL, regs, fill_callchain, entry); > + arch_stack_walk(fill_callchain, entry, NULL, regs); > } > diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c > index 64a9c093aef93..e28f7b2e4b6a6 100644 > --- a/arch/riscv/kernel/stacktrace.c > +++ b/arch/riscv/kernel/stacktrace.c > @@ -18,8 +18,9 @@ > > extern asmlinkage void ret_from_exception(void); > > -void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, > - bool (*fn)(void *, unsigned long), void *arg) > +static __always_inline void > +walk_stackframe(struct task_struct *task, struct pt_regs *regs, > + bool (*fn)(void *, unsigned long), void *arg) Really a nit, but please try to keep the return value/linkage/function name on one line if possible. > { > unsigned long fp, sp, pc; > int level = 0; > @@ -76,8 +77,9 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, > > #else /* !CONFIG_FRAME_POINTER */ > > -void notrace walk_stackframe(struct task_struct *task, > - struct pt_regs *regs, bool (*fn)(void *, unsigned long), void *arg) > +static __always_inline void > +walk_stackframe(struct task_struct *task, struct pt_regs *regs, > + bool (*fn)(void *, unsigned long), void *arg) ...and here. Björn
WARNING: multiple messages have this Message-ID (diff)
From: "Björn Töpel" <bjorn@kernel.org> To: "Puranjay Mohan" <puranjay12@gmail.com>, "Paul Walmsley" <paul.walmsley@sifive.com>, "Palmer Dabbelt" <palmer@dabbelt.com>, "Albert Ou" <aou@eecs.berkeley.edu>, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, "Björn Töpel" <bjorn@rivosinc.com> Cc: puranjay12@gmail.com Subject: Re: [PATCH 1/2] riscv: stacktrace: use arch_stack_walk() in place of walk_stackframe Date: Tue, 02 Apr 2024 15:19:29 +0200 [thread overview] Message-ID: <87zfubrjfi.fsf@all.your.base.are.belong.to.us> (raw) In-Reply-To: <20240328184020.34278-2-puranjay12@gmail.com> Puranjay Mohan <puranjay12@gmail.com> writes: > Currently, dump_backtrace(), __get_wchan(), and perf_callchain_kernel() > directly call walk_stackframe(). Make then call arch_stack_walk() which > is a wrapper around walk_stackframe() and make walk_stackframe() static. > > This allows making changes to walk_stackframe() without disturbing the > users of arch_stack_walk() which is the exposed function. > > Signed-off-by: Puranjay Mohan <puranjay12@gmail.com> > --- > arch/riscv/include/asm/stacktrace.h | 2 -- > arch/riscv/kernel/perf_callchain.c | 2 +- > arch/riscv/kernel/stacktrace.c | 26 ++++++++++++++------------ > 3 files changed, 15 insertions(+), 15 deletions(-) > > diff --git a/arch/riscv/include/asm/stacktrace.h b/arch/riscv/include/asm/stacktrace.h > index b1495a7e06ce6..32213e37c379f 100644 > --- a/arch/riscv/include/asm/stacktrace.h > +++ b/arch/riscv/include/asm/stacktrace.h > @@ -11,8 +11,6 @@ struct stackframe { > unsigned long ra; > }; > > -extern void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, > - bool (*fn)(void *, unsigned long), void *arg); > extern void dump_backtrace(struct pt_regs *regs, struct task_struct *task, > const char *loglvl); > > diff --git a/arch/riscv/kernel/perf_callchain.c b/arch/riscv/kernel/perf_callchain.c > index 3348a61de7d99..c023e0b1eb814 100644 > --- a/arch/riscv/kernel/perf_callchain.c > +++ b/arch/riscv/kernel/perf_callchain.c > @@ -74,5 +74,5 @@ static bool fill_callchain(void *entry, unsigned long pc) > void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, > struct pt_regs *regs) > { > - walk_stackframe(NULL, regs, fill_callchain, entry); > + arch_stack_walk(fill_callchain, entry, NULL, regs); > } > diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c > index 64a9c093aef93..e28f7b2e4b6a6 100644 > --- a/arch/riscv/kernel/stacktrace.c > +++ b/arch/riscv/kernel/stacktrace.c > @@ -18,8 +18,9 @@ > > extern asmlinkage void ret_from_exception(void); > > -void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, > - bool (*fn)(void *, unsigned long), void *arg) > +static __always_inline void > +walk_stackframe(struct task_struct *task, struct pt_regs *regs, > + bool (*fn)(void *, unsigned long), void *arg) Really a nit, but please try to keep the return value/linkage/function name on one line if possible. > { > unsigned long fp, sp, pc; > int level = 0; > @@ -76,8 +77,9 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, > > #else /* !CONFIG_FRAME_POINTER */ > > -void notrace walk_stackframe(struct task_struct *task, > - struct pt_regs *regs, bool (*fn)(void *, unsigned long), void *arg) > +static __always_inline void > +walk_stackframe(struct task_struct *task, struct pt_regs *regs, > + bool (*fn)(void *, unsigned long), void *arg) ...and here. Björn _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2024-04-02 13:19 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-28 18:40 [PATCH 0/2] riscv: ftrace: make stack walk more robust Puranjay Mohan 2024-03-28 18:40 ` Puranjay Mohan 2024-03-28 18:40 ` [PATCH 1/2] riscv: stacktrace: use arch_stack_walk() in place of walk_stackframe Puranjay Mohan 2024-03-28 18:40 ` Puranjay Mohan 2024-04-02 13:19 ` Björn Töpel [this message] 2024-04-02 13:19 ` Björn Töpel 2024-03-28 18:40 ` [PATCH 2/2] riscv: stacktrace: make walk_stackframe() more robust Puranjay Mohan 2024-03-28 18:40 ` Puranjay Mohan 2024-04-02 13:20 ` Björn Töpel 2024-04-02 13:20 ` Björn Töpel 2024-04-02 13:18 ` [PATCH 0/2] riscv: ftrace: make stack walk " Björn Töpel 2024-04-02 13:18 ` Björn Töpel
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=87zfubrjfi.fsf@all.your.base.are.belong.to.us \ --to=bjorn@kernel.org \ --cc=aou@eecs.berkeley.edu \ --cc=bjorn@rivosinc.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-riscv@lists.infradead.org \ --cc=palmer@dabbelt.com \ --cc=paul.walmsley@sifive.com \ --cc=puranjay12@gmail.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.