Skip to content

[backport] riscv: Implement smp_cond_load8/16() with Zawrs - #371

Merged
sterling-teng merged 1 commit into
RVCK-Project:rvck-6.6from
uestc-gr:zawrs
Sep 1, 2026
Merged

[backport] riscv: Implement smp_cond_load8/16() with Zawrs#371
sterling-teng merged 1 commit into
RVCK-Project:rvck-6.6from
uestc-gr:zawrs

Conversation

@uestc-gr

Copy link
Copy Markdown
Contributor

fixed: #367

补丁 riscv: Implement smp_cond_load8/16() with Zawrs 在 arch/riscv/include/asm/cmpxchg.h 中新增了对 byte (8-bit) 和 halfword (16-bit) 的 smp_cond_load 实现,利用 Zawrs 指令扩展 (WRS.NTO) 来优化自旋锁等待。

之前 RISC-V 内核只支持 word (32/64 位) 的 smp_cond_load,该补丁补齐了 8/16 位场景。

测试方法
smp_cond_load_test.c

测试结果
~ # insmod /home/smp_cond_load_test.ko
[ 42.385827] smp_cond_load_test: loading out-of-tree module taints kernel.
[ 42.478998] cmpwait_test: module init
[ 42.487520] writer: sleeping 2s before update...
[ 42.490939] reader: waiting for test_byte=0x12...
[ 44.519323] writer: updated test_byte=0x12
[ 44.519475] reader: got test_byte match!
[ 44.520820] reader: waiting for test_half=0x1234...
[ 46.534158] writer: updated test_half=0x1234
[ 46.534316] reader: got test_half match!

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown

开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/32363783546

参数解析结果
args value
repository RVCK-Project/rvck
head ref pull/371/head
base ref rvck-6.6
LAVA repo RVCK-Project/lavaci
LAVA hardware ['qemu']
LAVA Testcase path lava-testcases/common-test/ltp/ltp.yaml
need run job kunit-test,kernel-build,check-patch,lava-trigger

测试完成

详细结果:
check result
kunit-test success
kernel-build success
check-patch success
lava-trigger-qemu success
lava-trigger-sg2042 skipped
lava-trigger-k1 skipped
lava-trigger-lpi4a skipped

Kunit Test Result

[11:30:53] Testing complete. Ran 482 tests: passed: 465, skipped: 17

Kernel Build Result

Check Patch Result

Total Errors 0
Total Warnings 1

LAVA Check (qemu)

args value
testcase_repo RVCK-Project/lavaci
lava_template lava-job-template/qemu/qemu-ltp.yaml
testcase_path lava-testcases/common-test/ltp/ltp.yaml
kernel_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck/371_32363783546_1/Image
initramfs_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck/371_32363783546_1/initramfs.img
rootfs_download_url https://fast-mirror.isrc.ac.cn/openeuler-sig-riscv/openEuler-RISC-V/RVCK/openEuler24.03-LTS-SP1/openeuler-rootfs.img.zst
testcase_ref main
testitem_name RVCK-Project_rvck_pull_request_target_371__common-test_qemu

result: Lava check done!

@unicornx unicornx added the ZTE label Aug 21, 2026
@unicornx

Copy link
Copy Markdown
Contributor

@uestc-gr 上周 rvck-6.6 升级了,请 rebase 一下再 review,谢谢

@unicornx
unicornx self-requested a review August 24, 2026 01:59
@unicornx unicornx changed the title 【backport】riscv: Implement smp_cond_load8/16() with Zawrs [backport] riscv: Implement smp_cond_load8/16() with Zawrs Aug 24, 2026
mainline inclusion
from Linux 6.14-rc7
commit d9708b1
category: feature
bugzilla: RVCK-Project#367

--------------------------------

RISC-V code uses the queued spinlock implementation, which calls
the macros smp_cond_load_acquire for one byte. So, complement the
implementation of byte and halfword versions.

Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Signed-off-by: Guo Ren <guoren@kernel.org>
Cc: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Link: https://lore.kernel.org/r/20241217013910.1039923-1-guoren@kernel.org
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/32696551465

参数解析结果
args value
repository RVCK-Project/rvck
head ref pull/371/head
base ref rvck-6.6
LAVA repo RVCK-Project/lavaci
LAVA hardware ['qemu']
LAVA Testcase path lava-testcases/common-test/ltp/ltp.yaml
need run job kunit-test,kernel-build,check-patch,lava-trigger

测试完成

详细结果:
check result
kunit-test success
kernel-build success
check-patch success
lava-trigger-qemu failure
lava-trigger-sg2042 skipped
lava-trigger-k1 skipped
lava-trigger-lpi4a skipped

Kunit Test Result

