linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jia He <hejianet@gmail.com>
To: Matthew Wilcox <willy@infradead.org>, Jia He <justin.he@arm.com>
Cc: "Mark Rutland" <mark.rutland@arm.com>,
	"Kaly Xin" <Kaly.Xin@arm.com>,
	"Ralph Campbell" <rcampbell@nvidia.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Suzuki Poulose" <Suzuki.Poulose@arm.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Anshuman Khandual" <anshuman.khandual@arm.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"James Morse" <james.morse@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	"Punit Agrawal" <punitagrawal@gmail.com>,
	"Marc Zyngier" <maz@kernel.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	nd@arm.com, "Will Deacon" <will@kernel.org>,
	"Alex Van Brunt" <avanbrunt@nvidia.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	"Robin Murphy" <robin.murphy@arm.com>
Subject: Re: [PATCH v7 3/3] mm: fix double page fault on arm64 if PTE_AF is cleared
Date: Sat, 21 Sep 2019 21:19:34 +0800	[thread overview]
Message-ID: <dbfc9da4-6650-5c9e-59c6-16e0f234b9c8@gmail.com> (raw)
In-Reply-To: <20190920155300.GC15392@bombadil.infradead.org>

[On behalf of justin.he@arm.com]

Hi Matthew

On 2019/9/20 23:53, Matthew Wilcox wrote:
> On Fri, Sep 20, 2019 at 09:54:37PM +0800, Jia He wrote:
>> -static inline void cow_user_page(struct page *dst, struct page *src, unsigned long va, struct vm_area_struct *vma)
>> +static inline int cow_user_page(struct page *dst, struct page *src,
>> +				struct vm_fault *vmf)
>>   {
> Can we talk about the return type here?
>
>> +			} else {
>> +				/* Other thread has already handled the fault
>> +				 * and we don't need to do anything. If it's
>> +				 * not the case, the fault will be triggered
>> +				 * again on the same address.
>> +				 */
>> +				pte_unmap_unlock(vmf->pte, vmf->ptl);
>> +				return -1;
> ...
>> +	return 0;
>>   }
> So -1 for "try again" and 0 for "succeeded".
>
>> +		if (cow_user_page(new_page, old_page, vmf)) {
> Then we use it like a bool.  But it's kind of backwards from a bool because
> false is success.
>
>> +			/* COW failed, if the fault was solved by other,
>> +			 * it's fine. If not, userspace would re-fault on
>> +			 * the same address and we will handle the fault
>> +			 * from the second attempt.
>> +			 */
>> +			put_page(new_page);
>> +			if (old_page)
>> +				put_page(old_page);
>> +			return 0;
> And we don't use the return value; in fact we invert it.
>
> Would this make more sense:
>
> static inline bool cow_user_page(struct page *dst, struct page *src,
> 					struct vm_fault *vmf)
> ...
> 				pte_unmap_unlock(vmf->pte, vmf->ptl);
> 				return false;
> ...
> 	return true;
> ...
> 		if (!cow_user_page(new_page, old_page, vmf)) {
>
> That reads more sensibly for me.  We could also go with returning a
> vm_fault_t, but that would be more complex than needed today, I think.

Ok, will change the return type to bool as you suggested.
Thanks

---
Cheers,
Justin (Jia He)


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      parent reply	other threads:[~2019-09-21 13:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-20 13:54 [PATCH v7 0/3] fix double page fault on arm64 Jia He
2019-09-20 13:54 ` [PATCH v7 1/3] arm64: cpufeature: introduce helper cpu_has_hw_af() Jia He
2019-09-20 13:54 ` [PATCH v7 2/3] arm64: mm: implement arch_faults_on_old_pte() on arm64 Jia He
2019-09-20 13:54 ` [PATCH v7 3/3] mm: fix double page fault on arm64 if PTE_AF is cleared Jia He
2019-09-20 14:21   ` Kirill A. Shutemov
2019-09-20 14:24     ` Justin He (Arm Technology China)
2019-09-20 15:53   ` Matthew Wilcox
2019-09-20 17:00     ` Kirill A. Shutemov
2019-09-21 13:19     ` Jia He [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=dbfc9da4-6650-5c9e-59c6-16e0f234b9c8@gmail.com \
    --to=hejianet@gmail.com \
    --cc=Kaly.Xin@arm.com \
    --cc=Suzuki.Poulose@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=avanbrunt@nvidia.com \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=jglisse@redhat.com \
    --cc=justin.he@arm.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=nd@arm.com \
    --cc=punitagrawal@gmail.com \
    --cc=rcampbell@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    --cc=willy@infradead.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).