Re: [PATCH v5 RESEND] arch/powerpc/kvm: Add support for reading VPA counters for pseries guests

2024-04-23 Thread Gautam Menghani
On Mon, Apr 22, 2024 at 09:15:02PM +0530, Naveen N Rao wrote: > On Tue, Apr 02, 2024 at 12:36:54PM +0530, Gautam Menghani wrote: > > PAPR hypervisor has introduced three new counters in the VPA area of > > LPAR CPUs for KVM L2 guest (see [1] for terminology) observability - 2

[PATCH v6] arch/powerpc/kvm: Add support for reading VPA counters for pseries guests

2024-05-06 Thread Gautam Menghani
-by: Gautam Menghani --- v5 -> v6: 1. Use TRACE_EVENT_FN to enable/disable counters only once. 2. Remove the agg. counters from vcpu->arch. 3. Use PACA to maintain old counter values instead of zeroing on every entry. 4. Simplify variable names v4 -> v5: 1. Define helper functions fo

[PATCH 0/3] XICS emulation optimizations in KVM for PPC

2024-05-06 Thread Gautam Menghani
| avg = 11 usecs, total: 57,720,612 usecs, count: 4,917,325 4. This patch series has been also tested on KVM on Power8 CPU. [1]: https://github.com/iovisor/bcc/blob/master/tools/funclatency.py Gautam Menghani (3): arch/powerpc/kvm: Use bitmap to speed up res

[PATCH 1/3] arch/powerpc/kvm: Use bitmap to speed up resend of irqs in ICS

2024-05-06 Thread Gautam Menghani
When an irq is to be resent, all 1024 irqs in an ICS are scanned and the irqs having 'resend' flag set are resent. Optimize this flow using bitmap array to speed up the resends. Signed-off-by: Gautam Menghani --- arch/powerpc/kvm/book3s_xics.c | 22 +++--- arch/p

[PATCH 2/3] arch/powerpc/kvm: Optimize the server number -> ICP lookup

2024-05-06 Thread Gautam Menghani
Given a server number, kvmppc_xics_find_server() does a linear search over the vcpus of a VM. Optimize this logic by using an array to maintain the mapping between server number -> icp. Signed-off-by: Gautam Menghani --- arch/powerpc/kvm/book3s_xics.c | 4 ++-- arch/powerpc/kvm/book3s_xic

[PATCH 3/3] arch/powerpc/kvm: Reduce lock contention by moving spinlock from ics to irq_state

2024-05-06 Thread Gautam Menghani
Take a spinlock on state of an IRQ instead of an entire ICS. This improves scalability by reducing contention. Signed-off-by: Gautam Menghani --- arch/powerpc/kvm/book3s_hv_rm_xics.c | 8 ++--- arch/powerpc/kvm/book3s_xics.c | 44 arch/powerpc/kvm

[PATCH v7] arch/powerpc/kvm: Add support for reading VPA counters for pseries guests

2024-05-07 Thread Gautam Menghani
: Vaibhav Jain Signed-off-by: Gautam Menghani --- v6 -> v7: 1. Use TRACE_EVENT_FN_COND to handle zero counters case. 2. Use for_each_present_cpu() to handle hotplugs. v5 -> v6: 1. Use TRACE_EVENT_FN to enable/disable counters only once. 2. Remove the agg. counters from vcpu->arch. 3. Us

[PATCH v8] arch/powerpc/kvm: Add support for reading VPA counters for pseries guests

2024-05-10 Thread Gautam Menghani
: Naveen N Rao Signed-off-by: Vaibhav Jain Signed-off-by: Gautam Menghani --- v7 -> v8: 1. Use per_cpu vars instead of paca members. 2. Fix build error for powernv config. v6 -> v7: 1. Use TRACE_EVENT_FN_COND to handle zero counters case. 2. Use for_each_present_cpu() to handle hotplugs. v5

[PATCH] arch/powerpc: Remove the definition of unused cede function

