All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger@xenproject.org>
To: George Dunlap <gwd@xenproject.org>
Cc: xen-devel@lists.xenproject.org, Jan Beulich <jbeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Teddy Astie <teddy.astie@vates.tech>
Subject: Re: [PATCH v3 12/18] x86/mm: let Xen's page-table walker operate on a given root
Date: Wed, 14 Oct 2026 10:08:36 +0200	[thread overview]
Message-ID: <as84hK0aO2PFub9w@Mac.lan> (raw)
In-Reply-To: <CAFLBxZYSYKdkyC997x0s+EWgHOdL=CYWi_tvanod9ryGeE9PMA@mail.gmail.com>

On Tue, Oct 13, 2026 at 09:37:53PM +0100, George Dunlap wrote:
> On Thu, Oct 8, 2026 at 3:59 PM Roger Pau Monné <roger@xenproject.org> wrote:
> >
> > On Wed, Oct 07, 2026 at 11:40:45AM +0100, George Dunlap wrote:
> > > map_pages_to_xen() and modify_xen_mappings() maintain Xen's own mappings,
> > > walking from idle_pg_table, whose Xen slots every other root page-table
> > > copies.  A later patch introduces a second directmap hierarchy: page
> > > tables for the directmap virtual address range that some guest contexts
> > > use in place of idle_pg_table's.  It needs the same maintenance at the
> > > same virtual addresses.
> >
> > I assume that "second directmap hierarchy" refers to the sparse
> > directmap approach?
> 
> Yes.  Should I change it to "a second, sparse directmap hierarchy"?  I
> think raising that we're going to be maintaining parallel hierarchies
> is important.

I think that would be clearer.

> 
> > > Give virt_to_xen_l{3,2,1}e() the L4 to walk from, and move the bodies of
> > > map_pages_to_xen() and modify_xen_mappings() into map_pages_in() and
> > > modify_mappings_in(), which take the root as well.  The public functions
> > > pass idle_pg_table.  The EFI runtime-services page-tables mirror
> > > idle_pg_table's L4 entries only, so a newly allocated L3 is propagated
> > > to them only when the root is idle_pg_table.
> > >
> > > TLB flushing is unaffected: it is by virtual address, and the same
> > > addresses are mapped in either hierarchy.
> >
> > The virtual address space is just part of it, so far
> > map_pages_to_xen() has been doing global TLB flushes, because all CPUs
> > used the same page-tables for the Xen slots that map_pages_to_xen()
> > modifies.  With the change to pass different L4, there's also the
> > assumption that the Xen slots on those L4 will be different, and hence
> > not all CPUs might need flushing?
> >
> > Maybe I'm thinking ahead too much - but if this is going to be used to
> > manage the sparse directmap we might want to avoid IPIs to CPUs that
> > are running with the full directmap when the sparse one is changed,
> > as those are useless.
> 
> Yes; changes to both "views" (e.g., map_pages_to_xen()) still need to
> flush on all CPUs; but changes only to the sparse "view" (e.g.,
> removing pages on free_xenheap_pages()) could send an IPI only to CPUs
> with the sparse view running on it.  We could keep a cpumask with
> which CPUs currently have sparse directmaps loaded, and only IPI
> those.
> 
> That said, maintaining the cpumask isn't free; it would cause some
> cacheline bouncing as vCPUs are scheduled in and out; and since the
> idle vCPU has the full directmap, even a system with all "normal"
> domains using the sparse map would still need to update it constantly.
> Not sure how often free_xenheap_pages() happens, but if it's not very
> frequent, it might not be worth the cache consistency overhead (and
> the extra complication).  I'd leave this as a potential future
> improvement.

Worth adding a TODO comment somewhere about the fact that
map_pages_to_xen() is likely doing too many flushes when used to
manage the sparse directmap.  Without going into the more complex
approach of tracking which CPUs are running with the sparse directmap,
we could do batch flushes in add_to_sparse_view() for example, as the
flush could be pulled out of the map_pages_in() loop.

