kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Xiao Guangrong <guangrong.xiao@linux.intel.com>,
	Junaid Shahid <junaids@google.com>,
	kvm@vger.kernel.org
Cc: andreslc@google.com, pfeiner@google.com
Subject: Re: [PATCH v3 7/8] kvm: x86: mmu: Lockless access tracking for Intel CPUs without EPT A bits.
Date: Wed, 21 Dec 2016 19:00:01 +0100	[thread overview]
Message-ID: <47788d75-f38c-adf2-9cb9-0dc4be4d65ba@redhat.com> (raw)
In-Reply-To: <ec8fc987-d4dc-0b52-7f07-45753a4928e8@linux.intel.com>



On 21/12/2016 10:49, Xiao Guangrong wrote:
> 
> 
> On 12/16/2016 11:23 PM, Paolo Bonzini wrote:
>>
>>
>> On 16/12/2016 14:04, Xiao Guangrong wrote:
>>>> +    /*
>>>> +     * #PF can be fast if:
>>>> +     * 1. The shadow page table entry is not present, which could
>>>> mean that
>>>> +     *    the fault is potentially caused by access tracking (if
>>>> enabled).
>>>> +     * 2. The shadow page table entry is present and the fault
>>>> +     *    is caused by write-protect, that means we just need
>>>> change the W
>>>> +     *    bit of the spte which can be done out of mmu-lock.
>>>> +     *
>>>> +     * However, if access tracking is disabled we know that a
>>>> non-present
>>>> +     * page must be a genuine page fault where we have to create a
>>>> new SPTE.
>>>> +     * So, if access tracking is disabled, we return true only for
>>>> write
>>>> +     * accesses to a present page.
>>>> +     */
>>>> +
>>>> +    return shadow_acc_track_mask != 0 ||
>>>> +           ((error_code & (PFERR_WRITE_MASK | PFERR_PRESENT_MASK))
>>>> +        == (PFERR_WRITE_MASK | PFERR_PRESENT_MASK));
>>>
>>> acc-track can not fix a WRITE-access, this should be:
>>>
>>> !(error_code & (PFERR_WRITE_MASK)) && shadow_acc_track_mask != 0 || ...
>>
>> Access tracking makes pages non-present, so a !W !P fault can sometimes
>> be fixed.
>>
>> One possibility is to test is_access_track_pte, but it is handled a
>> little below the call to page_fault_can_be_fast:
>>
>>             remove_acc_track = is_access_track_spte(spte);
>>
>>             /* Verify that the fault can be handled in the fast path */
>>             if (!remove_acc_track && !remove_write_prot)
>>                     break;
>>
>> It's not different from the way page_fault_can_be_fast return true for
>> writes, even if spte_can_locklessly_be_made_writable will return false
>> later.
>>
>> So I think Junaid's patch is okay.
> 
> Yes, it is workable.
> 
> My suggestion is just a optimization. Figure out Write access which can
> not be fixed by acc-track earlier in page_fault_can_be_fast() can stop
> useless  lockless-ly page-table walking.

That optimization can be done as a follow-up, but your suggestion was
not complete.  page_fault_can_be_fast must be conservative and return
true if unsure.