2024-05-14 Thread Gautam Menghani
Remove extended_cede_processor() definition as it has no callers since commit 48f6e7f6d948("powerpc/pseries: remove cede offline state for CPUs") Signed-off-by: Gautam Menghani --- arch/powerpc/include/asm/plpar_wrappers.h | 18 -- 1 file changed, 18 deletions(-) di

Re: [PATCH] arch/powerpc: Remove the definition of unused cede function

2024-05-14 Thread Gautam Menghani
On Tue, May 14, 2024 at 04:20:04PM GMT, Naveen N Rao wrote: > On Tue, May 14, 2024 at 03:35:03PM GMT, Gautam Menghani wrote: > > Remove extended_cede_processor() definition as it has no callers since > > commit 48f6e7f6d948("powerpc/pseries: remove cede of

[PATCH v2] arch/powerpc: Remove unused cede related functions

2024-05-14 Thread Gautam Menghani
Remove extended_cede_processor() and its helpers as extended_cede_processor() has no callers since commit 48f6e7f6d948("powerpc/pseries: remove cede offline state for CPUs") Signed-off-by: Gautam Menghani --- v1 -> v2: 1. Remove helpers of extended_cede_processor() arch/powerp

[RESEND PATCH 0/3] XICS emulation optimizations in KVM for PPC

2024-05-20 Thread Gautam Menghani
| avg = 11 usecs, total: 57,720,612 usecs, count: 4,917,325 4. This patch series has been also tested on KVM on Power8 CPU. [1]: https://github.com/iovisor/bcc/blob/master/tools/funclatency.py Changes v1 -> v1 resend 1. Add Cedric to CC Gautam Menghani (3): a

[RESEND PATCH 3/3] arch/powerpc/kvm: Reduce lock contention by moving spinlock from ics to irq_state

2024-05-20 Thread Gautam Menghani
Take a spinlock on state of an IRQ instead of an entire ICS. This improves scalability by reducing contention. Signed-off-by: Gautam Menghani --- arch/powerpc/kvm/book3s_hv_rm_xics.c | 8 ++--- arch/powerpc/kvm/book3s_xics.c | 44 arch/powerpc/kvm

[RESEND PATCH 1/3] arch/powerpc/kvm: Use bitmap to speed up resend of irqs in ICS

2024-05-20 Thread Gautam Menghani
When an irq is to be resent, all 1024 irqs in an ICS are scanned and the irqs having 'resend' flag set are resent. Optimize this flow using bitmap array to speed up the resends. Signed-off-by: Gautam Menghani --- arch/powerpc/kvm/book3s_xics.c | 22 +++--- arch/p

[RESEND PATCH 2/3] arch/powerpc/kvm: Optimize the server number -> ICP lookup

2024-05-20 Thread Gautam Menghani
Given a server number, kvmppc_xics_find_server() does a linear search over the vcpus of a VM. Optimize this logic by using an array to maintain the mapping between server number -> icp. Signed-off-by: Gautam Menghani --- arch/powerpc/kvm/book3s_xics.c | 4 ++-- arch/powerpc/kvm/book3s_xic

[PATCH v9] arch/powerpc/kvm: Add support for reading VPA counters for pseries guests

2024-05-20 Thread Gautam Menghani
: Naveen N Rao Signed-off-by: Vaibhav Jain Signed-off-by: Gautam Menghani --- v8 -> v9: 1. Fix linker errors when compiling as module. v7 -> v8: 1. Use per_cpu vars instead of paca members. 2. Fix build error for powernv config. v6 -> v7: 1. Use TRACE_EVENT_FN_COND to handle zero counter

[PATCH] arch/powerpc/kvm: Fix doorbell emulation by adding DPDES support

2024-05-22 Thread Gautam Menghani
()). Add DPDES support in the host KVM code to fix doorbell emulation. Fixes: 6ccbbc33f06a ("KVM: PPC: Add helper library for Guest State Buffers") Signed-off-by: Gautam Menghani --- Documentation/arch/powerpc/kvm-nested.rst | 4 +++- arch/powerpc/include/asm/guest-state-buf

