From: Julien Grall <julien.grall@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: "Wei Liu" <wei.liu2@citrix.com>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"George Dunlap" <George.Dunlap@eu.citrix.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Ian Jackson" <ian.jackson@eu.citrix.com>,
"Tim Deegan" <tim@xen.org>, "Jan Beulich" <jbeulich@suse.com>,
xen-devel@lists.xenproject.org,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH for-4.12 v2 17/17] xen/arm: Track page accessed between batch of Set/Way operations
Date: Tue, 11 Dec 2018 16:22:07 +0000 [thread overview]
Message-ID: <9dfc25ea-a26a-21f8-2406-10c22b723184@arm.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1812071332060.18779@sstabellini-ThinkPad-X260>
Hi Stefano,
On 07/12/2018 21:43, Stefano Stabellini wrote:
> On Tue, 4 Dec 2018, Julien Grall wrote:
>> At the moment, the implementation of Set/Way operations will go through
>> all the entries of the guest P2M and flush them. However, this is very
>> expensive and may render unusable a guest OS using them.
>>
>> For instance, Linux 32-bit will use Set/Way operations during secondary
>> CPU bring-up. As the implementation is really expensive, it may be possible
>> to hit the CPU bring-up timeout.
>>
>> To limit the Set/Way impact, we track what pages has been of the guest
>> has been accessed between batch of Set/Way operations. This is done
>> using bit[0] (aka valid bit) of the P2M entry.
>>
>> This patch adds a new per-arch helper is introduced to perform actions just
>> before the guest is first unpaused. This will be used to invalidate the
>> P2M to track access from the start of the guest.
>>
>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>>
>> ---
>>
>> While we can spread d->creation_finished all over the code, the per-arch
>> helper to perform actions just before the guest is first unpaused can
>> bring a lot of benefit for both architecture. For instance, on Arm, the
>> flush to the instruction cache could be delayed until the domain is
>> first run. This would improve greatly the performance of creating guest.
>>
>> I am still doing the benchmark whether having a command line option is
>> worth it. I will provide numbers as soon as I have them.
>>
>> Cc: Stefano Stabellini <sstabellini@kernel.org>
>> Cc: Julien Grall <julien.grall@arm.com>
>> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
>> Cc: George Dunlap <George.Dunlap@eu.citrix.com>
>> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
>> Cc: Jan Beulich <jbeulich@suse.com>
>> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> Cc: Tim Deegan <tim@xen.org>
>> Cc: Wei Liu <wei.liu2@citrix.com>
>> ---
>> xen/arch/arm/domain.c | 14 ++++++++++++++
>> xen/arch/arm/p2m.c | 30 ++++++++++++++++++++++++++++--
>> xen/arch/x86/domain.c | 4 ++++
>> xen/common/domain.c | 5 ++++-
>> xen/include/asm-arm/p2m.h | 2 ++
>> xen/include/xen/domain.h | 2 ++
>> 6 files changed, 54 insertions(+), 3 deletions(-)
>>
>> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
>> index 1d926dcb29..41f101746e 100644
>> --- a/xen/arch/arm/domain.c
>> +++ b/xen/arch/arm/domain.c
>> @@ -767,6 +767,20 @@ int arch_domain_soft_reset(struct domain *d)
>> return -ENOSYS;
>> }
>>
>> +void arch_domain_creation_finished(struct domain *d)
>> +{
>> + /*
>> + * To avoid flushing the whole guest RAM on the first Set/Way, we
>> + * invalidate the P2M to track what has been accessed.
>> + *
>> + * This is only turned when IOMMU is not used or the page-table are
>> + * not shared because bit[0] (e.g valid bit) unset will result
>> + * IOMMU fault that could be not fixed-up.
>> + */
>> + if ( !iommu_use_hap_pt(d) )
>> + p2m_invalidate_root(p2m_get_hostp2m(d));
>> +}
>> +
>> static int is_guest_pv32_psr(uint32_t psr)
>> {
>> switch (psr & PSR_MODE_MASK)
>> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
>> index 8ee6ff7bd7..44ea3580cf 100644
>> --- a/xen/arch/arm/p2m.c
>> +++ b/xen/arch/arm/p2m.c
>> @@ -1079,6 +1079,22 @@ static void p2m_invalidate_table(struct p2m_domain *p2m, mfn_t mfn)
>> }
>>
>> /*
>> + * Invalidate all entries in the root page-tables. This is
>> + * useful to get fault on entry and do an action.
>> + */
>> +void p2m_invalidate_root(struct p2m_domain *p2m)
>> +{
>> + unsigned int i;
>> +
>> + p2m_write_lock(p2m);
>> +
>> + for ( i = 0; i < P2M_ROOT_LEVEL; i++ )
>> + p2m_invalidate_table(p2m, page_to_mfn(p2m->root + i));
>> +
>> + p2m_write_unlock(p2m);
>> +}
>> +
>> +/*
>> * Resolve any translation fault due to change in the p2m. This
>> * includes break-before-make and valid bit cleared.
>> */
>> @@ -1587,15 +1603,18 @@ int p2m_cache_flush_range(struct domain *d, gfn_t *pstart, gfn_t end)
>> */
>> if ( gfn_eq(start, next_block_gfn) )
>> {
>> - mfn = p2m_get_entry(p2m, start, &t, NULL, &order, NULL);
>> + bool valid;
>> +
>> + mfn = p2m_get_entry(p2m, start, &t, NULL, &order, &valid);
>> next_block_gfn = gfn_next_boundary(start, order);
>>
>> /*
>> * The following regions can be skipped:
>> * - Hole
>> * - non-RAM
>> + * - block with valid bit (bit[0]) unset
>> */
>> - if ( mfn_eq(mfn, INVALID_MFN) || !p2m_is_any_ram(t) )
>> + if ( mfn_eq(mfn, INVALID_MFN) || !p2m_is_any_ram(t) || !valid )
>> {
>> count++;
>> start = next_block_gfn;
>> @@ -1629,6 +1648,7 @@ int p2m_cache_flush_range(struct domain *d, gfn_t *pstart, gfn_t end)
>> */
>> void p2m_flush_vm(struct vcpu *v)
>> {
>> + struct p2m_domain *p2m = p2m_get_hostp2m(v->domain);
>> int rc;
>> gfn_t start = _gfn(0);
>>
>> @@ -1648,6 +1668,12 @@ void p2m_flush_vm(struct vcpu *v)
>> "P2M has not been correctly cleaned (rc = %d)\n",
>> rc);
>>
>> + /*
>> + * Invalidate the p2m to track which page was modified by the guest
>> + * between call of p2m_flush_vm().
>> + */
>> + p2m_invalidate_root(p2m);
>
> Does this mean that we are invalidating the p2m once more than
> necessary, when the caches are finally enabled in Linux?Could that be
> avoided by passing an additional argument to p2m_flush_vm?
I don't think you can know when the guest finally enabled the cache. A guest is
free to disable the cache afterwards. This is actually what arm32 does because
it decompress itself with cache enabled and then disabled it afterwards.
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
prev parent reply other threads:[~2018-12-11 16:22 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-04 20:26 [PATCH for-4.12 v2 00/17] xen/arm: Implement Set/Way operations Julien Grall
2018-12-04 20:26 ` [PATCH for-4.12 v2 01/17] xen/arm: Introduce helpers to clear/flags flags in HCR_EL2 Julien Grall
2018-12-04 20:26 ` [PATCH for-4.12 v2 02/17] xen/arm: traps: Move the implementation of GUEST_BUG_ON in traps.h Julien Grall
2018-12-04 20:26 ` [PATCH for-4.12 v2 03/17] xen/arm: p2m: Clean-up headers included and order them alphabetically Julien Grall
2018-12-04 23:47 ` Stefano Stabellini
2018-12-04 20:26 ` [PATCH for-4.12 v2 04/17] xen/arm: p2m: Introduce p2m_is_valid and use it Julien Grall
2018-12-04 23:50 ` Stefano Stabellini
2018-12-05 9:46 ` Julien Grall
2018-12-06 22:02 ` Stefano Stabellini
2018-12-07 10:14 ` Julien Grall
2018-12-04 20:26 ` [PATCH for-4.12 v2 05/17] xen/arm: p2m: Handle translation fault in get_page_from_gva Julien Grall
2018-12-04 23:59 ` Stefano Stabellini
2018-12-05 10:03 ` Julien Grall
2018-12-06 22:04 ` Stefano Stabellini
2018-12-07 10:16 ` Julien Grall
2018-12-07 16:56 ` Stefano Stabellini
2018-12-04 20:26 ` [PATCH for-4.12 v2 06/17] xen/arm: p2m: Introduce a function to resolve translation fault Julien Grall
2018-12-06 22:33 ` Stefano Stabellini
2018-12-04 20:26 ` [PATCH for-4.12 v2 07/17] xen/arm: vcpreg: Add wrappers to handle co-proc access trapped by HCR_EL2.TVM Julien Grall
2018-12-06 22:33 ` Stefano Stabellini
2018-12-04 20:26 ` [PATCH for-4.12 v2 08/17] xen/arm: vsysreg: Add wrapper to handle sysreg " Julien Grall
2018-12-04 20:26 ` [PATCH for-4.12 v2 09/17] xen/arm: Rework p2m_cache_flush to take a range [begin, end) Julien Grall
2018-12-04 20:26 ` [PATCH for-4.12 v2 10/17] xen/arm: p2m: Allow to flush cache on any RAM region Julien Grall
2018-12-04 20:26 ` [PATCH for-4.12 v2 11/17] xen/arm: p2m: Extend p2m_get_entry to return the value of bit[0] (valid bit) Julien Grall
2018-12-04 20:35 ` Razvan Cojocaru
2018-12-06 22:32 ` Stefano Stabellini
2018-12-07 10:17 ` Julien Grall
2018-12-04 20:26 ` [PATCH for-4.12 v2 12/17] xen/arm: traps: Rework leave_hypervisor_tail Julien Grall
2018-12-06 23:08 ` Stefano Stabellini
2018-12-04 20:26 ` [PATCH for-4.12 v2 13/17] xen/arm: p2m: Rework p2m_cache_flush_range Julien Grall
2018-12-06 23:53 ` Stefano Stabellini
2018-12-07 10:18 ` Julien Grall
2018-12-04 20:26 ` [PATCH for-4.12 v2 14/17] xen/arm: domctl: Use typesafe gfn in XEN_DOMCTL_cacheflush Julien Grall
2018-12-06 23:13 ` Stefano Stabellini
2018-12-04 20:26 ` [PATCH for-4.12 v2 15/17] xen/arm: p2m: Add support for preemption in p2m_cache_flush_range Julien Grall
2018-12-06 23:32 ` Stefano Stabellini
2018-12-07 11:15 ` Julien Grall
2018-12-07 22:11 ` Stefano Stabellini
2018-12-11 16:11 ` Julien Grall
2018-12-04 20:26 ` [PATCH for-4.12 v2 16/17] xen/arm: Implement Set/Way operations Julien Grall
2018-12-06 23:32 ` Stefano Stabellini
2018-12-07 13:22 ` Julien Grall
2018-12-07 21:29 ` Stefano Stabellini
2018-12-12 15:33 ` Julien Grall
2018-12-12 17:25 ` Stefano Stabellini
2018-12-12 17:49 ` Dario Faggioli
2018-12-04 20:26 ` [PATCH for-4.12 v2 17/17] xen/arm: Track page accessed between batch of " Julien Grall
2018-12-05 8:37 ` Jan Beulich
2018-12-07 13:24 ` Julien Grall
2018-12-06 12:21 ` Julien Grall
2018-12-07 21:52 ` Stefano Stabellini
2018-12-07 21:43 ` Stefano Stabellini
2018-12-11 16:22 ` Julien Grall [this message]
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=9dfc25ea-a26a-21f8-2406-10c22b723184@arm.com \
--to=julien.grall@arm.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=konrad.wilk@oracle.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--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;
as well as URLs for NNTP newsgroup(s).