Paolo

  reply	other threads:[~2016-12-21 18:00 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-27  2:19 [PATCH 0/4] Lockless Access Tracking for Intel CPUs without EPT A bits Junaid Shahid
2016-10-27  2:19 ` [PATCH 1/4] kvm: x86: mmu: Use symbolic constants for EPT Violation Exit Qualifications Junaid Shahid
2016-11-02 18:03   ` Paolo Bonzini
2016-11-02 21:40     ` Junaid Shahid
2016-10-27  2:19 ` [PATCH 2/4] kvm: x86: mmu: Rename spte_is_locklessly_modifiable() Junaid Shahid
2016-10-27  2:19 ` [PATCH 3/4] kvm: x86: mmu: Fast Page Fault path retries Junaid Shahid
2016-10-27  2:19 ` [PATCH 4/4] kvm: x86: mmu: Lockless access tracking for Intel CPUs without EPT A bits Junaid Shahid
2016-11-02 18:01   ` Paolo Bonzini
2016-11-02 21:42     ` Junaid Shahid
2016-11-08 23:00 ` [PATCH v2 0/5] Lockless Access Tracking " Junaid Shahid
2016-11-08 23:00   ` [PATCH v2 1/5] kvm: x86: mmu: Use symbolic constants for EPT Violation Exit Qualifications Junaid Shahid
2016-11-21 13:06     ` Paolo Bonzini
2016-11-08 23:00   ` [PATCH v2 2/5] kvm: x86: mmu: Rename spte_is_locklessly_modifiable() Junaid Shahid
2016-11-21 13:07     ` Paolo Bonzini
2016-11-08 23:00   ` [PATCH v2 3/5] kvm: x86: mmu: Fast Page Fault path retries Junaid Shahid
2016-11-21 13:13     ` Paolo Bonzini
2016-11-08 23:00   ` [PATCH v2 4/5] kvm: x86: mmu: Lockless access tracking for Intel CPUs without EPT A bits Junaid Shahid
2016-11-21 14:42     ` Paolo Bonzini
2016-11-24  3:50       ` Junaid Shahid
2016-11-25  9:45         ` Paolo Bonzini
2016-11-29  2:43           ` Junaid Shahid
2016-11-29  8:09             ` Paolo Bonzini
2016-11-30  0:59               ` Junaid Shahid
2016-11-30 11:09                 ` Paolo Bonzini
2016-12-01 22:54       ` Junaid Shahid
2016-12-02  8:33         ` Paolo Bonzini
2016-12-05 22:57           ` Junaid Shahid
2016-11-08 23:00   ` [PATCH v2 5/5] kvm: x86: mmu: Update documentation for fast page fault mechanism Junaid Shahid
2016-12-07  0:46 ` [PATCH v3 0/8] Lockless Access Tracking for Intel CPUs without EPT A bits Junaid Shahid
2016-12-07  0:46   ` [PATCH v3 1/8] kvm: x86: mmu: Use symbolic constants for EPT Violation Exit Qualifications Junaid Shahid
2016-12-15  6:50     ` Xiao Guangrong
2016-12-15 23:06       ` Junaid Shahid
2016-12-07  0:46   ` [PATCH v3 2/8] kvm: x86: mmu: Rename spte_is_locklessly_modifiable() Junaid Shahid
2016-12-15  6:51     ` Xiao Guangrong
2016-12-07  0:46   ` [PATCH v3 3/8] kvm: x86: mmu: Fast Page Fault path retries Junaid Shahid
2016-12-15  7:20     ` Xiao Guangrong
2016-12-15 23:36       ` Junaid Shahid
2016-12-16 13:13         ` Xiao Guangrong
2016-12-17  0:36           ` Junaid Shahid
2016-12-07  0:46   ` [PATCH v3 4/8] kvm: x86: mmu: Refactor accessed/dirty checks in mmu_spte_update/clear Junaid Shahid
2016-12-07  0:46   ` [PATCH v3 5/8] kvm: x86: mmu: Introduce a no-tracking version of mmu_spte_update Junaid Shahid
2016-12-07  0:46   ` [PATCH v3 6/8] kvm: x86: mmu: Do not use bit 63 for tracking special SPTEs Junaid Shahid
2016-12-07  0:46   ` [PATCH v3 7/8] kvm: x86: mmu: Lockless access tracking for Intel CPUs without EPT A bits Junaid Shahid
2016-12-14 16:28     ` Paolo Bonzini
2016-12-14 22:36       ` Junaid Shahid
2016-12-14 23:35         ` Paolo Bonzini
2016-12-16 13:04     ` Xiao Guangrong
2016-12-16 15:23       ` Paolo Bonzini
2016-12-17  0:01         ` Junaid Shahid
2016-12-21  9:49         ` Xiao Guangrong
2016-12-21 18:00           ` Paolo Bonzini [this message]
2016-12-17  2:04       ` Junaid Shahid
2016-12-17 14:19         ` Paolo Bonzini
2016-12-20  3:36           ` Junaid Shahid
2016-12-20  9:01             ` Paolo Bonzini
2016-12-07  0:46   ` [PATCH v3 8/8] kvm: x86: mmu: Update documentation for fast page fault mechanism Junaid Shahid

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=47788d75-f38c-adf2-9cb9-0dc4be4d65ba@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=andreslc@google.com \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=junaids@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pfeiner@google.com \
    /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).