From: Matthew Wilcox <willy@infradead.org>
To: Yin Fengwei <fengwei.yin@intel.com>
Cc: david@redhat.com, linux-mm@kvack.org, dave.hansen@intel.com,
tim.c.chen@intel.com, ying.huang@intel.com
Subject: Re: [RFC PATCH v2 5/5] filemap: batched update mm counter,rmap when map file folio
Date: Wed, 1 Feb 2023 15:50:23 +0000 [thread overview]
Message-ID: <Y9qKP0EX4Q+48Dga@casper.infradead.org> (raw)
In-Reply-To: <20230201081737.2330141-6-fengwei.yin@intel.com>
On Wed, Feb 01, 2023 at 04:17:37PM +0800, Yin Fengwei wrote:
> Use do_set_pte_range() in filemap_map_folio_range(). Which
> batched updates mm counter, rmap.
>
> With a self cooked will-it-scale.page_fault3 like app (change
> file write fault to read fault) got 15% performance gain.
I'd suggest that you create a will-it-scale.page_fault4. Anton
is quite open to adding new variations of tests.
> Perf data collected before/after the change:
> 18.73%--page_add_file_rmap
> |
> --11.60%--__mod_lruvec_page_state
> |
> |--7.40%--__mod_memcg_lruvec_state
> | |
> | --5.58%--cgroup_rstat_updated
> |
> --2.53%--__mod_lruvec_state
> |
> --1.48%--__mod_node_page_state
>
> 9.93%--page_add_file_rmap_range
> |
> --2.67%--__mod_lruvec_page_state
> |
> |--1.95%--__mod_memcg_lruvec_state
> | |
> | --1.57%--cgroup_rstat_updated
> |
> --0.61%--__mod_lruvec_state
> |
> --0.54%--__mod_node_page_state
>
> The running time of __mode_lruvec_page_state() is reduced a lot.
Nice.
> +++ b/mm/filemap.c
> @@ -3364,11 +3364,22 @@ static vm_fault_t filemap_map_folio_range(struct vm_fault *vmf,
> struct file *file = vma->vm_file;
> struct page *page = folio_page(folio, start);
> unsigned int mmap_miss = READ_ONCE(file->f_ra.mmap_miss);
> - unsigned int ref_count = 0, count = 0;
> + unsigned int ref_count = 0, count = 0, nr_mapped = 0;
>
> do {
> - if (PageHWPoison(page))
> + if (PageHWPoison(page)) {
> + if (nr_mapped) {
> + vmf->pte -= nr_mapped;
> + do_set_pte_range(vmf, folio,
> + start + count - nr_mapped,
> + addr - nr_mapped * PAGE_SIZE,
> + nr_mapped);
> +
> + }
> +
> + nr_mapped = 0;
> continue;
> + }
Having subtracted nr_mapped from vmf->pte, we then need to add it again.
But this is all too complicated. What if we don't update vmf->pte
each time around the loop? ie something like this:
do {
if (PageHWPoisoned(page))
goto map;
if (mmap_miss > 0)
mmap_miss--;
/*
* If there're PTE markers, we'll leave them to be handled
* in the specific fault path, and it'll prohibit the
* fault-around logic.
*/
if (!pte_none(vmf->pte[count]))
goto map;
if (vmf->address == addr + count * PAGE_SIZE)
ret = VM_FAULT_NOPAGE;
continue;
map:
if (count > 1) {
do_set_pte_range(vmf, folio, start, addr, count - 1);
folio_ref_add(folio, count - 1);
}
start += count;
vmf->pte += count;
addr += count * PAGE_SIZE;
nr_pages -= count;
count = 0;
} while (page++, ++count < nr_pages);
if (count > 0) {
do_set_pte_range(vmf, folio, start, addr, count);
folio_ref_add(folio, count);
} else {
/* Make sure the PTE points to the correct page table */
vmf->pte--;
}
next prev parent reply other threads:[~2023-02-01 15:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 8:17 [RFC PATCH v2 0/5] folio based filemap_map_pages() Yin Fengwei
2023-02-01 8:17 ` [RFC PATCH v2 1/5] mm: Enable fault around for shared file page fault Yin Fengwei
2023-02-01 14:34 ` Kirill A. Shutemov
2023-02-02 1:54 ` Yin, Fengwei
2023-02-01 8:17 ` [RFC PATCH v2 2/5] filemap: add function filemap_map_folio_range() Yin Fengwei
2023-02-01 8:17 ` [RFC PATCH v2 3/5] rmap: add page_add_file_rmap_range() Yin Fengwei
2023-02-01 17:32 ` Matthew Wilcox
2023-02-02 2:00 ` Yin, Fengwei
2023-02-01 8:17 ` [RFC PATCH v2 4/5] mm: add do_set_pte_range() Yin Fengwei
2023-02-01 9:09 ` David Hildenbrand
2023-02-01 10:04 ` Yin, Fengwei
2023-02-01 17:38 ` Matthew Wilcox
2023-02-01 21:59 ` Matthew Wilcox
2023-02-02 3:18 ` Yin, Fengwei
2023-02-03 8:54 ` Yin Fengwei
2023-02-01 8:17 ` [RFC PATCH v2 5/5] filemap: batched update mm counter,rmap when map file folio Yin Fengwei
2023-02-01 15:50 ` Matthew Wilcox [this message]
2023-02-02 3:31 ` Yin, Fengwei
2023-02-03 13:15 ` Yin, Fengwei
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=Y9qKP0EX4Q+48Dga@casper.infradead.org \
--to=willy@infradead.org \
--cc=dave.hansen@intel.com \
--cc=david@redhat.com \
--cc=fengwei.yin@intel.com \
--cc=linux-mm@kvack.org \
--cc=tim.c.chen@intel.com \
--cc=ying.huang@intel.com \
/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