From: Julien Grall <julien.grall@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: proskurin@sec.in.tum.de, wei.chen@linaro.org,
steve.capper@arm.com, xen-devel@lists.xen.org
Subject: Re: [RFC 18/22] xen/arm: p2m: Introduce p2m_set_entry and __p2m_set_entry
Date: Wed, 7 Sep 2016 09:18:33 +0100 [thread overview]
Message-ID: <7e9fbb1d-04a4-ad8b-8a05-a69495929aba@arm.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1609061123370.4105@sstabellini-ThinkPad-X260>
Hi Stefano,
On 06/09/2016 19:51, Stefano Stabellini wrote:
> On Tue, 6 Sep 2016, Julien Grall wrote:
>>> I was asking myself the same question
>>
>> It is not trivial. On ARMv7, there is no way to invalidate by IPA, so we still
>> need to do a full flush.
>>
>> In the case of ARMv8, it is possible to do a flush by IPA with the following
>> sequence (see D4-1739 in ARM DDI 0487A.i):
>> tlbi ipa2e1, xt
>> dsb
>> tlbi vmalle1
>>
>> So I was wondering if we could leave that for a future optimization.
>
> We can leave it for now but I have an hunch that it is going to have a
> pretty significant impact.
In theory, the current approach will have an impact on platform where
the TLBs are caching separately stage-1 and stage-2 translation.
This will not be the case if the TLBs are caching stage-1 and stage-2 in
a single entry.
However, on ARMv7 it will not be possible to minimize the impact.
But to be honest, most of the time, the p2m will be modified via
guest_physmap_add_entry and guest_physmap_remove_page. Both are often
called with order = 0 or order = 6 (for domain use 64KB page granularity).
Taken aside domains using 64KB page granularity, the number of TLB
flushs will be either 1 or 2 depending whether you need to shatter a
superpage. Which is the same as today.
In the case of 64KB domain, the number of TLB flush will be higher if
the domain is replacing existing mapping (1 TLB flush per 4KB-entry).
But this is already a programming issue given that in this case the
underlying memory (if RAM) will not be freed until the domain is
destroyed. In general a domain should remove a mapping before creating a
new one at the same address.
I have done some testing and noticed that DOMU p2m will not be often
modified. In the case of DOM0, this will mostly happen when a domain is
created (you have to map the new domain memory). Although, the number of
flushes should be the same given dom0 will use balloon page (i.e the
stage-2 mapping does not exist).
I have some ideas on how to optimize a bit more the code, but they are
heavy and will be hard to maintain. I would prefer to defer it until
user come with use case where the performance hit is too much.
>
>
>>>> + if ( !(mask & ((1UL << FIRST_ORDER) - 1)) )
>>>> + order = FIRST_ORDER;
>>>> + else if ( !(mask & ((1UL << SECOND_ORDER) - 1)) )
>>>> + order = SECOND_ORDER;
>>>> + else
>>>> + order = THIRD_ORDER;
>>>> +
>>>> + rc = __p2m_set_entry(p2m, sgfn, order, smfn, t, a);
>>>> + if ( rc )
>>>> + break;
>>>
>>> Shouldn't we be checking that "(1<<order)" doesn't exceed "todo" before
>>> calling __p2m_set_entry? Otherwise we risk creating a mapping bigger
>>> than requested.
>>
>> The mask is defined as gfn_x(sgfn) | mfn_x(smfn) | todo
>>
>> So we will never have the order exceeding "todo".
>
> Ah, I see. But this way we are not able to do superpage mappings for
> regions larger than 2MB but not multiple of 2MB (3MB for example). But I
> don't think we were able to do it before either so it is not a
> requirement for the patch.
From my understanding of is_mapping_aligned, the case you mentioned is
handled.
The function p2m_set_entry is using the number of page because some
caller (such as MMIO ones) are passing a number of page. However, the
main callers are guest_physmap_remove_page and guest_physmap_add_entry.
They take an order in parameter.
So it would be a nice feature to have, but I don't think this is
strictly necessary.
Regards,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-09-07 8:18 UTC|newest]
Thread overview: 98+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-28 14:51 [RFC 00/22] xen/arm: Rework the P2M code to follow break-before-make sequence Julien Grall
2016-07-28 14:51 ` [RFC 01/22] xen/arm: do_trap_instr_abort_guest: Move the IPA computation out of the switch Julien Grall
2016-08-16 0:21 ` Stefano Stabellini
2016-08-16 16:20 ` Julien Grall
2016-08-31 10:01 ` Julien Grall
2016-08-31 19:43 ` Stefano Stabellini
2016-09-06 14:54 ` Julien Grall
2016-07-28 14:51 ` [RFC 02/22] xen/arm: p2m: Store in p2m_domain whether we need to clean the entry Julien Grall
2016-08-16 0:35 ` Stefano Stabellini
2016-08-31 10:29 ` Julien Grall
2016-07-28 14:51 ` [RFC 03/22] xen/arm: p2m: Rename parameter in p2m_{remove, write}_pte Julien Grall
2016-08-16 0:36 ` Stefano Stabellini
2016-07-28 14:51 ` [RFC 04/22] xen/arm: p2m: Use typesafe gfn in p2m_mem_access_radix_set Julien Grall
2016-08-16 0:39 ` Stefano Stabellini
2016-07-28 14:51 ` [RFC 05/22] xen/arm: traps: Move MMIO emulation code in a separate helper Julien Grall
2016-08-16 0:49 ` Stefano Stabellini
2016-08-31 10:36 ` Julien Grall
2016-07-28 14:51 ` [RFC 06/22] xen/arm: traps: Check the P2M before injecting a data/instruction abort Julien Grall
2016-08-23 1:05 ` Stefano Stabellini
2016-08-31 10:58 ` Julien Grall
2016-07-28 14:51 ` [RFC 07/22] xen/arm: p2m: Rework p2m_put_l3_page Julien Grall
2016-08-23 1:10 ` Stefano Stabellini
2016-07-28 14:51 ` [RFC 08/22] xen/arm: p2m: Invalidate the TLBs when write unlocking the p2m Julien Grall
2016-08-23 1:18 ` Stefano Stabellini
2016-07-28 14:51 ` [RFC 09/22] xen/arm: p2m: Change the type of level_shifts from paddr_t to unsigned int Julien Grall
2016-08-23 1:20 ` Stefano Stabellini
2016-08-31 11:04 ` Julien Grall
2016-07-28 14:51 ` [RFC 10/22] xen/arm: p2m: Move the lookup helpers at the top of the file Julien Grall
2016-07-28 14:51 ` [RFC 11/22] xen/arm: p2m: Introduce p2m_get_root_pointer and use it in __p2m_lookup Julien Grall
2016-08-23 1:34 ` Stefano Stabellini
2016-07-28 14:51 ` [RFC 12/22] xen/arm: p2m: Introduce p2m_get_entry and use it to implement __p2m_lookup Julien Grall
2016-07-30 18:37 ` Tamas K Lengyel
2016-08-31 0:30 ` [RFC 12/22] xen/arm: p2m: Introduce p2m_get_entry and use it to implement __p2m_lookupo Stefano Stabellini
2016-08-31 12:25 ` Julien Grall
2016-08-31 19:33 ` Stefano Stabellini
2016-09-01 11:37 ` Julien Grall
2016-07-28 14:51 ` [RFC 13/22] xen/arm: p2m: Replace all usage of __p2m_lookup with p2m_get_entry Julien Grall
2016-07-28 17:29 ` Tamas K Lengyel
2016-07-28 17:36 ` Tamas K Lengyel
2016-07-29 15:06 ` Julien Grall
2016-07-29 22:36 ` Tamas K Lengyel
2016-07-28 17:51 ` Julien Grall
2016-09-05 20:45 ` Stefano Stabellini
2016-07-28 14:51 ` [RFC 14/22] xen/arm: p2m: Re-implement p2m_cache_flush using p2m_get_entry Julien Grall
2016-09-05 21:13 ` Stefano Stabellini
2016-09-06 14:56 ` Julien Grall
2016-07-28 14:51 ` [RFC 15/22] xen/arm: p2m: Re-implement relinquish_p2m_mapping " Julien Grall
2016-09-05 21:58 ` Stefano Stabellini
2016-09-06 15:05 ` Julien Grall
2016-09-06 18:21 ` Stefano Stabellini
2016-09-07 7:37 ` Julien Grall
2016-07-28 14:51 ` [RFC 16/22] xen/arm: p2m: Make p2m_{valid, table, mapping} helpers inline Julien Grall
2016-09-05 22:00 ` Stefano Stabellini
2016-07-28 14:51 ` [RFC 17/22] xen/arm: p2m: Introduce a helper to check if an entry is a superpage Julien Grall
2016-09-05 22:03 ` Stefano Stabellini
2016-07-28 14:51 ` [RFC 18/22] xen/arm: p2m: Introduce p2m_set_entry and __p2m_set_entry Julien Grall
2016-07-30 18:40 ` Tamas K Lengyel
2016-08-15 10:22 ` Sergej Proskurin
2016-09-06 1:08 ` Stefano Stabellini
2016-09-06 17:12 ` Julien Grall
2016-09-06 18:51 ` Stefano Stabellini
2016-09-07 8:18 ` Julien Grall [this message]
2016-09-09 23:14 ` Stefano Stabellini
2016-07-28 14:51 ` [RFC 19/22] xen/arm: p2m: Re-implement p2m_remove_using using p2m_set_entry Julien Grall
2016-09-06 18:53 ` Stefano Stabellini
2016-07-28 14:51 ` [RFC 20/22] xen/arm: p2m: Re-implement p2m_insert_mapping " Julien Grall
2016-09-06 18:57 ` Stefano Stabellini
2016-09-15 10:38 ` Julien Grall
2016-07-28 14:51 ` [RFC 21/22] xen/arm: p2m: Re-implement p2m_set_mem_access using p2m_{set, get}_entry Julien Grall
2016-07-28 15:04 ` Razvan Cojocaru
2016-07-28 15:16 ` Julien Grall
2016-08-01 15:40 ` Julien Grall
2016-08-01 15:59 ` Tamas K Lengyel
2016-08-01 16:15 ` Julien Grall
2016-08-01 16:27 ` Tamas K Lengyel
2016-08-01 16:33 ` Julien Grall
2016-08-01 16:41 ` Tamas K Lengyel
2016-08-02 6:07 ` Razvan Cojocaru
2016-08-01 16:34 ` Mark Rutland
2016-08-01 16:57 ` Julien Grall
2016-08-01 17:26 ` Mark Rutland
2016-08-01 18:22 ` Mark Rutland
2016-08-02 9:58 ` Julien Grall
2016-08-02 10:26 ` Mark Rutland
2016-07-28 17:21 ` Tamas K Lengyel
2016-09-06 19:06 ` Stefano Stabellini
2016-09-06 19:16 ` Razvan Cojocaru
2016-09-06 19:17 ` Stefano Stabellini
2016-09-07 6:56 ` Julien Grall
2016-09-07 7:03 ` Razvan Cojocaru
2016-07-28 14:51 ` [RFC 22/22] xen/arm: p2m: Do not handle shattering in p2m_create_table Julien Grall
2016-09-06 18:59 ` Stefano Stabellini
2016-07-28 17:46 ` [RFC 00/22] xen/arm: Rework the P2M code to follow break-before-make sequence Tamas K Lengyel
2016-07-29 16:23 ` Julien Grall
2016-07-29 19:05 ` Julien Grall
2016-08-15 10:24 ` Julien Grall
2016-08-15 15:06 ` Edgar E. Iglesias
2016-08-17 2:28 ` Shanker Donthineni
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=7e9fbb1d-04a4-ad8b-8a05-a69495929aba@arm.com \
--to=julien.grall@arm.com \
--cc=proskurin@sec.in.tum.de \
--cc=sstabellini@kernel.org \
--cc=steve.capper@arm.com \
--cc=wei.chen@linaro.org \
--cc=xen-devel@lists.xen.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).