[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Updates to Xen hypercall preemption


  • To: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
  • From: Per Bilse <Per.Bilse@xxxxxxxxxx>
  • Date: Wed, 21 Jun 2023 19:19:21 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gL5JnXuT2ZqtMdc2o/AZh0m3G5nUqpWXd+Ha+AGpDMM=; b=KGMbPmZtYqy93+cTWAf3i0awPyez+OmW+KCUrTbwZoFYP48RAknVbe7X0KocvpHcgJFvhj6e2lTmzZTBYQU7LZxBhCrsIu9edk64rdftdt5uZMad7fJ3tHY9G8N6PSydyiMebpAk07fItClyACQc3FCZ6V6L34QZ6Li9Mll1tlWuV5NYG0CrBmvDL7KVeQ7KAD0BdrXtSfYGGPQhloilo8ezUJIbOZVuYw08UUKnrlYjFgBDh0nbqWewXXlEgDbgDTCbt+Cc31zRoeGbtuXW8BdJor7rMbn8c7ozrnYnHqfc7Pt7+BrwrJay4eyrp4wB8+UEz5IEcHbB1UVEuEoC7A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YL1S6VbhNm8HdJs9swv3lXbhqGBlFN4YHsMA2c09CslXexHYTaMJexRX+degl3F4ofg5EDAdTDEYMGGKYAVk1m+Xyx+QcWyBce5k/6QR1C1O+UVMhrmHAY28o9aVfFHGEeaShWoeSWBVhKmE8Rf7g16nzlmXbPMWGzM5lg11Z5AEGrUdH9rldeSekR6Zj9nF2d7emBQBoftbUlGiYRzHfMNN6D+PaqVslOwV9A7DNCDSeP92/m2iSfeyfOLY3KpNMbvojOXyM1HzKbPD8iYD0HPBf94Y4geDbVYyfnzQ2JCxXGfEWair3C3KsaDf9eTKwAvhGkkSY7khb+uOycnebw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andy Lutomirski <luto@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@xxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, "open list:X86 ENTRY CODE" <linux-kernel@xxxxxxxxxxxxxxx>, "moderated list:XEN HYPERVISOR INTERFACE" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 21 Jun 2023 19:19:45 +0000
  • Ironport-data: A9a23:POlBcaMkSy8x4v3vrR2hl8FynXyQoLVcMsEvi/4bfWQNrUpz0TUPn GJJXm2PPq7YNmX3KtxwaNnl90xQu8Tcz9diHAto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CU6jufQAOKnUoYoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGjxSs/rrRC9H5qyo42tG5AVmOZingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0rctQj5x9 eY3EQEyZ0ykv7u34oyAGvY506zPLOGzVG8ekldJ6GiASNoDH9XESaiM4sJE1jAtgMwIBezZe 8cSdTtoalLHfgFLPVAUTpk5mY9EhFGmK2Ee9A3T+PVxujePpOBy+OGF3N79QtGQA+9Uml2Vj mnH4374ElcRM9n3JT+tqyv32L+QxnunMG4UPLO20d5MhEaX/VMeIgMkWAak/6mwgVHrDrqzL GRRoELCt5Ma7EG3Q8Pvdxy+rmSNshMVV5xXCeJSwAWQ1q384AuDAGUACDlbZ7QOqMAyVRQu1 1mUg8nuAz1/9rGYIVqY97GbqhuoNCQVJHNEbigBJSMP+/HqpIA+iEKJQtsLOKK8kNCzGTj22 D2MhCw/gagDy88Ny6i/u1vAhlqEtsiXZg04/APaWiSi9AwRTI69bqS6+ETc97BLK4PxZluOp n8fgOCF8fsDS5qKkUSlW/4RFbuk4/KENjz0glN1GZQlsTO39BaLeoRd4yp3IktzBdoVYj/iY ELVugR56YdaOT2haqofS4awDdk6iKvtD9LoUtjKYddUJJt8bgmK+Gdpf0H493Dglg0gnL8yP b+fcN2wFjAKBKJ/1j20SuwBl7gxyUgDKXj7QJn6y1Gr1OSYbXvMELMdagLRMqY+8b+OpxjT/ 5BHLcyWxh5DUer4JC7K7YoUKlNMJn8+bXzrl/Fqmie4ClIOMAkc5zX5m9vNp6QNc3xpq9r1
  • Ironport-hdrordr: A9a23:fl9ZhaDJL+nqnAflHelW55DYdb4zR+YMi2TDt3oddfWaSKylfq GV7ZAmPHrP4gr5N0tOpTntAse9qBDnhPtICOsqTNSftWDd0QPFEGgL1+DfKlbbak/DH4BmtJ uJc8JFeaDN5VoRt7eH3OFveexQv+Vu88qT9JnjJ28Gd3AMV0n5hT0JcTpyFCdNNW97LKt8Lr WwzOxdqQGtfHwGB/7LfEXsD4D41qT2fIuNW29/OyIa
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZpFMl91hHG7ZDuUq21h7QjP0mVK+VdZEAgAAsiIA=
  • Thread-topic: [PATCH] Updates to Xen hypercall preemption

On 6/21/2023 5:40 PM, Peter Zijlstra wrote:
> I don't understand it -- fundamentally, how can linux schedule when the
> guest isn't even running? Hypercall transfers control to the
> host/hypervisor and leaves the guest suspended.

Hi Peter, as noted in earlier note to Andy, this is essentially existing
code that other commits have rendered ineffective over time.  Hence,
the finer details of how or why it works haven't changed since it was
first introduced.

> This makes no sense; the race that warning warns about is:
> 
>       CPU0                    CPU1
>       per-cpu write
>       <preempt-out>
>                               <preempt-in>
>                               do-hypercall
> 
> So you wrote the value on CPU0, got migrated to CPU1 because you had
> preemptioned enabled, and then continue with the percpu value of CPU1
> because that's where you're at now.

This issue was raised internally, and it was noted that the only way
for the preemptible code to switch task is via an interrupt that goes
through xen_pv_evtchn_do_upcall(), which handles this.  I'm happy to
check with my sources, but it's holiday season right now.

>> 4) Update irqentry_exit_cond_resched() to raw_irqentry_exit_cond_resched().
>> The code will call irqentry_exit_cond_resched() if the flag (as noted
>> above) is set, but the dynamic preemption feature will livepatch that
>> function to a no-op unless full preemption is selected.  The code is
>> therefore updated to call raw_irqentry_exit_cond_resched().
> 
> That, again meeds more explanation. Why do you want this if not
> preemptible?

I'm not quite sure what you mean here.  Dynamic preemption
will livepatch irqentry_exit_cond_resched() to be a no-op, while
raw_irqentry_exit_cond_resched() remains functional.  This was 
introduced in commit 4624a14f4daa last year which was said to fix
the problem, but doesn't.  You may remember, it was signed off by 
yourself and Mark Rutland.

> You're doing 4 things, that should be 4 patches. Also, please give more
> clues for how this is supposed to work at all.

I respectfully have to disagree with that.  The fixes here are very
closely related, and we're not introducing anything new, we're merely
re-enabling code which has been rendered ineffective due to oversights
in commits made after the code was first introduced.  How the code is
supposed to work hasn't changed, and is beyond the scope of these fixes;
I'm sure it must have been discussed at great length at the time (commit 
fdfd811ddde3).

Best,

   -- Per


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.