From: Gavin Shan <gshan@redhat.com>
To: Marc Zyngier <maz@kernel.org>
Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] KVM: arm/arm64: Fix young bit from mmu notifier
Date: Wed, 22 Jan 2020 10:07:12 +1100 [thread overview]
Message-ID: <421c8827-4201-9e07-7d7e-377a8ee665c1@redhat.com> (raw)
In-Reply-To: <55ae5a0f91f2e675a4e71d83bef9d911@kernel.org>
On 1/22/20 12:28 AM, Marc Zyngier wrote:
> On 2020-01-21 05:56, Gavin Shan wrote:
>> kvm_test_age_hva() is called upon mmu_notifier_test_young(), but wrong
>> address range has been passed to handle_hva_to_gpa(). With the wrong
>> address range, no young bits will be checked in handle_hva_to_gpa().
>> It means zero is always returned from mmu_notifier_test_young().
>>
>> This fixes the issue by passing correct address range to the underly
>> function handle_hva_to_gpa(), so that the hardware young (access) bit
>> will be visited.
>>
>> Cc: stable@vger.kernel.org # v4.1+
>> Fixes: 35307b9a5f7e ("arm/arm64: KVM: Implement Stage-2 page aging")
>> Signed-off-by: Gavin Shan <gshan@redhat.com>
>> ---
>> virt/kvm/arm/mmu.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
>> index 0b32a904a1bb..a2777efb558e 100644
>> --- a/virt/kvm/arm/mmu.c
>> +++ b/virt/kvm/arm/mmu.c
>> @@ -2147,7 +2147,8 @@ int kvm_test_age_hva(struct kvm *kvm, unsigned long hva)
>> if (!kvm->arch.pgd)
>> return 0;
>> trace_kvm_test_age_hva(hva);
>> - return handle_hva_to_gpa(kvm, hva, hva, kvm_test_age_hva_handler, NULL);
>> + return handle_hva_to_gpa(kvm, hva, hva + PAGE_SIZE,
>> + kvm_test_age_hva_handler, NULL);
>> }
>>
>> void kvm_mmu_free_memory_caches(struct kvm_vcpu *vcpu)
>
> I knew this start/end thing (instead of start/size) would bite us
> one of these days. Terribly embarrassing. On the other hand, who
> really wants to swap things out? ;-)
>
> Out of curiosity, how did you find this one?
>
Well, it's hard to tell who really wants to swap things out. Something I
was involved previously: user daemon is started to scan the accessed pages
periodically, in order to determine the least accessed pages. These least
access anonymous pages are migrated to low-cost storage (e.g. NVDIMM). This
helps on balance of performance and cost.
It's found when reading code. After that, I wrote some code (as below) to
double confirm:
(1) locate qemu process and the corresponding vma because the VM is started
with "mem-path=/tmp/virtiofs/backup-file". "backup-file" is the key in
the location.
(2) iterate the virtual space of the vma by mmu_notifier_test_young(), none
of return values is 1 (accessed). It seems it's not correct.
With the patch applied and rerun above code, mmu_notifier_test_young() returns
1 (accessed) on some pages.
Thanks,
Gavin
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
prev parent reply other threads:[~2020-01-22 8:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-21 5:56 [PATCH] KVM: arm/arm64: Fix young bit from mmu notifier Gavin Shan
2020-01-21 13:28 ` Marc Zyngier
2020-01-21 23:07 ` Gavin Shan [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=421c8827-4201-9e07-7d7e-377a8ee665c1@redhat.com \
--to=gshan@redhat.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.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