|
[an error occurred while processing this directive]
|
|
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhV-H6zjWXjjuoOkRov4886E82QRH=3NnkhP2e4hroSJr1UXg@mail.gmail.com>
Date: Tue, 9 Dec 2025 16:30:17 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Tiezhu Yang <yangtiezhu@...ngson.cn>
Cc: loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] LoongArch: Remove unnecessary checks in bt_address()
Hi, Tiezhu,
On Tue, Dec 9, 2025 at 2:18 PM Tiezhu Yang <yangtiezhu@...ngson.cn> wrote:
>
> According to the following function definitions, __kernel_text_address()
> already checks __module_text_address(), so it should remove the check of
> __module_text_address() in bt_address() at least.
>
> int __kernel_text_address(unsigned long addr)
> {
> if (kernel_text_address(addr))
> return 1;
> ...
> return 0;
> }
>
> int kernel_text_address(unsigned long addr)
> {
> bool no_rcu;
> int ret = 1;
> ...
> if (is_module_text_address(addr))
> goto out;
> ...
> return ret;
> }
>
> bool is_module_text_address(unsigned long addr)
> {
> guard(rcu)();
> return __module_text_address(addr) != NULL;
> }
>
> Furthermore, since it returns ra at the end of bt_address() and check it
> with __kernel_text_address() after calling bt_address(), so it can remove
> the check of __kernel_text_address() in bt_address() too.
>
> Just remove unnecessary checks, no functional changes intended.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
> ---
> arch/loongarch/kernel/unwind_orc.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/arch/loongarch/kernel/unwind_orc.c b/arch/loongarch/kernel/unwind_orc.c
> index 0d5fa64a2225..3919dbd04c21 100644
> --- a/arch/loongarch/kernel/unwind_orc.c
> +++ b/arch/loongarch/kernel/unwind_orc.c
> @@ -360,12 +360,6 @@ static inline unsigned long bt_address(unsigned long ra)
> {
> extern unsigned long eentry;
>
> - if (__kernel_text_address(ra))
> - return ra;
> -
> - if (__module_text_address(ra))
> - return ra;
I think the correct way is to remove the __module_text_address()
condition but keep the __kernel_text_address() condition. Then return
0 at the end of this function, and remove the __kernel_text_address()
condition out of this function.
Huacai
> -
> if (ra >= eentry && ra < eentry + EXCCODE_INT_END * VECSIZE) {
> unsigned long func;
> unsigned long type = (ra - eentry) / VECSIZE;
> --
> 2.42.0
>
Powered by blists - more mailing lists