[PATCH v1 RESEND] arch/powerpc/kvm: Fix doorbell emulation by adding DPDES support

2024-05-22 Thread Gautam Menghani
()). Add DPDES support in the host KVM code to fix doorbell emulation. Fixes: 6ccbbc33f06a ("KVM: PPC: Add helper library for Guest State Buffers") Cc: sta...@vger.kernel.org Signed-off-by: Gautam Menghani --- v1 -> v1 resend: 1. Add the stable tag Documentation/arch/powerpc/k

Re: [RESEND PATCH 0/3] XICS emulation optimizations in KVM for PPC

2024-05-28 Thread Gautam Menghani
Hello, Please review this series and let me know if any changes are needed. Thanks, Gautam

Re: [PATCH] arch/powerpc/kvm: Fix doorbell emulation by adding DPDES support

2024-05-30 Thread Gautam Menghani
Hello, Please review this patch and let me know if any changes are needed. Thanks, Gautam

Re: [PATCH] arch/powerpc/kvm: Fix doorbell emulation by adding DPDES support

2024-05-31 Thread Gautam Menghani
On Fri, May 31, 2024 at 08:09:13AM GMT, Greg KH wrote: > On Fri, May 31, 2024 at 10:54:58AM +0530, Gautam Menghani wrote: > > Hello, > > > > Please review this patch and let me know if any changes are needed. > > There already was review comments on it, why ignore t

Re: [PATCH v1 RESEND] arch/powerpc/kvm: Fix doorbell emulation by adding DPDES support

2024-06-03 Thread Gautam Menghani
On Mon, Jun 03, 2024 at 03:42:22PM GMT, Nicholas Piggin wrote: > On Wed May 22, 2024 at 6:49 PM AEST, Gautam Menghani wrote: > > Doorbell emulation is broken for KVM on PowerVM guests as support for > > DPDES was not added in the initial patch series. Due to this, a KVM on > >

[PATCH v2 0/2] Fix doorbell emulation for v2 API on PPC

2024-06-05 Thread Gautam Menghani
its own patch Gautam Menghani (2): arch/powerpc/kvm: Add DPDES support in helper library for Guest state buffer arch/powerpc/kvm: Fix doorbell emulation for v2 API Documentation/arch/powerpc/kvm-nested.rst | 4 +++- arch/powerpc/include/asm/guest-state-buffer.h | 3 ++- arch/powerpc

[PATCH v2 2/2] arch/powerpc/kvm: Fix doorbell emulation for v2 API

2024-06-05 Thread Gautam Menghani
ost KVM code to fix doorbell emulation. Fixes: 19d31c5f1157 ("KVM: PPC: Add support for nestedv2 guests") Cc: sta...@vger.kernel.org # v6.7 Signed-off-by: Gautam Menghani --- arch/powerpc/kvm/book3s_hv.c | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/powerpc/kvm/book3

[PATCH v2 1/2] arch/powerpc/kvm: Add DPDES support in helper library for Guest state buffer

2024-06-05 Thread Gautam Menghani
Add support for using DPDES in the library for using guest state buffers. DPDES support is needed for enabling usage of doorbells in a L2 KVM on PAPR guest. Fixes: 6ccbbc33f06a ("KVM: PPC: Add helper library for Guest State Buffers") Cc: sta...@vger.kernel.org # v6.7 Signed-off-

Re: [PATCH v2 0/2] Fix doorbell emulation for v2 API on PPC

2024-06-05 Thread Gautam Menghani
On Thu, Jun 06, 2024 at 01:00:19PM GMT, Nicholas Piggin wrote: > On Wed Jun 5, 2024 at 9:39 PM AEST, Gautam Menghani wrote: > > Doorbell emulation for KVM on PAPR guests is broken as support for DPDES > > was not added in initial patch series [1]. > > Add DPDES support

Re: [PATCH v2 0/2] Fix doorbell emulation for v2 API on PPC

2024-06-05 Thread Gautam Menghani
On Wed, Jun 05, 2024 at 05:09:08PM GMT, Gautam Menghani wrote: > Doorbell emulation for KVM on PAPR guests is broken as support for DPDES > was not added in initial patch series [1]. > Add DPDES support and doorbell handling support for V2 API. > > [1] lore.kernel.o

