From: Juergen Gross <jgross@suse.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Per Bilse <Per.Bilse@citrix.com>,
Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
"open list:X86 ENTRY CODE" <linux-kernel@vger.kernel.org>,
"moderated list:XEN HYPERVISOR INTERFACE"
<xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] Updates to Xen hypercall preemption
Date: Thu, 22 Jun 2023 12:33:31 +0200 [thread overview]
Message-ID: <4d29bfe0-975a-c97f-3e79-5b77d95d3494@suse.com> (raw)
In-Reply-To: <20230622082607.GD4253@hirez.programming.kicks-ass.net>
[-- Attachment #1.1.1: Type: text/plain, Size: 3090 bytes --]
On 22.06.23 10:26, Peter Zijlstra wrote:
> On Thu, Jun 22, 2023 at 07:22:53AM +0200, Juergen Gross wrote:
>
>> The hypercalls we are talking of are synchronous ones. They are running
>> in the context of the vcpu doing the call (like a syscall from userland is
>> running in the process context).
>
> (so time actually passes from the guest's pov?)
Correct.
>
>> The hypervisor will return to guest context from time to time by modifying
>> the registers such that the guest will do the hypercall again with different
>> input values for the hypervisor, resulting in a proper continuation of the
>> hypercall processing.
>
> Eeeuw.. that's pretty terrible. And changing this isn't in the cards,
> like at all?
In the long run this should be possible, but not for already existing Xen
versions.
>
> That is, why isn't this whole thing written like:
>
> for (;;) {
> ret = hypercall(foo);
> if (ret == -EAGAIN) {
> cond_resched();
> continue;
> }
> break;
> }
The hypervisor doesn't return -EAGAIN for hysterical reasons.
This would be one of the options to change the interface. OTOH there are cases
where already existing hypercalls need to be modified in the hypervisor to do
preemption in the middle due to e.g. security reasons (avoiding cpu hogging in
special cases).
Additionally some of the hypercalls being subject to preemption are allowed in
unprivileged guests, too. Those are mostly hypercalls allowed for PV guests
only, but some are usable by all guests.
>
>> It is an awful interface and I agree that switching to full preemption in
>> dom0 seems to be the route which we should try to take.
>
> Well, I would very strongly suggest the route to take is to scrap the
> whole thing and invest in doing something saner so we don't have to jump
> through hoops like this.
>
> This is quite possibly the worst possible interface for this Xen could
> have come up with -- awards material for sure.
Yes.
>
>> The downside would be that some workloads might see worse performance
>> due to backend I/O handling might get preempted.
>
> Is that an actual concern? Mark this a legaxy inteface and anybody who
> wants to get away from it updates.
It isn't that easy. See above.
>
>> Just thinking - can full preemption be enabled per process?
>
> Nope, that's a system wide thing. Preemption is something that's driven
> by the requirements of the tasks that preempt, not something by the
> tasks that get preempted.
Depends. If a task in a non-preempt system could switch itself to be
preemptable, we could do so around hypercalls without compromising the
general preemption setting. Disabling preemption in a preemptable system
should continue to be possible for short code paths only, of course.
> Andy's idea of having that thing intercepted as an exception (EXTABLE
> like) and relocating the IP to a place that does cond_resched() before
> going back is an option.. gross, but possibly better, dunno.
>
> Quite the mess indeed :/
Yeah.
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
next prev parent reply other threads:[~2023-06-22 10:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-21 15:14 Per Bilse
2023-06-21 16:27 ` Andy Lutomirski
2023-06-21 19:05 ` Per Bilse
2023-06-21 23:42 ` Andy Lutomirski
2023-06-21 16:40 ` Peter Zijlstra
2023-06-21 19:19 ` Per Bilse
2023-06-21 20:04 ` Peter Zijlstra
2023-06-22 5:22 ` Juergen Gross
2023-06-22 8:26 ` Peter Zijlstra
2023-06-22 10:33 ` Juergen Gross [this message]
2023-06-22 11:15 ` Peter Zijlstra
2023-06-22 12:17 ` Juergen Gross
2023-06-22 16:39 ` Andy Lutomirski
2023-06-22 17:20 ` Juergen Gross
2023-06-24 15:19 ` Andy Lutomirski
2023-06-22 13:05 ` Andrew Cooper
2023-06-22 13:14 ` Peter Zijlstra
2023-06-22 13:35 ` Juergen Gross
2023-06-22 10:01 ` Per Bilse
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=4d29bfe0-975a-c97f-3e79-5b77d95d3494@suse.com \
--to=jgross@suse.com \
--cc=Per.Bilse@citrix.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=oleksandr_tyshchenko@epam.com \
--cc=peterz@infradead.org \
--cc=sstabellini@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/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
all inboxes | Powered by JetHome®