From: Michal Hocko <mhocko@suse.com>
To: Zhongkun He <hezhongkun.hzk@bytedance.com>
Cc: minchan@kernel.org, senozhatsky@chromium.org, david@redhat.com,
yosryahmed@google.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 2/2] zram: charge the compressed RAM to the page's memcgroup
Date: Mon, 10 Jul 2023 12:52:17 +0200 [thread overview]
Message-ID: <ZKvi4ZvhQaIFtSvg@dhcp22.suse.cz> (raw)
In-Reply-To: <20230707044707.1169285-1-hezhongkun.hzk@bytedance.com>
On Fri 07-07-23 12:47:07, Zhongkun He wrote:
[...]
> @@ -1692,11 +1725,21 @@ static int zram_recompress(struct zram *zram, u32 index, struct page *page,
>
> zs_unmap_object(zram->mem_pool, handle_new);
>
> + /*
> + * Recompress will reclaim some memory, so we set the reclaim
> + * flag in order to charge comp_len_new successfully.
> + */
> + noreclaim_flag = memalloc_noreclaim_save();
> + objcg = zram_get_obj_cgroup(zram, index);
> + obj_cgroup_get(objcg);
> zram_free_page(zram, index);
> + obj_cgroup_charge_zram(objcg, GFP_KERNEL, comp_len_new);
AFAICS your obj_cgroup_charge_zram doesn't have gfp argument.
Anyway, memalloc_noreclaim_save is an abuse IMHO (the primary purpose of
the flag is to prevent recursion into the memory reclaim). Do you really
can not perform any memory recalim to trigger to free up some memory if
the memcg is at the hard limit boundary?
> + zram_set_obj_cgroup(zram, index, objcg);
> zram_set_handle(zram, index, handle_new);
> zram_set_obj_size(zram, index, comp_len_new);
> zram_set_priority(zram, index, prio);
>
> + memalloc_noreclaim_restore(noreclaim_flag);
> atomic64_add(comp_len_new, &zram->stats.compr_data_size);
> atomic64_inc(&zram->stats.pages_stored);
>
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2023-07-10 10:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-07 4:47 Zhongkun He
2023-07-10 10:52 ` Michal Hocko [this message]
2023-07-10 14:59 ` [External] " 贺中坤
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=ZKvi4ZvhQaIFtSvg@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=david@redhat.com \
--cc=hezhongkun.hzk@bytedance.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=senozhatsky@chromium.org \
--cc=yosryahmed@google.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