From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Matthew Wilcox <willy@infradead.org>
Cc: "Mark Rutland" <mark.rutland@arm.com>,
"Catalin Marinas" <catalin.marinas@arm.com>,
linux-mm@kvack.org, "Punit Agrawal" <punitagrawal@gmail.com>,
"Will Deacon" <will@kernel.org>,
"Alex Van Brunt" <avanbrunt@nvidia.com>,
"Jia He" <justin.he@arm.com>, "Marc Zyngier" <maz@kernel.org>,
"Anshuman Khandual" <anshuman.khandual@arm.com>,
"Kaly Xin" <Kaly.Xin@arm.com>,
hejianet@gmail.com, "Ralph Campbell" <rcampbell@nvidia.com>,
"Suzuki Poulose" <Suzuki.Poulose@arm.com>,
"Jérôme Glisse" <jglisse@redhat.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
nd@arm.com, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, "James Morse" <james.morse@arm.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Robin Murphy" <robin.murphy@arm.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH v7 3/3] mm: fix double page fault on arm64 if PTE_AF is cleared
Date: Fri, 20 Sep 2019 20:00:30 +0300 [thread overview]
Message-ID: <20190920170030.bpse5rlpjodbiv62@box> (raw)
In-Reply-To: <20190920155300.GC15392@bombadil.infradead.org>
On Fri, Sep 20, 2019 at 08:53:00AM -0700, 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.
I like this idea too.
--
Kirill A. Shutemov
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-09-20 17:00 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 [this message]
2019-09-21 13:19 ` Jia He
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=20190920170030.bpse5rlpjodbiv62@box \
--to=kirill@shutemov.name \
--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=hejianet@gmail.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).