[06:20:15] Testing complete. Ran 482 tests: passed: 465, skipped: 17

Kernel Build Result

Check Patch Result

Total Errors 0
Total Warnings 1

LAVA Check (qemu)

args value
testcase_repo RVCK-Project/lavaci
lava_template lava-job-template/qemu/qemu-ltp.yaml
testcase_path lava-testcases/common-test/ltp/ltp.yaml
kernel_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck/371_32696551465_1/Image
initramfs_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck/371_32696551465_1/initramfs.img
rootfs_download_url https://fast-mirror.isrc.ac.cn/openeuler-sig-riscv/openEuler-RISC-V/RVCK/openEuler24.03-LTS-SP1/openeuler-rootfs.img.zst
testcase_ref main
testitem_name RVCK-Project_rvck_pull_request_target_371__common-test_qemu

result: Lava check fail!

测试完成

详细结果:
check result
kunit-test success
kernel-build success
check-patch success
lava-trigger-qemu failure
lava-trigger-sg2042 skipped
lava-trigger-k1 skipped
lava-trigger-lpi4a skipped

Kunit Test Result

[06:20:15] Testing complete. Ran 482 tests: passed: 465, skipped: 17

Kernel Build Result

Check Patch Result

Total Errors 0
Total Warnings 1

LAVA Check (qemu)

args value
testcase_repo RVCK-Project/lavaci
lava_template lava-job-template/qemu/qemu-ltp.yaml
testcase_path lava-testcases/common-test/ltp/ltp.yaml
kernel_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck/371_32696551465_1/Image
initramfs_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck/371_32696551465_1/initramfs.img
rootfs_download_url https://fast-mirror.isrc.ac.cn/openeuler-sig-riscv/openEuler-RISC-V/RVCK/openEuler24.03-LTS-SP1/openeuler-rootfs.img.zst
testcase_ref main
testitem_name RVCK-Project_rvck_pull_request_target_371__common-test_qemu

result: Lava check fail!

@uestc-gr
uestc-gr marked this pull request as draft August 24, 2026 06:21
@uestc-gr
uestc-gr requested review from unicornx and removed request for unicornx August 24, 2026 06:21
@uestc-gr
uestc-gr marked this pull request as ready for review August 24, 2026 06:23
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/32696551465

参数解析结果
args value
repository RVCK-Project/rvck
head ref pull/371/head
base ref rvck-6.6
LAVA repo RVCK-Project/lavaci
LAVA hardware ['qemu']
LAVA Testcase path lava-testcases/common-test/ltp/ltp.yaml
need run job kunit-test,kernel-build,check-patch,lava-trigger

测试完成

详细结果:
check result
kunit-test success
kernel-build success
check-patch success
lava-trigger-qemu success
lava-trigger-sg2042 skipped
lava-trigger-k1 skipped
lava-trigger-lpi4a skipped

Kunit Test Result

[09:08:59] Testing complete. Ran 482 tests: passed: 465, skipped: 17

Kernel Build Result

Check Patch Result

Total Errors 0
Total Warnings 1

LAVA Check (qemu)

args value
testcase_repo RVCK-Project/lavaci
lava_template lava-job-template/qemu/qemu-ltp.yaml
testcase_path lava-testcases/common-test/ltp/ltp.yaml
kernel_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck/371_32696551465_3/Image
initramfs_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck/371_32696551465_3/initramfs.img
rootfs_download_url https://fast-mirror.isrc.ac.cn/openeuler-sig-riscv/openEuler-RISC-V/RVCK/openEuler24.03-LTS-SP1/openeuler-rootfs.img.zst
testcase_ref main
testitem_name RVCK-Project_rvck_pull_request_target_371__common-test_qemu

result: Lava check done!

@unicornx unicornx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Reviewed-by: Chen Wang wangchen20@iscas.ac.cn
Tested-by: Chen Wang wangchen20@iscas.ac.cn # QEMU

@unicornx

unicornx commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

test.tar.gz
Attached test module package for memo.

Also:

  • build pass and no impaction on qemu boot-up and login openEuler 24.03 LTS.
  • build pass and no impaction on Pioneerbox/SG2042 boot-up and login openEuler 24.03 LTS.

@unicornx
unicornx requested a review from fangyu0809 August 31, 2026 02:06
@fangyu0809

Copy link
Copy Markdown

LGTM

Reviewed-by: Fangyu Yu fangyu.yu@linux.alibaba.com

@sterling-teng

Copy link
Copy Markdown
Contributor

已经合并至rvck-6.6.

@sterling-teng
sterling-teng merged commit 17c2a37 into RVCK-Project:rvck-6.6 Sep 1, 2026
37 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【backport】riscv: Implement smp_cond_load8/16() with Zawrs

5 participants