From: Peter Xu <peterx@redhat.com>
To: David Rientjes <rientjes@google.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
John Hubbard <jhubbard@nvidia.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Gerald Schaefer <gerald.schaefer@de.ibm.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Will Deacon <will@kernel.org>
Subject: Re: [PATCH v4 01/26] mm: Do page fault accounting in handle_mm_fault
Date: Tue, 30 Jun 2020 17:30:09 -0400 [thread overview]
Message-ID: <20200630213009.GB40675@xz-x1> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2006301401560.1512657@chino.kir.corp.google.com>
Hi, David,
On Tue, Jun 30, 2020 at 02:05:24PM -0700, David Rientjes wrote:
> On Tue, 30 Jun 2020, Peter Xu wrote:
>
> > @@ -4408,6 +4440,34 @@ vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
> > mem_cgroup_oom_synchronize(false);
> > }
> >
> > + if (ret & (VM_FAULT_RETRY | VM_FAULT_ERROR))
> > + return ret;
> > +
> > + /*
> > + * Do accounting in the common code, to avoid unnecessary
> > + * architecture differences or duplicated code.
> > + *
> > + * We arbitrarily make the rules be:
> > + *
> > + * - Unsuccessful faults do not count (e.g. when the address wasn't
> > + * valid). That includes arch_vma_access_permitted() failing above.
> > + *
> > + * So this is expressly not a "this many hardware page faults"
> > + * counter. Use the hw profiling for that.
> > + *
> > + * - Incomplete faults do not count (e.g. RETRY). They will only
> > + * count once completed.
> > + *
> > + * - The fault counts as a "major" fault when the final successful
> > + * fault is VM_FAULT_MAJOR, or if it was a retry (which implies that
> > + * we couldn't handle it immediately previously).
> > + *
> > + * - If the fault is done for GUP, regs will be NULL and no accounting
> > + * will be done.
> > + */
> > + mm_account_fault(regs, address, (ret & VM_FAULT_MAJOR) ||
> > + (flags & FAULT_FLAG_TRIED));
> > +
> > return ret;
> > }
> > EXPORT_SYMBOL_GPL(handle_mm_fault);
>
> Just a nit, likely not important: I wonder if it would be cleaner to pass
> the vm_fault_t into mm_account_fault() and then do the VM_FAULT_RETRY and
> VM_FAULT_ERROR checks there as well as putting the comment about how
> accounting is handled in that function. Your comment is great.
Yes that seems to be cleaner so handle_mm_fault is shorter (btw, I "stole" the
comment block majorly from Linus :).
But this change will also need to touch patch 25 again or it won't apply
cleanly. So I think I'll see whether Andrew would like me to repost the whole
series then I'll adopt the change when I repost, or another alternative is
maybe we can also do that on top, depending on whether there's further
comments..
Thanks!
--
Peter Xu
prev parent reply other threads:[~2020-06-30 21:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-30 20:45 Peter Xu
2020-06-30 21:05 ` David Rientjes
2020-06-30 21:30 ` Peter Xu [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=20200630213009.GB40675@xz-x1 \
--to=peterx@redhat.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=gerald.schaefer@de.ibm.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mpe@ellerman.id.au \
--cc=rientjes@google.com \
--cc=torvalds@linux-foundation.org \
--cc=will@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