From: Julien Grall <julien.grall@linaro.org>
To: Ian Campbell <Ian.Campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel@lists.xenproject.org, tim@xen.org,
stefano.stabellini@citrix.com, patches@linaro.org
Subject: Re: [PATCH] xen/arm: p2m: Correctly flush TLB in create_p2m_entries
Date: Thu, 09 Jan 2014 13:14:25 +0000 [thread overview]
Message-ID: <52CEA0B1.3020403@linaro.org> (raw)
In-Reply-To: <1389265175.27473.67.camel@kazak.uk.xensource.com>
On 01/09/2014 10:59 AM, Ian Campbell wrote:
> On Wed, 2014-01-08 at 17:13 +0000, Stefano Stabellini wrote:
>> On Wed, 8 Jan 2014, Julien Grall wrote:
>>> The p2m is shared between VCPUs for each domain. Currently Xen only flush
>>> TLB on the local PCPU. This could result to mismatch between the mapping in the
>>> p2m and TLBs.
>>>
>>> Flush TLBs used by this domain on every PCPU.
>>>
>>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>>
>> The fix makes sense to me.
>
> Me too. Has anyone had a grep for similar issues?
I think flush_xen_data_tlb and flush_xen_text_tlb should also be
innershareable.
The former one is used by flush_tlb_mask. But ... this function seems
badly implement, it's weird to use flush_xen_data_tlb because we are
mainly using flush_tlb_mask in common/grant-table.c. Any ideas?
> (the reason for getting this wrong is that for cache flushes the "is"
> suffix restricts the flush to the IS domain, whereas with tlb flushes
> the "is" suffix broadcasts instead of keeping it local, which is a bit
> confusing ;-))
>
>>
>>> ---
>>>
>>> This is a possible bug fix (found by reading the code) for Xen 4.4. I have
>>> added a small optimisation to avoid flushing all TLBs when a VCPU of this
>>> domain is running on the current cpu.
>>>
>>> The downside of this patch is the function can be a little bit slower because
>>> Xen is flushing more TLBs.
>>
>> Yes, I wonder how much slower it is going to be, considering that the flush
>> is executed for every iteration of the loop.
>
> It might be better to set the current VMID to the target domain for the
> duration of this function, we'd still need the broadcast but at least we
> wouldn't be killing unrelated VMIDs.
I can modify the patch to handle that.
>
> Pulling the flush out of the loop would require great case WRT accesses
> from other VCPUs, e.g. you'd have to put the pages on a list (page->list
> might be available?) and issue the put_page() after the flush, otherwise
> it might get recycled into another domain while the first domain still
> has TLB entries for it.
>
> Or is there always something outside this function which holds another
> ref count such that the page definitely won't be freed by the put_page
> here?
>
> Actually, do the existing code not have this issue already? The put_page
> is before the flush. If this bug does exist now then I'd be inclined to
> consider this a bug fix for 4.4, rather than a potential optimisation
> for 4.5.
For now we don't take reference when we map/unmap mapping. Most of the
time create_p2m_entries is called by common code which take care of
having a reference when this function is called. So we should be safe.
I would prefer to wait 4.5 for this optimisation (moving the flush
outside the loop).
> While looking at this function I'm now wondering what happens to the
> existing page on ALLOCATE or INSERT, is it leaked?
For ALLOCATE page, it's on the domain page list so the page will be
freed duing relinquish.
For INSERT, except for foreign mapping we don't have refcount for
mapping. So the only issue could be with foreign mapping.
--
Julien Grall
next prev parent reply other threads:[~2014-01-09 13:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-08 17:05 [PATCH] xen/arm: p2m: Correctly flush TLB in create_p2m_entries Julien Grall
2014-01-08 17:13 ` Stefano Stabellini
2014-01-09 10:59 ` Ian Campbell
2014-01-09 13:14 ` Julien Grall [this message]
2014-01-09 14:05 ` Ian Campbell
2014-01-09 15:08 ` Julien Grall
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=52CEA0B1.3020403@linaro.org \
--to=julien.grall@linaro.org \
--cc=Ian.Campbell@citrix.com \
--cc=patches@linaro.org \
--cc=stefano.stabellini@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--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.