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

Re: [PATCH] x86/hap: Defer P2M TLB flushes


  • To: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 19 Mar 2026 10:08:42 +0100
  • 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=arcselector10001; 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=7I/PDk8ghjn+CiK62ovORrPQlqhmJqQdCmbc/U8ZdqE=; b=iycYcfwUGgQM7bxP9pB1wVcYMrMGNU0KUI4u31R++TPfrmg26KJA5JAnedZuXxhFxZV0Ppys5UsgV2egpb2m7zVHksUcvj/cDqhI9Bk4EQGkW/t61SFiW7reiXzHTKoTK+heQOR6F2StnGvBTY5wvKMuPYcSwr9SRCFHg3nvFnLrXUeY9+DUh9vSRxiUzAYDGVD0tUBItYFBbOtH7Qql7RjAPSHxl76SUHQ6mMyJ8YLJHPLaEWk+qZyah7Yx32FIJkY3GG1+RGROvlCyVpz7PQP3ueEfIhvziu+dQcnXZuf2wktk7FeQT59M7bRqD2bgkn0AeAImQ5ZZfIOSCvPKTQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EkUk2jrs2tnnNLC6QBVAlt26wEnq6CR+qObIfKDh3ZH6IT5AYlViJ1hWMHKS4PXeWa3HYRXD4QkCsm7zT5qF2p/wHdZwHHhtrHBdI4Vn+VnGgVB/2r52ETeEmWTLr+2gT2PcyYsqv7HFXZSxvQOnP8fvpH5vzsPKzkowjOGKqilJOYCSQa3Aqx3UI1AqkwdfPZ2x/u6vIpnI2oWo1v90uDcnnE42AqV4EZFy/A55UKWzvOM4WqwwdBHzD4ucHw16ISkhWnYnhNCgbVFbuebN5UBxP0VgtZlKveW9dDM9jsZw1W3AVeuById9I7AXi9qSJOB4pVJX6jSFm18zZuOtMA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Thu, 19 Mar 2026 09:08:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The subject should possibly mention NPT, as reading HAP one would
assume it applies to both EPT and NPT (and the EPT side is already
done here):

x86/hap: Defer NPT P2M TLB flushes

On Wed, Mar 18, 2026 at 05:13:24PM +0000, Ross Lagerwall wrote:
> Like the EPT code, defer TLB flushes to reduce the number of flushes and
> avoid holding the P2M lock while flushing. This can substantially
> improve performance in some scenarios.
> 
> The cases where the TLB needs to be flushed without deferring are
> already handled by the call to p2m_tlb_flush_sync() in p2m_free_ptp().
> 
> Suggested-by: Roger Pau Monne <roger.pau@xxxxxxxxxx>
> Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
> ---
>  xen/arch/x86/mm/hap/hap.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c
> index a337752bf488..1eba995c7b39 100644
> --- a/xen/arch/x86/mm/hap/hap.c
> +++ b/xen/arch/x86/mm/hap/hap.c
> @@ -813,16 +813,26 @@ static void cf_check hap_update_paging_modes(struct 
> vcpu *v)
>  
>  static void cf_check
>  hap_write_p2m_entry_post(struct p2m_domain *p2m, unsigned int oflags)
> +{
> +    if ( oflags & _PAGE_PRESENT )
> +    {
> +        ASSERT(p2m->defer_flush);

Here I'm unsure whether we might want to do:

if ( !p2m->defer_flush )
{
    ASSERT_UNREACHABLE();
    guest_flush_tlb_mask(d, d->dirty_cpumask);
}

Instead of just asserting that the defer_flush field is set, to be on
the safe(r) side.

Thanks, Roger.



 


Rackspace

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