Re: [PATCH] powerpc/pseries: Fix scv instruction crash with kexec

2024-06-26 Thread Gautam Menghani
7c2a0b78 3821fd30 41c20008 e82d0910 <0981fd30> f9210160 f9610130 f9810138 [ 2598.923269] ---[ end trace ]--- [ 2598.926662] pstore: backend (nvram) writing error (-1) With this patch, the disabled cpus are woken up and kexec goes through fine. Tested-by: Gautam Menghani

[PATCH] arch/powerpc/kvm: Avoid extra checks when emulating HFSCR bits

2024-06-26 Thread Gautam Menghani
When a KVM guest tries to use a feature disabled by HFSCR, it exits to the host for emulation support, and the code checks for all bits which are emulated. Avoid checking all the bits by using a switch case. Signed-off-by: Gautam Menghani --- arch/powerpc/kvm/book3s_hv.c | 16

[RFC PATCH 0/2] Fix doorbell emulation for nested KVM guests in V1 API

2024-06-27 Thread Gautam Menghani
Doorbell emulation for nested KVM guests in V1 API is broken because of 2 reasons: 1. L0 presenting H_EMUL_ASSIST to L1 instead of H_FAC_UNAVAIL 2. Broken plumbing for passing around doorbell state. Fix the trap passed to L1 and the plumbing for maintaining doorbell state. Gautam Menghani (2

[RFC PATCH 1/2] Revert "KVM: PPC: Book3S HV Nested: Stop forwarding all HFUs to L1"

2024-06-27 Thread Gautam Menghani
t;KVM: PPC: Book3S HV Nested: Stop forwarding all HFUs to L1") the L1 ends up getting a H_EMUL_ASSIST because of which, the L1 ends up injecting a SIGILL when L2 (nested guest) tries to use doorbells. Signed-off-by: Gautam Menghani --- arch/powerpc/kvm/book3s

[RFC PATCH 2/2] arch/powerpc/kvm: Fix doorbells for nested KVM guests on PowerNV

2024-06-27 Thread Gautam Menghani
plumbing to utilize vcpu->doorbell_request instead of vcore->dpdes on P9 and above. Fixes: 6398326b9ba1 ("KVM: PPC: Book3S HV P9: Stop using vc->dpdes") Signed-off-by: Gautam Menghani --- arch/powerpc/kvm/book3s_hv.c| 9 - arch/powerpc/kvm/book3s_hv_neste

Re: [PATCH] KVM: PPC: Book3S HV: Fix L2 guest reboot failure due to empty 'arch_compat'

2024-01-22 Thread Gautam Menghani
arch_compat = PVR_ARCH_300; > + } else { > + arch_compat = vcpu->arch.vcore->arch_compat; > + } > + rc = kvmppc_gse_put_u32(gsb, iden, arch_compat); > break; > } > > -- > 2.43.0 > I tested this patch on pseries Power 10 machine with KVM support : Without this patch, with the latest mainline as host,the kvm guest on pseries/powervm fails to reboot and with this patch, reboot works fine. Tested-by: Gautam Menghani

[PATCH] arch/powerpc/kvm: Add support for reading VPA counters for pseries guests

2024-03-19 Thread Gautam Menghani
-by: Gautam Menghani --- arch/powerpc/include/asm/kvm_host.h | 5 + arch/powerpc/include/asm/lppaca.h | 11 --- arch/powerpc/kvm/book3s_hv.c| 20 arch/powerpc/kvm/trace_hv.h | 24 4 files changed, 57 insertions(+), 3

[PATCH v2] arch/powerpc/kvm: Add support for reading VPA counters for pseries guests

2024-03-19 Thread Gautam Menghani
-by: Gautam Menghani --- V1 -> V2: 1. Fix the build error due to invalid struct member reference. arch/powerpc/include/asm/kvm_host.h | 5 + arch/powerpc/include/asm/lppaca.h | 11 --- arch/powerpc/kvm/book3s_hv.c| 20 arch/powerpc/kvm/trace_h

