From: Razvan Cojocaru <rcojocaru@bitdefender.com>
To: George Dunlap <george.dunlap@citrix.com>, xen-devel@lists.xenproject.org
Cc: "George Dunlap" <george.dunlap@eu.citrix.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Wei Liu" <wei.liu2@citrix.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH V11 4/5] p2m: Always use hostp2m when clipping rangesets
Date: Thu, 20 Dec 2018 18:25:38 +0200 [thread overview]
Message-ID: <1d01d363-3607-dfa9-95f6-d7f762701c28@bitdefender.com> (raw)
In-Reply-To: <21a7f345-6744-6dd7-061d-246a748373ff@citrix.com>
On 12/20/18 6:09 PM, George Dunlap wrote:
> On 12/5/18 9:18 AM, Razvan Cojocaru wrote:
>> The logdirty rangesets of the altp2ms need to be kept in sync with the
>> hostp2m. This means when iterating through the altp2ms, we need to
>> use the host p2m to clip the rangeset, not the indiviual altp2m's
>> value.
>>
>> This change also:
>>
>> - Documents that the end is non-inclusive
>>
>> - Calculates an "inclusive" value for the end once, rather than
>> open-coding the modification, and (worse) back-modifying updates so
>> that the calculation ends up correct
>>
>> - Clarifies the logic deciding whether to call
>> change_entry_type_global() or change_entry_type_range()
>>
>> - Handles the case where start >= hostp2m->max_mapped_pfn
>>
>> Signed-off-by: George Dunlap <george.dunlap@citrix.com>
>> Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
>> Tested-by: Tamas K Lengyel <tamas@tklengyel.com>
>>
>> ---
>> CC: George Dunlap <george.dunlap@eu.citrix.com>
>> CC: Jan Beulich <jbeulich@suse.com>
>> CC: Andrew Cooper <andrew.cooper3@citrix.com>
>> CC: Wei Liu <wei.liu2@citrix.com>
>> CC: "Roger Pau Monné" <roger.pau@citrix.com>
>>
>> ---
>> Changes since V10:
>> - Fixed a double-space in the patch description.
>> - Fixed a coding style issue for
>> "if ( !start && end >= p2m->max_mapped_pfn)" (no space before
>> closing ')').
>> - Switched the early return comment back to "/* If the requested
>> range is out of scope, return doing nothing. */.
>> - Added Tamas' Tested-by.
>> ---
>> xen/arch/x86/mm/p2m.c | 47 ++++++++++++++++++++++++++++++-----------------
>> 1 file changed, 30 insertions(+), 17 deletions(-)
>>
>> diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
>> index d145850..539ea16 100644
>> --- a/xen/arch/x86/mm/p2m.c
>> +++ b/xen/arch/x86/mm/p2m.c
>> @@ -1002,30 +1002,43 @@ int p2m_change_type_one(struct domain *d, unsigned long gfn_l,
>> return rc;
>> }
>>
>> -/* Modify the p2m type of a range of gfns from ot to nt. */
>> +/* Modify the p2m type of [start, end) from ot to nt. */
>> static void change_type_range(struct p2m_domain *p2m,
>> unsigned long start, unsigned long end,
>> p2m_type_t ot, p2m_type_t nt)
>> {
>> - unsigned long gfn = start;
>> struct domain *d = p2m->domain;
>> + const unsigned long host_max_pfn = p2m_get_hostp2m(d)->max_mapped_pfn;
>> int rc = 0;
>>
>> - if ( unlikely(end > p2m->max_mapped_pfn) )
>> - {
>> - if ( !gfn )
>> - {
>> - p2m->change_entry_type_global(p2m, ot, nt);
>> - gfn = end;
>> - }
>> - end = p2m->max_mapped_pfn + 1;
>> - }
>> - if ( gfn < end )
>> - rc = p2m->change_entry_type_range(p2m, ot, nt, gfn, end - 1);
>> + --end;
>
> I don't like the idea of modifying arguments, which is why I duplicated
> them in the first place.
>
> What about calling the argument end_exclusive, and having a local
> variable, 'end', which we set to be end_exclusive-1?
Of course, I'll do that.
>> + if ( start >= host_max_pfn )
>> + printk(XENLOG_G_WARNING "Dom%d logdirty rangeset clipped to max_mapped_pfn\n",
>> + d->domain_id);
>
> This doesn't seem to be the right condition for this warning.. Surely
> this warning would go better under the next conditional, where we
> actually do the clipping?
>
>> + /* Always clip the rangeset down to the host p2m. */
>> + if ( unlikely(end > host_max_pfn) )
>> + end = host_max_pfn;
>
> So what about modifying this comment thus:
>
> "Always clip the rangeset down to the host p2m. This is probably not
> the right behavior. This should be revisited later, but for now post a
> warning."
You're right, the warning is a bit out of place above. I'll move it and
update the comment as indicated.
Thank you,
Razvan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-12-20 16:25 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-05 9:18 [PATCH V11 0/5] Fix VGA logdirty related display freezes with altp2m Razvan Cojocaru
2018-12-05 9:18 ` [PATCH V11 1/5] x86/p2m: allocate logdirty_ranges for altp2ms Razvan Cojocaru
2018-12-05 9:18 ` [PATCH V11 2/5] x86/p2m: refactor p2m_reset_altp2m() Razvan Cojocaru
2018-12-05 9:18 ` [PATCH V11 3/5] x86/altp2m: fix display frozen when switching to a new view early Razvan Cojocaru
2018-12-20 15:31 ` George Dunlap
2018-12-05 9:18 ` [PATCH V11 4/5] p2m: Always use hostp2m when clipping rangesets Razvan Cojocaru
2018-12-05 16:30 ` Jan Beulich
2018-12-13 10:22 ` Razvan Cojocaru
2018-12-13 10:43 ` Jan Beulich
2018-12-19 17:26 ` George Dunlap
2018-12-20 8:20 ` Jan Beulich
2018-12-20 12:59 ` George Dunlap
2018-12-20 13:52 ` Jan Beulich
2018-12-20 14:38 ` George Dunlap
2018-12-20 14:49 ` Jan Beulich
2018-12-20 15:14 ` Razvan Cojocaru
2018-12-20 15:22 ` George Dunlap
2018-12-20 15:01 ` Jan Beulich
2018-12-20 16:09 ` George Dunlap
2018-12-20 16:25 ` Razvan Cojocaru [this message]
2018-12-20 16:31 ` George Dunlap
2018-12-20 16:46 ` Razvan Cojocaru
2018-12-05 9:18 ` [PATCH V11 5/5] p2m: change_type_range: Only invalidate mapped gfns Razvan Cojocaru
2018-12-20 16:17 ` George Dunlap
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=1d01d363-3607-dfa9-95f6-d7f762701c28@bitdefender.com \
--to=rcojocaru@bitdefender.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--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).