Re: [PATCH v2] kvm: Faults which trigger IO release the mmap_sem

From: Wanpeng Li
Date: Thu Sep 18 2014 - 20:30:17 EST


On Thu, Sep 18, 2014 at 09:13:26AM +0300, Gleb Natapov wrote:
>On Thu, Sep 18, 2014 at 08:29:17AM +0800, Wanpeng Li wrote:
>> Hi Andres,
>> On Wed, Sep 17, 2014 at 10:51:48AM -0700, Andres Lagar-Cavilla wrote:
>> [...]
>> > static inline int check_user_page_hwpoison(unsigned long addr)
>> > {
>> > int rc, flags = FOLL_TOUCH | FOLL_HWPOISON | FOLL_WRITE;
>> >@@ -1177,9 +1214,15 @@ static int hva_to_pfn_slow(unsigned long addr, bool *async, bool write_fault,
>> > npages = get_user_page_nowait(current, current->mm,
>> > addr, write_fault, page);
>> > up_read(&current->mm->mmap_sem);
>> >- } else
>> >- npages = get_user_pages_fast(addr, 1, write_fault,
>> >- page);
>> >+ } else {
>> >+ /*
>> >+ * By now we have tried gup_fast, and possibly async_pf, and we
>> >+ * are certainly not atomic. Time to retry the gup, allowing
>> >+ * mmap semaphore to be relinquished in the case of IO.
>> >+ */
>> >+ npages = kvm_get_user_page_io(current, current->mm, addr,
>> >+ write_fault, page);
>> >+ }
>>
>> try_async_pf
>> gfn_to_pfn_async
>> __gfn_to_pfn async = false
> *async = false
>
>> __gfn_to_pfn_memslot
>> hva_to_pfn
>> hva_to_pfn_fast
>> hva_to_pfn_slow
>hva_to_pfn_slow checks async not *async.

Got it, thanks for your pointing out.

Reviewed-by: Wanpeng Li <wanpeng.li@xxxxxxxxxxxxxxx>

Regards,
Wanpeng Li

>
>> kvm_get_user_page_io
>>
>> page will always be ready after kvm_get_user_page_io which leads to APF
>> don't need to work any more.
>>
>> Regards,
>> Wanpeng Li
>>
>> > if (npages != 1)
>> > return npages;
>> >
>> >--
>> >2.1.0.rc2.206.gedb03e5
>> >
>> >--
>> >To unsubscribe, send a message with 'unsubscribe linux-mm' in
>> >the body to majordomo@xxxxxxxxxx For more info on Linux MM,
>> >see: http://www.linux-mm.org/ .
>> >Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>
>
>--
> Gleb.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/