[PATCH v3] arch/powerpc/kvm: Add support for reading VPA counters for pseries guests

2024-03-22 Thread Gautam Menghani
the near future. [1] Terminology: a. L1 refers to the VM (LPAR) booted on top of PAPR hypervisor b. L2 refers to the KVM guest booted on top of L1. Signed-off-by: Vaibhav Jain Signed-off-by: Gautam Menghani --- v1 -> v2: 1. Fix the build error due to invalid struct member reference. v2 -&

Re: [PATCH v3] arch/powerpc/kvm: Add support for reading VPA counters for pseries guests

2024-03-24 Thread Gautam Menghani
On Fri, Mar 22, 2024 at 03:41:32PM +0530, Gautam Menghani wrote: > PAPR hypervisor has introduced three new counters in the VPA area of > LPAR CPUs for KVM L2 guest (see [1] for terminology) observability - 2 > for context switches from host to guest and vice versa, and 1 counter > for

[PATCH v4] arch/powerpc/kvm: Add support for reading VPA counters for pseries guests

2024-03-26 Thread Gautam Menghani
the near future. [1] Terminology: a. L1 refers to the VM (LPAR) booted on top of PAPR hypervisor b. L2 refers to the KVM guest booted on top of L1. Signed-off-by: Vaibhav Jain Signed-off-by: Gautam Menghani --- v1 -> v2: 1. Fix the build error due to invalid struct member reference. v2 -&

[PATCH v5] arch/powerpc/kvm: Add support for reading VPA counters for pseries guests

2024-04-01 Thread Gautam Menghani
the near future. [1] Terminology: a. L1 refers to the VM (LPAR) booted on top of PAPR hypervisor b. L2 refers to the KVM guest booted on top of L1. Signed-off-by: Vaibhav Jain Signed-off-by: Gautam Menghani --- arch/powerpc/include/asm/kvm_host.h | 5 arch/powerpc/include/asm/lppaca.h |

[PATCH v5 RESEND] arch/powerpc/kvm: Add support for reading VPA counters for pseries guests

2024-04-02 Thread Gautam Menghani
the near future. [1] Terminology: a. L1 refers to the VM (LPAR) booted on top of PAPR hypervisor b. L2 refers to the KVM guest booted on top of L1. Signed-off-by: Vaibhav Jain Signed-off-by: Gautam Menghani --- v5 RESEND: 1. Add the changelog v4 -> v5: 1. Define helper functions for g

Re: [PATCH] arch/powerpc: Remove unnecessary endian conversion code in XICS

2023-07-26 Thread Gautam Menghani
On Thu, Jul 06, 2023 at 05:50:57PM +1000, Jordan Niethe wrote: > > > On 30/6/23 3:56 pm, Gautam Menghani wrote: > > Remove an unnecessary piece of code that does an endianness conversion but > > does not use the result. The following warning was reported by Clang&

Re: [PATCH] arch/powerpc: Remove unnecessary endian conversion code in XICS

2023-07-26 Thread Gautam Menghani
On Thu, Jul 06, 2023 at 05:50:57PM +1000, Jordan Niethe wrote: > > > On 30/6/23 3:56 pm, Gautam Menghani wrote: > > Remove an unnecessary piece of code that does an endianness conversion but > > does not use the result. The following warning was reported by Clang&

[PATCH v2] arch/powerpc: Remove unnecessary endian conversion code in XICS

2023-07-31 Thread Gautam Menghani
lso removed 'server' from the error message for the call to opal_get_xive(). Fix the warning by removing the server variable assignment. Fixes: bf8e0f891a32 ("powerpc/powernv: Fix endian issues in OPAL ICS backend") Reviewed-by: Jordan Niethe Signed-off-by: Gautam Menghani --

Re: [PATCH] arch/powerpc: Remove unnecessary endian conversion code in XICS

