Re: Loongson (and other $ARCHs?) idle VS timer enqueue

From: maobibo
Date: Tue Apr 25 2023 - 22:23:38 EST




在 2023/4/26 10:10, WANG Xuerui 写道:
> On 2023/4/26 08:46, maobibo wrote:
>>
>>
>> 在 2023/4/25 21:28, WANG Xuerui 写道:
>>> On 2023/4/25 21:25, maobibo wrote:
>>>>
>>>>
>>>> 在 2023/4/25 19:49, Peter Zijlstra 写道:
>>>
>>> <snip>
>>>
>>>>>
>>>>> diff --git a/arch/loongarch/kernel/genex.S b/arch/loongarch/kernel/genex.S
>>>>> index 44ff1ff64260..3c8a6bab98fe 100644
>>>>> --- a/arch/loongarch/kernel/genex.S
>>>>> +++ b/arch/loongarch/kernel/genex.S
>>>>> @@ -18,27 +18,31 @@
>>>>>          .align    5
>>>>>    SYM_FUNC_START(__arch_cpu_idle)
>>>>> -    /* start of rollback region */
>>>>> -    LONG_L    t0, tp, TI_FLAGS
>>>>> -    nop
>>>>> -    andi    t0, t0, _TIF_NEED_RESCHED
>>>>> -    bnez    t0, 1f
>>>>> -    nop
>>>>> -    nop
>>>>> -    nop
>>>>> +    /* start of idle interrupt region */
>>>>> +    move    t0, CSR_CRMD_IE
>>>> addi.d  t0, zero, CSR_CRMD_IE can be used here, move is used for reg to reg
>>>
>>> Or better: li.d t0, CSR_CRMD_IE (prefer pseudo-instruction over concrete ones whenever it helps readability). We don't need to support ancient in-house toolchains without support for even li. ;-)
>>    I am not familiar with compiler:(, how many actual instructions does
>> pseudo-instr li.d takes? It will be ok if it uses only one intr, else
>> there will be problem.
>
> It's just `ori $t0, $zero, 4` no matter which of li.w or li.d is used. It only matters when the immediate to load is bigger. Given CSR_CRMD_IE is just 4 (1<<2) you can definitely say `li.w` if you want to be extra cautious and it won't hurt. ;-)

That is good to me, you are compiler expert:)

>