[PATCH v7 0/2] MIPS: Fix idle VS timer enqueue

Marco Crivellari posted 2 patches 8 months, 2 weeks ago
arch/mips/include/asm/idle.h |  3 +-
arch/mips/kernel/genex.S     | 63 +++++++++++++++++++++---------------
arch/mips/kernel/idle.c      |  7 ----
3 files changed, 38 insertions(+), 35 deletions(-)
[PATCH v7 0/2] MIPS: Fix idle VS timer enqueue
Posted by Marco Crivellari 8 months, 2 weeks ago
This patch aims to fix idle routine while the CPU receive an interrupt,
because __r4k_wait() only checks if TIF_NEED_RESCHED is set before
going to sleep.
The same behavior has been changed in LoongArch [1].

Code (cross) compiled successfully and I manage to test it on a VM
emulating a malta board. I ran QEMU with:

qemu-system-mips64el -M malta -m 2G -kernel vmlinux -serial stdio -drive \
file=rootfs.ext2,format=raw -append "rootwait root=/dev/sda" -cpu 5Kc

rootfs generated using buildroot (malta default configuration).

- [1] https://github.com/chenhuacai/linux/commit/a8aa673ea46c03b3f62992ffa4ffe810ac84f6e3

---
Changes in v7:
 - patch 2 to handle __r4k_wait() moved to .cpuidle.text section
 - removed .noreorder section from __r4k_wait()
 - idle region of 32-bytes
 - removed C wrapper r4k_wait() and renamed __r4k_wait() to r4k_wait()
 - changes discussed in:
    https://lore.kernel.org/lkml/20250315194002.13778-1-marco.crivellari@suse.com/T/#m07f2568d9099101637063bd057a497ceb846be3d

Changes in v6:
 - typo in comment, capitalise sentences and full stops

Changes in v5:
 - comment: idle interrupt region, instead of rollback region

Changes in v4:
 - comments: 36 byte region

Changes in v3:
 - changed "daddiu k0, 1" with PTR_ADDIU k0, 5
 - replaced CONFIG_CPU_MICROMIPS with 3 _ssnop followed by _ehb
 - integrated the commit message with explanation about
   CONFIG_CPU_MICROMIPS replacement

Changes in v2:
 - Changes introduced by Huacai:
    https://lore.kernel.org/linux-mips/20250214105047.150835-1-marco.crivellari@suse.com/T/#m75d9c587829e15e0d7baec13078be4e65c936408

Marco Crivellari (2):
  MIPS: Fix idle VS timer enqueue
  MIPS: Move __r4k_wait() to .cpuidle.text section

 arch/mips/include/asm/idle.h |  3 +-
 arch/mips/kernel/genex.S     | 63 +++++++++++++++++++++---------------
 arch/mips/kernel/idle.c      |  7 ----
 3 files changed, 38 insertions(+), 35 deletions(-)

-- 
2.49.0
Re: [PATCH v7 0/2] MIPS: Fix idle VS timer enqueue
Posted by Thomas Bogendoerfer 7 months, 3 weeks ago
On Thu, Apr 03, 2025 at 06:11:41PM +0200, Marco Crivellari wrote:
> This patch aims to fix idle routine while the CPU receive an interrupt,
> because __r4k_wait() only checks if TIF_NEED_RESCHED is set before
> going to sleep.
> The same behavior has been changed in LoongArch [1].
> 
> Code (cross) compiled successfully and I manage to test it on a VM
> emulating a malta board. I ran QEMU with:
> 
> qemu-system-mips64el -M malta -m 2G -kernel vmlinux -serial stdio -drive \
> file=rootfs.ext2,format=raw -append "rootwait root=/dev/sda" -cpu 5Kc
> 
> rootfs generated using buildroot (malta default configuration).
> 
> - [1] https://github.com/chenhuacai/linux/commit/a8aa673ea46c03b3f62992ffa4ffe810ac84f6e3
> 
> ---
> Changes in v7:
>  - patch 2 to handle __r4k_wait() moved to .cpuidle.text section
>  - removed .noreorder section from __r4k_wait()
>  - idle region of 32-bytes
>  - removed C wrapper r4k_wait() and renamed __r4k_wait() to r4k_wait()
>  - changes discussed in:
>     https://lore.kernel.org/lkml/20250315194002.13778-1-marco.crivellari@suse.com/T/#m07f2568d9099101637063bd057a497ceb846be3d
> 
> Changes in v6:
>  - typo in comment, capitalise sentences and full stops
> 
> Changes in v5:
>  - comment: idle interrupt region, instead of rollback region
> 
> Changes in v4:
>  - comments: 36 byte region
> 
> Changes in v3:
>  - changed "daddiu k0, 1" with PTR_ADDIU k0, 5
>  - replaced CONFIG_CPU_MICROMIPS with 3 _ssnop followed by _ehb
>  - integrated the commit message with explanation about
>    CONFIG_CPU_MICROMIPS replacement
> 
> Changes in v2:
>  - Changes introduced by Huacai:
>     https://lore.kernel.org/linux-mips/20250214105047.150835-1-marco.crivellari@suse.com/T/#m75d9c587829e15e0d7baec13078be4e65c936408
> 
> Marco Crivellari (2):
>   MIPS: Fix idle VS timer enqueue
>   MIPS: Move __r4k_wait() to .cpuidle.text section
> 
>  arch/mips/include/asm/idle.h |  3 +-
>  arch/mips/kernel/genex.S     | 63 +++++++++++++++++++++---------------
>  arch/mips/kernel/idle.c      |  7 ----
>  3 files changed, 38 insertions(+), 35 deletions(-)

series applied to mips-fixes.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]