public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Donnellan <ajd@linux.ibm.com>
To: Heiko Carstens <hca@linux.ibm.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Vasily Gorbik	 <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Sven Schnelle	 <svens@linux.ibm.com>,
	Nicholas Miehlbradt <nicholas@linux.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Andy Lutomirski	 <luto@kernel.org>,
	David Hildenbrand <david@kernel.org>
Subject: Re: [PATCH 3/3] KVM: s390: Use generic VIRT_XFER_TO_GUEST_WORK functions
Date: Wed, 26 Nov 2025 13:01:26 +1100	[thread overview]
Message-ID: <bec71a9ee80b6493da75693808ec846cca56343b.camel@linux.ibm.com> (raw)
In-Reply-To: <20251125111618.10410Fa0-hca@linux.ibm.com>

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@linux.ibm.com   IBM Australia Limited

      reply	other threads:[~2025-11-26  2:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-25  7:45 [PATCH 0/3] KVM: s390: Use generic VIRT_XFER_TO_GUEST_WORK entry helpers Andrew Donnellan
2025-11-25  7:45 ` [PATCH 1/3] KVM: s390: Add signal_exits counter Andrew Donnellan
2025-11-25  7:45 ` [PATCH 2/3] KVM: s390: Enable and disable interrupts in entry code Andrew Donnellan
2025-11-25  7:45 ` [PATCH 3/3] KVM: s390: Use generic VIRT_XFER_TO_GUEST_WORK functions Andrew Donnellan
2025-11-25 11:16   ` Heiko Carstens
2025-11-26  2:01     ` Andrew Donnellan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bec71a9ee80b6493da75693808ec846cca56343b.camel@linux.ibm.com \
    --to=ajd@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=david@kernel.org \
    --cc=frankja@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=nicholas@linux.ibm.com \
    --cc=peterz@infradead.org \
    --cc=svens@linux.ibm.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox