Skip to content

Commit 4cd641a

Browse files
seehearfeelchenhuacai
authored andcommitted
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>
1 parent 6e5416d commit 4cd641a

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

arch/loongarch/kernel/unwind_orc.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,6 @@ static inline unsigned long bt_address(unsigned long ra)
352352
{
353353
extern unsigned long eentry;
354354

355-
if (__kernel_text_address(ra))
356-
return ra;
357-
358-
if (__module_text_address(ra))
359-
return ra;
360-
361355
if (ra >= eentry && ra < eentry + EXCCODE_INT_END * VECSIZE) {
362356
unsigned long func;
363357
unsigned long type = (ra - eentry) / VECSIZE;
@@ -375,10 +369,13 @@ static inline unsigned long bt_address(unsigned long ra)
375369
break;
376370
}
377371

378-
return func + offset;
372+
ra = func + offset;
379373
}
380374

381-
return ra;
375+
if (__kernel_text_address(ra))
376+
return ra;
377+
378+
return 0;
382379
}
383380

384381
bool unwind_next_frame(struct unwind_state *state)
@@ -501,9 +498,6 @@ bool unwind_next_frame(struct unwind_state *state)
501498
goto err;
502499
}
503500

504-
if (!__kernel_text_address(state->pc))
505-
goto err;
506-
507501
return true;
508502

509503
err:

0 commit comments

Comments
 (0)