From: Chen Ridong <chenridong@huaweicloud.com>
To: Yu Zhao <yuzhao@google.com>, Hugh Dickins <hughd@google.com>
Cc: akpm@linux-foundation.org, mhocko@kernel.org, hannes@cmpxchg.org,
yosryahmed@google.com, roman.gushchin@linux.dev,
shakeel.butt@linux.dev, muchun.song@linux.dev, davidf@vimeo.com,
vbabka@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org, chenridong@huawei.com,
wangweiyang2@huawei.com
Subject: Re: [next -v1 3/5] memcg: simplify the mem_cgroup_update_lru_size function
Date: Fri, 6 Dec 2024 14:40:53 +0800 [thread overview]
Message-ID: <897b04c9-dba3-44ae-8113-145ca3457cb3@huaweicloud.com> (raw)
In-Reply-To: <CAOUHufbCCkOBGcSPZqNY+FXcrH8+U7_nRvftzOzKUBS4hn+kuQ@mail.gmail.com>
On 2024/12/6 13:33, Yu Zhao wrote:
> On Thu, Dec 5, 2024 at 6:45 PM Chen Ridong <chenridong@huaweicloud.com> wrote:
>>
>> From: Chen Ridong <chenridong@huawei.com>
>>
>> In the `mem_cgroup_update_lru_size` function, the `lru_size` should be
>> updated by adding `nr_pages` regardless of whether `nr_pages` is greater
>> than 0 or less than 0. To simplify this function, add a check for
>> `nr_pages` == 0. When `nr_pages` is not equal to 0, perform the same
>> actions.
>>
>> Signed-off-by: Chen Ridong <chenridong@huawei.com>
>
> NAK.
>
> The commit that added that clearly explains why it was done that way.
Thank you for your reply.
I have read the commit message for ca707239e8a7 ("mm: update_lru_size
warn and reset bad lru_size") before sending my patch. However, I did
not quite understand why we need to deal with the difference between
'nr_pages > 0' and 'nr_pages < 0'.
The 'lru_zone_size' can only be modified in the
'mem_cgroup_update_lru_size' function. Only subtracting 'nr_pages' or
adding 'nr_pages' in a way that causes an overflow can make the size < 0.
For case 1, subtracting 'nr_pages', we should issue a warning if the
size goes below 0. For case 2, when adding 'nr_pages' results in an
overflow, there will be no warning and the size won't be reset to 0 the
first time it occurs . It might be that a warning will be issued the
next time 'mem_cgroup_update_lru_size' is called to modify the
'lru_zone_size'. However, as the commit message said, "the first
occurrence is the most informative," and it seems we have missed that
first occurrence.
As the commit message said: "and then the vast unsigned long size draws
page reclaim into a loop of repeatedly", I think that a warning should
be issued and 'lru_zone_size' should be reset whenever 'size < 0' occurs
for the first time, whether from subtracting or adding 'nr_pages'.
I am be grateful if you can explain more details, it has confused me for
a while. Thank you very much.
Best regards,
Ridong
next prev parent reply other threads:[~2024-12-06 6:41 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-06 1:35 [next -v1 0/5] Some cleanup for memcg Chen Ridong
2024-12-06 1:35 ` [next -v1 1/5] memcg: use OFP_PEAK_UNSET instead of -1 Chen Ridong
2024-12-17 12:27 ` Michal Koutný
2024-12-17 16:55 ` David Finkel
2024-12-17 17:47 ` Shakeel Butt
2024-12-06 1:35 ` [next -v1 2/5] memcg: call the free function when allocation of pn fails Chen Ridong
2024-12-17 12:27 ` Michal Koutný
2024-12-17 17:47 ` Shakeel Butt
2024-12-06 1:35 ` [next -v1 3/5] memcg: simplify the mem_cgroup_update_lru_size function Chen Ridong
2024-12-06 5:33 ` Yu Zhao
2024-12-06 6:40 ` Chen Ridong [this message]
2024-12-06 8:24 ` Hugh Dickins
2024-12-06 10:02 ` Chen Ridong
2024-12-06 21:20 ` Shakeel Butt
2024-12-10 11:35 ` Chen Ridong
2024-12-06 1:35 ` [next -v1 4/5] memcg: factor out the __refill_obj_stock function Chen Ridong
2024-12-17 18:19 ` Shakeel Butt
2024-12-19 1:54 ` Chen Ridong
2024-12-06 1:35 ` [next -v1 5/5] memcg: factor out stat(event)/stat_local(event_local) reading functions Chen Ridong
2024-12-20 9:51 ` Chen Ridong
2024-12-14 1:47 ` [next -v1 0/5] Some cleanup for memcg Chen Ridong
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=897b04c9-dba3-44ae-8113-145ca3457cb3@huaweicloud.com \
--to=chenridong@huaweicloud.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huawei.com \
--cc=davidf@vimeo.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=linux-kernel@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=vbabka@suse.cz \
--cc=wangweiyang2@huawei.com \
--cc=yosryahmed@google.com \
--cc=yuzhao@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