]> Gentwo Git Trees - linux/.git/commit
riscv: ptrace: Optimize the allocation of vector regset
authorYong-Xuan Wang <yongxuan.wang@sifive.com>
Tue, 18 Nov 2025 04:19:29 +0000 (21:19 -0700)
committerPaul Walmsley <pjw@kernel.org>
Wed, 19 Nov 2025 16:19:28 +0000 (09:19 -0700)
commit6efb1a9462ef0023f3f96a7b88542e1f878e31a0
treed46c26c65297a46b91b4c3e89db512bbfd8b06d1
parent3ac022bf389d60e696e4d3156b72f3ccd6e6368b
riscv: ptrace: Optimize the allocation of vector regset

The vector regset uses the maximum possible vlen value to estimate the
.n field. But not all the hardwares support the maximum vlen. Linux
might wastes time to prepare a large memory buffer(about 2^6 pages) for
the vector regset.

The regset can only copy vector registers when the process are using
vector. Add .active callback and determine the n field of vector regset
in riscv_v_setup_ctx_cache() doesn't affect the ptrace syscall and
coredump. It can avoid oversized allocations and better matches real
hardware limits.

Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
Reviewed-by: Andy Chiu <andybnac@gmail.com>
Tested-by: Andy Chiu <andybnac@gmail.com>
Link: https://patch.msgid.link/20251013091318.467864-2-yongxuan.wang@sifive.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/include/asm/vector.h
arch/riscv/kernel/ptrace.c
arch/riscv/kernel/vector.c