Re: [PATCH] arm64: stacktrace: Factor out some common code info on_stack()

From: Yunfeng Ye
Date: Thu May 07 2020 - 21:30:26 EST




On 2020/5/7 21:52, Will Deacon wrote:
> On Thu, May 07, 2020 at 05:28:19PM +0800, Yunfeng Ye wrote:
>> diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h
>> index fdb913cc0bcb..b92bef2fb6cd 100644
>> --- a/arch/arm64/include/asm/stacktrace.h
>> +++ b/arch/arm64/include/asm/stacktrace.h
>> @@ -69,27 +69,40 @@ extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
>>
>> DECLARE_PER_CPU(unsigned long *, irq_stack_ptr);
>>
>> -static inline bool on_irq_stack(unsigned long sp,
>> +static inline bool on_stack(unsigned long sp, unsigned long low,
>> + unsigned long high, enum stack_type type,
>> struct stack_info *info)
>> {
>> - unsigned long low = (unsigned long)raw_cpu_read(irq_stack_ptr);
>> - unsigned long high = low + IRQ_STACK_SIZE;
>> -
>> - if (!low)
>> - return false;
>> -
>> if (sp < low || sp >= high)
>> return false;
>>
>> if (info) {
>> info->low = low;
>> info->high = high;
>> - info->type = STACK_TYPE_IRQ;
>> + info->type = type;
>> }
>> -
>> return true;
>> }
>>
>> +static inline bool on_valid_stack(unsigned long sp, unsigned long low,
>> + unsigned long high, enum stack_type type,
>> + struct stack_info *info)
>> +{
>> + if (!low)
>> + return false;
>> +
>> + return on_stack(sp, low, high, type, info);
>> +}
>
> Do we need this as distinct from on_stack()? Afaict, 'low' is never
> going to be NULL for the on_stack() callers, so I suggest just having
> on_stack() check 'low' and getting everybody to call that instead.
>
> Make sense?
>
ok, I will modify and send the patch v2, thanks.

> Will
>
> .
>