riscv: kvm: use generic entry for TIF_NOTIFY_RESUME and misc
Subsystems (3)
v3 cover riscv: kvm: use generic entry for TIF_NOTIFY_RESUME and misc
This series is a preparation series to add PREEMPT_RT support to riscv:
patch1 adds the missing number of signal exits in vCPU stat patch2 switches to the generic guest entry infrastructure patch3 select HAVE_POSIX_CPU_TIMERS_TASK_WORK which is a requirement for RT
After these three patches merged, the left RT patches are similar as other arch.
Since v2:
- splict the series into two separate ones, one for next another for
RT.
Since v1:
- send to related maillist, I press ENTER too quickly when sending v1
- remove the signal_pending() handling because that's covered by generic guest entry infrastructure
Jisheng Zhang (3):
RISC-V: KVM: Record number of signal exits as a vCPU stat
RISC-V: KVM: Use generic guest entry infrastructure
riscv: select HAVE_POSIX_CPU_TIMERS_TASK_WORK
arch/riscv/Kconfig | 1 + arch/riscv/include/asm/kvm_host.h | 1 + arch/riscv/kvm/Kconfig | 1 + arch/riscv/kvm/vcpu.c | 18 +++++++----------- 4 files changed, 10 insertions(+), 11 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/3 RISC-V: KVM: Record number of signal exits as a vCPU stat
Record a statistic indicating the number of times a vCPU has exited due to a pending signal.
--- arch/riscv/include/asm/kvm_host.h | 1 + arch/riscv/kvm/vcpu.c | 2 ++ 2 files changed, 3 insertions(+)
arch/riscv/include/asm/kvm_host.h +1 -0
@@ -67,6 +67,7 @@ struct kvm_vcpu_stat {u64 mmio_exit_kernel;u64 csr_exit_user;u64 csr_exit_kernel; +u64 signal_exits;u64 exits; };
arch/riscv/kvm/vcpu.c +2 -0
@@ -28,6 +28,7 @@ const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {STATS_DESC_COUNTER (VCPU , mmio_exit_kernel),STATS_DESC_COUNTER (VCPU , csr_exit_user),STATS_DESC_COUNTER (VCPU , csr_exit_kernel), +STATS_DESC_COUNTER (VCPU , signal_exits), STATS_DESC_COUNTER(VCPU, exits) };
@@ -973,6 +974,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)if (signal_pending (current)) { ret = -EINTR ; run->exit_reason =KVM_EXIT_INTR ; + ++vcpu->stat.signal_exits; }/*
Signature · 1 line
2.34.1
Re: [PATCH v3 1/3] RISC-V: KVM: Record number of signal exits as a vCPU stat
? linux git:(master) grep signal_exits arch/arm64 -r arch/arm64/kvm/guest.c: STATS_DESC_COUNTER(VCPU, signal_exits),arch/arm64/include/asm/kvm_host.h: u64 signal_exits;
By the way, do you know why arm64 is defined, but not used?
Quoted 43 lines · Jisheng Zhang
Record a statistic indicating the number of times a vCPU has exited due to a pending signal.
Signed-off-by Jisheng Zhang <[email protected]>--- arch/riscv/include/asm/kvm_host.h | 1 + arch/riscv/kvm/vcpu.c | 2 ++ 2 files changed, 3 insertions(+)arch/riscv/include/asm/kvm_host.h +1
-0@@ -67,6 +67,7 @@ struct kvm_vcpu_stat {u64 mmio_exit_kernel;u64 csr_exit_user;u64 csr_exit_kernel; +u64 signal_exits;u64 exits; };arch/riscv/kvm/vcpu.c +2
-1@@ -28,6 +28,7 @@ const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {STATS_DESC_COUNTER (VCPU , mmio_exit_kernel),STATS_DESC_COUNTER (VCPU , csr_exit_user),STATS_DESC_COUNTER (VCPU , csr_exit_kernel), +STATS_DESC_COUNTER (VCPU , signal_exits), STATS_DESC_COUNTER(VCPU, exits) };@@ -973,6 +974,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)if (signal_pending (current)) { ret = -EINTR ; run->exit_reason =KVM_EXIT_INTR ; + ++vcpu->stat.signal_exits; }/* --
Quoted 2 lines
2.34.1
--
Best Regards
Guo Ren
Re: [PATCH v3 1/3] RISC-V: KVM: Record number of signal exits as a vCPU stat
Quoted 7 lines · Guo Ren
Reviewed-by Guo Ren <[email protected]>? linux git:(master) grep
signal_exitsarch/arm64-rarch/arm64/kvm/guest.c:STATS_DESC_COUNTER(VCPU, signal_exits),arch/arm64/include/asm/kvm_host.h: u64signal_exits;By the way, do you know why arm64 is defined, but not used?
It is. arm64 uses generic xfer to guest mode work, like this series introduces for riscv.
Thanks,
drew
Quoted 58 lines · Jisheng Zhang
Quoted 43 lines
Record a statistic indicating the number of times a vCPU has exited due to a pending signal.
Signed-off-by Jisheng Zhang <[email protected]>--- arch/riscv/include/asm/kvm_host.h | 1 + arch/riscv/kvm/vcpu.c | 2 ++ 2 files changed, 3 insertions(+)arch/riscv/include/asm/kvm_host.h +1
-0@@ -67,6 +67,7 @@ struct kvm_vcpu_stat {u64 mmio_exit_kernel;u64 csr_exit_user;u64 csr_exit_kernel; +u64 signal_exits;u64 exits; };arch/riscv/kvm/vcpu.c +2
-1@@ -28,6 +28,7 @@ const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {STATS_DESC_COUNTER (VCPU , mmio_exit_kernel),STATS_DESC_COUNTER (VCPU , csr_exit_user),STATS_DESC_COUNTER (VCPU , csr_exit_kernel), +STATS_DESC_COUNTER (VCPU , signal_exits), STATS_DESC_COUNTER(VCPU, exits) };@@ -973,6 +974,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)if (signal_pending (current)) { ret = -EINTR ; run->exit_reason =KVM_EXIT_INTR ; + ++vcpu->stat.signal_exits; }/* -- Quoted 2 lines
2.34.1
--
Best Regards
Guo RenSignature · 3 lines
kvm-riscv mailing list kvm-riscv at lists.infradead.org http://lists.infradead.org/mailman/listinfo/kvm-riscv
PATCH v3 2/3 RISC-V: KVM: Use generic guest entry infrastructure
In reply to Jisheng ZhangUse generic guest entry infrastructure to properly handle TIF_NOTIFY_RESUME.
--- arch/riscv/kvm/Kconfig | 1 + arch/riscv/kvm/vcpu.c | 18 ++++++------------ 2 files changed, 7 insertions(+), 12 deletions(-)
arch/riscv/kvm/Kconfig +1 -0
@@ -24,6 +24,7 @@ config KVM select PREEMPT_NOTIFIERS select KVM_MMIO select KVM_GENERIC_DIRTYLOG_READ_PROTECT + select KVM_XFER_TO_GUEST_WORK select HAVE_KVM_VCPU_ASYNC_IOCTL select HAVE_KVM_EVENTFD select SRCU
arch/riscv/kvm/vcpu.c +6 -12
@@ -7,6 +7,7 @@*/ #include <linux/bitops.h> +#include <linux/entry-kvm.h> #include <linux/errno.h> #include <linux/err.h> #include <linux/kdebug.h>
@@ -959,7 +960,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) run->exit_reason =KVM_EXIT_UNKNOWN ;while (ret >0 ) {/* Check conditions before entering the guest */ -cond_resched (); + ret =xfer_to_guest_mode_handle_work (vcpu); +if (!ret) + ret =1 ;kvm_riscv_gstage_vmid_update (vcpu);
@@ -967,16 +970,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)local_irq_disable (); -/* -* Exit if we have a signal pending so that we can deliver -* the signal to user space. -*/ -if (signal_pending (current)) { - ret = -EINTR ; - run->exit_reason =KVM_EXIT_INTR ; - ++vcpu->stat.signal_exits; - } -/* * Ensure we set mode to IN_GUEST_MODE after we disable * interrupts and before the final VCPU requests check.
@@ -999,7 +992,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)if (ret <=0 ||kvm_riscv_gstage_vmid_ver_changed (&vcpu->kvm->arch.vmid) || -kvm_request_pending (vcpu)) { +kvm_request_pending (vcpu) || +xfer_to_guest_mode_work_pending ()) { vcpu->mode =OUTSIDE_GUEST_MODE ;local_irq_enable ();kvm_vcpu_srcu_read_lock (vcpu);
Signature · 1 line
2.34.1
PATCH v3 3/3 riscv: select HAVE_POSIX_CPU_TIMERS_TASK_WORK
In reply to Jisheng ZhangMove POSIX CPU timer expiry and signal delivery into task context to allow PREEMPT_RT setups to coexist with KVM.
--- arch/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/riscv/Kconfig +1 -0
@@ -104,6 +104,7 @@ config RISCV select HAVE_PERF_EVENTS select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP + select HAVE_POSIX_CPU_TIMERS_TASK_WORK select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_FUNCTION_ARG_ACCESS_API select HAVE_STACKPROTECTOR
Signature · 1 line
2.34.1
Quoted 23 lines · Jisheng Zhang
This series is a preparation series to add
PREEMPT_RTsupport to riscv:
patch1 adds the missing number of signal exits in vCPU stat patch2 switches to the generic guest entry infrastructure patch3 selectHAVE_POSIX_CPU_TIMERS_TASK_WORKwhich is a requirement for RTAfter these three patches merged, the left RT patches are similar as other arch.
Since v2:
- splict the series into two separate ones, one for next another forRT.Since v1:
- send to related maillist, I press ENTER too quickly when sending v1
- remove thesignal_pending()handling because that's covered by generic guest entry infrastructureJisheng Zhang (3):
RISC-V: KVM: Record number of signal exits as a vCPU stat
RISC-V: KVM: Use generic guest entry infrastructure
riscv: selectHAVE_POSIX_CPU_TIMERS_TASK_WORK
Quoted 9 lines
arch/riscv/Kconfig | 1 + arch/riscv/include/asm/kvm_host.h | 1 + arch/riscv/kvm/Kconfig | 1 + arch/riscv/kvm/vcpu.c | 18 +++++++----------- 4 files changed, 10 insertions(+), 11 deletions(-)Signature · 1 line
2.34.1
For the series
Anup Patel
maintainerQuoted 19 lines · Jisheng Zhang
This series is a preparation series to add
PREEMPT_RTsupport to riscv:
patch1 adds the missing number of signal exits in vCPU stat patch2 switches to the generic guest entry infrastructure patch3 selectHAVE_POSIX_CPU_TIMERS_TASK_WORKwhich is a requirement for RTAfter these three patches merged, the left RT patches are similar as other arch.
Since v2:
- splict the series into two separate ones, one for next another forRT.Since v1:
- send to related maillist, I press ENTER too quickly when sending v1
- remove thesignal_pending()handling because that's covered by generic guest entry infrastructure
Quoted 4 lines
Jisheng Zhang (3):
RISC-V: KVM: Record number of signal exits as a vCPU stat
RISC-V: KVM: Use generic guest entry infrastructure
riscv: selectHAVE_POSIX_CPU_TIMERS_TASK_WORK
I have queued this series for Linux-6.1
Thanks,
Anup
Quoted 10 lines
arch/riscv/Kconfig | 1 + arch/riscv/include/asm/kvm_host.h | 1 + arch/riscv/kvm/Kconfig | 1 + arch/riscv/kvm/vcpu.c | 18 +++++++----------- 4 files changed, 10 insertions(+), 11 deletions(-)--
2.34.1