Regards, Roger.


  reply	other threads:[~2026-10-14  8:09 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 10:40 [PATCH v3 00/18] ASI: HVM per-vCPU areas and sparse-view directmap George Dunlap
2026-10-07 10:40 ` [PATCH v3 01/18] x86/PoD: map one page at a time in p2m_pod_zero_check() George Dunlap
2026-10-07 10:51   ` Jan Beulich
2026-10-07 12:33   ` Andrew Cooper
2026-10-07 12:38   ` Andrew Cooper
2026-10-08 11:09     ` George Dunlap
2026-10-08 22:24       ` Andrew Cooper
2026-10-07 10:40 ` [PATCH v3 02/18] x86/mm: purge unneeded destroy_perdomain_mapping() George Dunlap
2026-10-07 14:06   ` Roger Pau Monné
2026-10-07 14:24     ` Jan Beulich
2026-10-08 12:19       ` George Dunlap
2026-10-08  7:55   ` Jan Beulich
2026-10-08  8:31     ` Roger Pau Monné
2026-10-08 12:27       ` George Dunlap
2026-10-07 10:40 ` [PATCH v3 03/18] x86/mm: prepare destroy_perdomain_mapping() for per-vCPU perdomain areas George Dunlap
2026-10-07 15:58   ` Roger Pau Monné
2026-10-08 13:27     ` George Dunlap
2026-10-07 10:40 ` [PATCH v3 04/18] x86/domain_page: drop redundant create_perdomain_mapping() call George Dunlap
2026-10-07 16:14   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 05/18] x86/mm: prepare create_perdomain_mapping() for per-vCPU perdomain areas George Dunlap
2026-10-07 16:31   ` Roger Pau Monné
2026-10-12 12:44     ` George Dunlap
2026-10-08  8:05   ` Jan Beulich
2026-10-07 10:40 ` [PATCH v3 06/18] x86/spec-ctrl: introduce Address Space Isolation command line option George Dunlap
2026-10-07 16:52   ` Roger Pau Monné
2026-10-12 12:47     ` George Dunlap
2026-10-08  8:24   ` Jan Beulich
2026-10-12 12:48     ` George Dunlap
2026-10-07 10:40 ` [PATCH v3 07/18] x86/hvm: introduce per-vCPU L3 page-table George Dunlap
2026-10-07 19:21   ` Roger Pau Monné
2026-10-08 20:55     ` George Dunlap
2026-10-08  8:40   ` Jan Beulich
2026-10-08 21:00     ` George Dunlap
2026-10-09  7:06       ` Jan Beulich
2026-10-07 10:40 ` [PATCH v3 08/18] x86/domain_page: prepare the mapcache for per-vCPU accounting George Dunlap
2026-10-08  8:22   ` Roger Pau Monné
2026-10-12 14:19     ` George Dunlap
2026-10-13 10:50       ` Roger Pau Monné
2026-10-12 13:48   ` Jan Beulich
2026-10-12 16:07     ` George Dunlap
2026-10-13  6:25       ` Jan Beulich
2026-10-13  9:53         ` George Dunlap
2026-10-13 11:56           ` Jan Beulich
2026-10-13 15:48             ` George Dunlap
2026-10-07 10:40 ` [PATCH v3 09/18] x86/domain_page: move struct mapcache_vcpu to struct arch_vcpu George Dunlap
2026-10-08  8:28   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 10/18] x86/domain_page: don't unmap a mapcache entry that is not present George Dunlap
2026-10-08 11:03   ` Roger Pau Monné
2026-10-13 10:33     ` George Dunlap
2026-10-13 10:55       ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 11/18] x86/hvm: introduce per-vCPU mapcache for vCPU-PT domains George Dunlap
2026-10-08 13:56   ` Roger Pau Monné
2026-10-13 16:23     ` George Dunlap
2026-10-07 10:40 ` [PATCH v3 12/18] x86/mm: let Xen's page-table walker operate on a given root George Dunlap
2026-10-08 14:58   ` Roger Pau Monné
2026-10-13 20:37     ` George Dunlap
2026-10-14  8:08       ` Roger Pau Monné [this message]
2026-10-14  8:49         ` George Dunlap
2026-10-07 10:40 ` [PATCH v3 13/18] x86/mm: build and maintain a sparse view of the directmap George Dunlap
2026-10-07 15:20   ` George Dunlap
2026-10-08 18:02   ` Roger Pau Monné
2026-10-14 10:04     ` George Dunlap
2026-10-07 10:40 ` [PATCH v3 14/18] x86/domain_page: key the directmap fast paths on the loaded view George Dunlap
2026-10-08 18:51   ` Roger Pau Monné
2026-10-14 12:30     ` George Dunlap
2026-10-07 10:40 ` [PATCH v3 15/18] x86/mm: flush owned pages before reuse with the sparse directmap view George Dunlap
2026-10-08 19:00   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 16/18] x86/domain_page: keep the maphash's slots, not their mappings George Dunlap
2026-10-08 19:08   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 17/18] x86/mm: run guest contexts on the sparse directmap view George Dunlap
2026-10-09  7:58   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 18/18] x86/spec-ctrl: wire the sparse directmap view into the asi= option George Dunlap
2026-10-08 19:21   ` Roger Pau Monné

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=as84hK0aO2PFub9w@Mac.lan \
    --to=roger@xenproject.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=gwd@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=teddy.astie@vates.tech \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.