From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
<linux-mm@kvack.org>, <linux-fsdevel@vger.kernel.org>,
Muchun Song <muchun.song@linux.dev>
Subject: Re: [PATCH rfc 4/4] mm: filemap: try to batch lruvec stat updating
Date: Fri, 10 May 2024 09:55:23 +0800 [thread overview]
Message-ID: <5a1eb9ca-663c-4d38-855a-c29297ecbeab@huawei.com> (raw)
In-Reply-To: <20240509140149.GA374370@cmpxchg.org>
On 2024/5/9 22:01, Johannes Weiner wrote:
> On Tue, May 07, 2024 at 05:06:57PM +0800, Kefeng Wang wrote:
>>> +static void filemap_lruvec_stat_update(struct mem_cgroup *memcg,
>>> + pg_data_t *pgdat, int nr)
>>> +{
>>> + struct lruvec *lruvec;
>>> +
>>> + if (!memcg) {
>>> + __mod_node_page_state(pgdat, NR_FILE_MAPPED, nr);
>>> + return;
>>> + }
>>> +
>>> + lruvec = mem_cgroup_lruvec(memcg, pgdat);
>>> + __mod_lruvec_state(lruvec, NR_FILE_MAPPED, nr);
>>> +}
>>> +
>>> vm_fault_t filemap_map_pages(struct vm_fault *vmf,
>>> pgoff_t start_pgoff, pgoff_t end_pgoff)
>>> {
>>> @@ -3628,6 +3642,9 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf,
>>> vm_fault_t ret = 0;
>>> unsigned long rss = 0;
>>> unsigned int nr_pages = 0, mmap_miss = 0, mmap_miss_saved, folio_type;
>>> + struct mem_cgroup *memcg, *memcg_cur;
>>> + pg_data_t *pgdat, *pgdat_cur;
>>> + int nr_mapped = 0;
>>>
>>> rcu_read_lock();
>>> folio = next_uptodate_folio(&xas, mapping, end_pgoff);
>>> @@ -3648,9 +3665,20 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf,
>>> }
>>>
>>> folio_type = mm_counter_file(folio);
>>> + memcg = folio_memcg(folio);
>>> + pgdat = folio_pgdat(folio);
>
> You should be able to do:
>
> lruvec = folio_lruvec(folio);
>
> and then pass that directly to filemap_lruvec_stat_update().
It's obviously better, will update and address David's comment in
patch3, thank you.
prev parent reply other threads:[~2024-05-10 1:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 7:24 [PATCH rfc 0/4] mm: filemap: try to batch lruvec stat updating Kefeng Wang
2024-04-29 7:24 ` [PATCH rfc 1/4] mm: memory: add prepare_range_pte_entry() Kefeng Wang
2024-04-29 7:24 ` [PATCH rfc 2/4] mm: filemap: add filemap_set_pte_range() Kefeng Wang
2024-04-29 7:24 ` [PATCH rfc 3/4] mm: filemap: move __lruvec_stat_mod_folio() out of filemap_set_pte_range() Kefeng Wang
2024-05-07 11:11 ` David Hildenbrand
2024-05-07 13:12 ` Kefeng Wang
2024-05-08 9:33 ` David Hildenbrand
2024-05-08 11:15 ` Kefeng Wang
2024-05-08 11:27 ` David Hildenbrand
2024-05-08 13:56 ` Kefeng Wang
2024-04-29 7:24 ` [PATCH rfc 4/4] mm: filemap: try to batch lruvec stat updating Kefeng Wang
2024-05-07 9:06 ` Kefeng Wang
2024-05-09 14:01 ` Johannes Weiner
2024-05-10 1:55 ` Kefeng Wang [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=5a1eb9ca-663c-4d38-855a-c29297ecbeab@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--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 read-only IMAP folder(s) and NNTP newsgroup(s).