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

Re: [PATCH v2] x86/mm: limit deferred TLB flushing to PV domain support


  • To: Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Wed, 9 Sep 2026 16:07:32 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=/0gX/DTWEj0mwqiaGPrnbN628OX8x2I7RIGGS0EYmiQ=; b=rEQ9LzKW/dVssnGIvjEHTD6bdXswL6QU3+c+R8rPyfrjQ1FU1A1ysA7q8RRAxsNWc/AQb6KmcNxOnTOr1/8H0dJZ1tjKny1jCPkxcLDYyGv1r7WyrOt6jPEpvVMqpFi/XIj7bA3pnceCMUzdwdkOMe/bid0g+ILglcH0ZyZaN40lJsdvk6DIS2Qlo55Q+CCXVoMhuiOoC7lziOaUfpHPXq4YfZ8lOL40mT/QrM85wNL4+Nl8WzHLBHTRTv9aQ7vaXjvyt7Q3wTRILIG1l6kb2qkfqxbD2ACDeeLdfpVeTCpDycosXdER5wEmksAZFwi4mfMu8zy8RRChZcwuuv0Qmw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r645R55wjpqgnhqxdzM/ms7FZSpnLRXeNWiZEt5YC2SQx2oUUPoEbRxWGJPZMapxIH8bPDHp4thObFYBYz1eFfaDQhMqHu6vJ6A0s067mFhgt3i1Aaan1bcYW675lFGb41udb0TWs/AqZXarlgmrkCwSsZkLPJcSBSgbMWQTUoBQJwBUvxfuWNO8lhZelexI1imPdQqeAEd64A2hhbxSsODOTG2hEEQyK6lDIqPp1FzzCFrnRd01R+ZH74/evtxdfp01Un4jK4XirNx0kQus4IMwaNut4LKdH7DbK5h9ZNHY0SiC46nLLP38zvr1xTqtew5GtNbsNUKbxDn0OghX6g==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Julien Grall" <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 09 Sep 2026 20:07:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2026-09-09 12:28, Roger Pau Monné wrote:
On Wed, Sep 09, 2026 at 04:46:01PM +0200, Jan Beulich wrote:
On 09.09.2026 16:05, Roger Pau Monne wrote:
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -1538,8 +1538,11 @@ static bool mark_page_free(struct page_info *pg, mfn_t 
mfn)
          BUG();
      }
- /* If a page has no owner it will need no safety TLB flush. */
-    pg->u.free.need_tlbflush = (page_get_owner(pg) != NULL);
+    /*
+     * If a page has no owner and there's no PV domain support it will need no
+     * safety TLB flush, there can be no stale TLB entries.
+     */
+    pg->u.free.need_tlbflush = IS_ENABLED(CONFIG_PV) && page_get_owner(pg);
      if ( pg->u.free.need_tlbflush )
          page_set_tlbflush_timestamp(pg);

I'm okay with the code change now, but the comment is still concerning me.
All by itself there is no reason why stale TLB entries couldn't also exist
for HVM guests. It's just that (a) only the host TLBs are flushed by
filtered_flush_tlb_mask() and (b) flushes of guest TLBs occur when pages
are removed from their P2Ms (aiui; hopefully true also for Arm). IOW what
the comment says looks to be correct, just that it leaves too much to be
figured out by the reader. At the very least I'd suggest "..., there can
be no stale (host) TLB entries." Thoughts?

Hm, I find adding "(host)" to also be slightly confusing, as I would
usually associate host TLB with Xen context TLB state.  Which is also
made more confusing by how PV guests share the page-tables with Xen.

"If a page has no owner and there's no PV domain support it will need
no safety TLB flush.  PV domains are the only domain types that can
keep stale entries on the TLB, as they have (limited) control over the
host MMU and when flushes are performed"
I find "will need no" a little awkward.  Maybe:

"If a page has no owner and there's no PV domain support it does not need a safety TLB flush."

or:

"If a page has no owner and there's no PV domain support, then a safety TLB flush is not needed."

Regards,
Jason



 


Rackspace

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