2023-07-31 Thread Gautam Menghani
On Sat, Jul 29, 2023 at 08:54:26PM +1000, Michael Ellerman wrote: > Gautam Menghani writes: > > On Thu, Jul 06, 2023 at 05:50:57PM +1000, Jordan Niethe wrote: > >> On 30/6/23 3:56 pm, Gautam Menghani wrote: > >> > Remove an unnecessary piece of code that does an end

Re: [PATCH 4/12] asm-generic/mmiowb: Mark accesses to fix KCSAN warnings

2023-05-08 Thread Gautam Menghani
KCSAN warnings at consumer's callsites. > > Signed-off-by: Rohan McLure > Reported-by: Michael Ellerman > Reported-by: Gautam Menghani > Acked-by: Arnd Bergmann > --- > include/asm-generic/mmiowb.h | 17 +++-- > 1 file changed, 11 insertions(+), 6 del

Re: [PATCH RFC v2 6/6] docs: powerpc: Document nested KVM on POWER

2023-06-06 Thread Gautam Menghani
On Mon, Jun 05, 2023 at 04:48:48PM +1000, Jordan Niethe wrote: > From: Michael Neuling Hi, There are some minor typos in the documentation pointed out below > +H_GUEST_GET_STATE() > +--- > + > +This is called to get state associated with an L2 (Guest-wide or vCPU > specific). >

[PATCH] arch/powerpc: Remove unnecessary endian conversion code in XICS

2023-06-29 Thread Gautam Menghani
server = be16_to_cpu(oserver); As the result of endianness conversion is never used, delete the line and fix the warning. Signed-off-by: Gautam Menghani --- arch/powerpc/sysdev/xics/ics-opal.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/powerpc/sysdev/xics/ics-opal.c b/arch/powe

[PATCH] arch/powerpc: Remove unnecessary endian conversion code in XICS

2023-06-29 Thread Gautam Menghani
server = be16_to_cpu(oserver); As the result of endianness conversion is never used, delete the line and fix the warning. Signed-off-by: Gautam Menghani --- arch/powerpc/sysdev/xics/ics-opal.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/powerpc/sysdev/xics/ics-opal.c b/arch/powe

Re: [PATCH] arch/powerpc: Remove unnecessary endian conversion code in XICS

2023-06-29 Thread Gautam Menghani
On Fri, Jun 30, 2023 at 11:43:26AM +0530, Gautam Menghani wrote: > Remove an unnecessary piece of code that does an endianness conversion but > does not use the result. The following warning was reported by Clang's > static analyzer: > > arch/powerpc/sysdev/xics/ics-opal.c:1

Re: [PATCH] arch/powerpc: Remove unnecessary endian conversion code in XICS

2023-07-11 Thread Gautam Menghani
On Thu, Jul 06, 2023 at 05:50:57PM +1000, Jordan Niethe wrote: > > > On 30/6/23 3:56 pm, Gautam Menghani wrote: > > Remove an unnecessary piece of code that does an endianness conversion but > > does not use the result. The following warning was reported by Clang&

Re: [PATCH] arch/powerpc/kvm: Avoid extra checks when emulating HFSCR bits

2024-07-14 Thread Gautam Menghani
Hello, Please review this patch and let me know if any changes are needed. Thanks, Gautam

Re: [PATCH] arch/powerpc/kvm: Avoid extra checks when emulating HFSCR bits

2024-07-16 Thread Gautam Menghani
On Tue, Jul 16, 2024 at 11:17:13AM GMT, Michael Ellerman wrote: > Gautam Menghani writes: > > When a KVM guest tries to use a feature disabled by HFSCR, it exits to > > the host for emulation support, and the code checks for all bits which > > are emulated. Avoid checking al

[PATCH v2] KVM: PPC: Book3S HV: Refactor HFSCR emulation for KVM guests

2024-07-16 Thread Gautam Menghani
Refactor HFSCR emulation for KVM guests when they exit out with H_FAC_UNAVAIL to use a switch case instead of checking all "cause" values, since the "cause" values are mutually exclusive; and this is better expressed with a switch case. Signed-off-by: Gautam Menghani ---