[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJD7tkbho1a6pwZq82aHBa8BpXijqVopde3k-RnageOtdO32pw@mail.gmail.com>
Date: Fri, 26 Jul 2024 09:30:38 -0700
From: Yosry Ahmed <yosryahmed@...gle.com>
To: Barry Song <21cnbao@...il.com>
Cc: akpm@...ux-foundation.org, linux-mm@...ck.org, ying.huang@...el.com,
baolin.wang@...ux.alibaba.com, chrisl@...nel.org, david@...hat.com,
hannes@...xchg.org, hughd@...gle.com, kaleshsingh@...gle.com,
kasong@...cent.com, linux-kernel@...r.kernel.org, mhocko@...e.com,
minchan@...nel.org, nphamcs@...il.com, ryan.roberts@....com,
senozhatsky@...omium.org, shakeel.butt@...ux.dev, shy828301@...il.com,
surenb@...gle.com, v-songbaohua@...o.com, willy@...radead.org,
xiang@...nel.org
Subject: Re: [PATCH v5 2/4] mm: Introduce mem_cgroup_swapin_uncharge_swap_nr()
helper for large folios swap-in
On Fri, Jul 26, 2024 at 2:47 AM Barry Song <21cnbao@...il.com> wrote:
>
> From: Barry Song <v-songbaohua@...o.com>
>
> With large folios swap-in, we might need to uncharge multiple entries
> all together, it is better to introduce a helper for that.
>
> Signed-off-by: Barry Song <v-songbaohua@...o.com>
> ---
> include/linux/memcontrol.h | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 1b79760af685..55958cbce61b 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -684,6 +684,14 @@ int mem_cgroup_swapin_charge_folio(struct folio *folio, struct mm_struct *mm,
> gfp_t gfp, swp_entry_t entry);
> void mem_cgroup_swapin_uncharge_swap(swp_entry_t entry);
>
> +static inline void mem_cgroup_swapin_uncharge_swap_nr(swp_entry_t entry, int nr)
> +{
> + int i;
> +
> + for (i = 0; i < nr; i++, entry.val++)
> + mem_cgroup_swapin_uncharge_swap(entry);
mem_cgroup_swapin_uncharge_swap() calls mem_cgroup_uncharge_swap()
which already takes in nr_pages, but we currently only pass 1. Would
it be better if we just make mem_cgroup_swapin_uncharge_swap() take in
nr_pages as well and pass it along to mem_cgroup_uncharge_swap(),
instead of calling it in a loop?
This would batch the page counter, stats updates, and refcount updates
in mem_cgroup_uncharge_swap(). You may be able to observe a bit of a
performance gain with this.
> +}
> +
> void __mem_cgroup_uncharge(struct folio *folio);
>
> /**
> @@ -1185,6 +1193,10 @@ static inline void mem_cgroup_swapin_uncharge_swap(swp_entry_t entry)
> {
> }
>
> +static inline void mem_cgroup_swapin_uncharge_swap_nr(swp_entry_t entry, int nr)
> +{
> +}
> +
> static inline void mem_cgroup_uncharge(struct folio *folio)
> {
> }
> --
> 2.34.1
>
Powered by blists - more mailing lists