Re: [PATCH v2] memcg: charge before adding to swapcache on swapin

From: Shakeel Butt
Date: Tue Feb 23 2021 - 11:41:07 EST


On Mon, Feb 22, 2021 at 9:55 PM Shakeel Butt <shakeelb@xxxxxxxxxx> wrote:
[snip]
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -596,6 +596,9 @@ static inline bool mem_cgroup_below_min(struct mem_cgroup *memcg)
> }
>
> int mem_cgroup_charge(struct page *page, struct mm_struct *mm, gfp_t gfp_mask);
> +int mem_cgroup_charge_swapin_page(struct page *page, struct mm_struct *mm,
> + gfp_t gfp, swp_entry_t entry);
> +void mem_cgroup_finish_swapin_page(struct page *page, swp_entry_t entry);
>
> void mem_cgroup_uncharge(struct page *page);
> void mem_cgroup_uncharge_list(struct list_head *page_list);
> @@ -1141,6 +1144,17 @@ static inline int mem_cgroup_charge(struct page *page, struct mm_struct *mm,
> return 0;
> }
>
> +static inline int mem_cgroup_charge_swapin_page(struct page *page,
> + struct mm_struct *mm, gfp_t gfp, swp_entry_t entry);

I didn't build-test the !CONFIG_MEMCG config and missed this
semicolon. Andrew, let me know if you want me to send a new version.

> +{
> + return 0;
> +}
> +