Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

LoongArch: Remove unnecessary checks for ORC unwinder

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, there are two checks of __kernel_text_address(), one is in
bt_address() and the other is after calling bt_address(), it looks like
redundant.

Handle the exception address first and then use __kernel_text_address()
to validate the calculated address for exception or the normal address
in bt_address(), then it can remove the check of __kernel_text_address()
after calling bt_address().

Just remove unnecessary checks, no functional changes intended.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>

authored by

Tiezhu Yang and committed by
Huacai Chen
4cd641a7 6e5416d6

+5 -11
+5 -11
arch/loongarch/kernel/unwind_orc.c
··· 352 352 { 353 353 extern unsigned long eentry; 354 354 355 - if (__kernel_text_address(ra)) 356 - return ra; 357 - 358 - if (__module_text_address(ra)) 359 - return ra; 360 - 361 355 if (ra >= eentry && ra < eentry + EXCCODE_INT_END * VECSIZE) { 362 356 unsigned long func; 363 357 unsigned long type = (ra - eentry) / VECSIZE; ··· 369 375 break; 370 376 } 371 377 372 - return func + offset; 378 + ra = func + offset; 373 379 } 374 380 375 - return ra; 381 + if (__kernel_text_address(ra)) 382 + return ra; 383 + 384 + return 0; 376 385 } 377 386 378 387 bool unwind_next_frame(struct unwind_state *state) ··· 497 500 pr_err("cannot find unwind pc at %p\n", (void *)pc); 498 501 goto err; 499 502 } 500 - 501 - if (!__kernel_text_address(state->pc)) 502 - goto err; 503 503 504 504 return true; 505 505