Re: [PATCH v4 18/20] KVM: s390: vsie: Add VSIE shadow stat counters
| Newsgroups | org.kernel.vger.linux-s390,org.kernel.vger.kvm |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The `vsie_shadow_scb` statistic undercounts allocated shadow SCB pages if their initialization fails, and incorrectly categorizes subsequent uses as reuses. -- --- Patch [18]: [PATCH v4 18/20] KVM: s390: vsie: Add VSIE shadow stat counters --- commit 30e90ae4cab73ef72cfd191918cda52ff46f4c0c Author: Christoph Schlameuss <[email protected]> KVM: s390: vsie: Add VSIE shadow stat counters This commit adds new statistics counters to track the allocation and reuse of VSIE shadow SCBs and SCAs. > diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c > index 5f6dd4b9e9fd7..a1b679b4aa361 100644 > --- a/arch/s390/kvm/vsie.c > +++ b/arch/s390/kvm/vsie.c [ ... ] > @@ -2042,6 +2047,7 @@ static struct vsie_page *get_vsie_page_cpu_nr(struct kvm_vcpu *vcpu, struct vsie > } > } > if (vsie_page != vsie_page_new) { > + vsie_page_is_new = false; > if (vsie_page_new) > free_vsie_page(vsie_page_new); > > @@ -2059,6 +2065,11 @@ static struct vsie_page *get_vsie_page_cpu_nr(struct kvm_vcpu *vcpu, struct vsie > put_vsie_page(vsie_page); > return ERR_PTR(rc); > } > + > + if (vsie_page_is_new) > + vcpu->kvm->stat.vsie_shadow_scb++; > + else > + vcpu->kvm->stat.vsie_shadow_scb_reuse++; > } > > return vsie_page; [Severity: Medium] Will this lead to an undercount of vsie_shadow_scb allocations if vsie_page_init() fails? If vsie_page_init() fails in get_vsie_page_cpu_nr(), it returns ERR_PTR(rc) and skips the stat increment here. However, the newly allocated page is already saved in vsie_sca->pages[cpu_nr] earlier in the function. The next time this page is fetched from the array, vsie_page_is_new will evaluate to false, causing vsie_shadow_scb_reuse to be incremented instead of counting the initial allocation. Should the vsie_shadow_scb counter be incremented earlier upon successful allocation, or should the page be removed from vsie_sca->pages[cpu_nr] on error? -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=18