[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <bec71a9ee80b6493da75693808ec846cca56343b.camel@linux.ibm.com>
Date: Wed, 26 Nov 2025 13:01:26 +1100
From: Andrew Donnellan <ajd@...ux.ibm.com>
To: Heiko Carstens <hca@...ux.ibm.com>
Cc: kvm@...r.kernel.org, linux-s390@...r.kernel.org,
linux-kernel@...r.kernel.org,
Christian Borntraeger
<borntraeger@...ux.ibm.com>,
Janosch Frank <frankja@...ux.ibm.com>,
Claudio Imbrenda <imbrenda@...ux.ibm.com>,
Vasily Gorbik
<gor@...ux.ibm.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Sven
Schnelle <svens@...ux.ibm.com>,
Nicholas Miehlbradt
<nicholas@...ux.ibm.com>,
Thomas Gleixner <tglx@...utronix.de>,
Peter
Zijlstra <peterz@...radead.org>,
Andy Lutomirski <luto@...nel.org>,
David
Hildenbrand <david@...nel.org>
Subject: Re: [PATCH 3/3] KVM: s390: Use generic VIRT_XFER_TO_GUEST_WORK
functions
On Tue, 2025-11-25 at 12:16 +0100, Heiko Carstens wrote:
> On Tue, Nov 25, 2025 at 06:45:54PM +1100, Andrew Donnellan wrote:
> > Switch to using the generic infrastructure to check for and handle pending
> > work before transitioning into guest mode.
> >
> > xfer_to_guest_mode_handle_work() does a few more things than the current
> > code does when deciding whether or not to exit the __vcpu_run() loop. The
> > exittime tests from kvm-unit-tests, in my tests, were +/-3% compared to
> > before this series, which is within noise tolerance.
>
> ...
>
> > local_irq_disable();
> > +
> > + xfer_to_guest_mode_prepare();
> > + if (xfer_to_guest_mode_work_pending()) {
> > + local_irq_enable();
> > + rc = kvm_xfer_to_guest_mode_handle_work(vcpu);
> > + if (rc)
> > + break;
> > + local_irq_disable();
> > + }
> > +
> > guest_timing_enter_irqoff();
> > __disable_cpu_timer_accounting(vcpu);
>
> This looks racy: kvm_xfer_to_guest_mode_handle_work() returns with
> interrupts enabled and before interrupts are disabled again more work
> might have been become pending. But that is ignored and guest state is
> entered instead. Why not change the above simply to something like
> this to avoid this:
>
> again:
> local_irq_disable();
> xfer_to_guest_mode_prepare();
> if (xfer_to_guest_mode_work_pending()) {
> local_irq_enable();
> rc = kvm_xfer_to_guest_mode_handle_work(vcpu);
> if (rc)
> break;
> goto again;
> }
>
> guest_timing_enter_irqoff();
> __disable_cpu_timer_accounting(vcpu);
>
> But maybe I'm missing something?
Agreed, I'll restructure this and respin.
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@...ux.ibm.com IBM Australia Limited
Powered by blists - more mailing lists