]> git.baikalelectronics.ru Git - kernel.git/commit
mm: list_lru: fix the return value of list_lru_count_one()
authorMuchun Song <songmuchun@bytedance.com>
Fri, 5 Nov 2021 20:37:50 +0000 (13:37 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 6 Nov 2021 20:30:35 +0000 (13:30 -0700)
commit7dc62d77cb51b606e185a1889681fbe0518f3580
tree5847dee7f7d5e734fbd7fb7c625c1100700707f6
parent6f1a0b6ec8f5ef879df4bf3797bdd8f798656a5e
mm: list_lru: fix the return value of list_lru_count_one()

Since commit 9335f2278020 ("memcg: reparent list_lrus and free kmemcg_id
on css offline"), ->nr_items can be negative during memory cgroup
reparenting.  In this case, list_lru_count_one() will return an unusual
and huge value, which can surprise users.  At least for now it hasn't
affected any users.  But it is better to let list_lru_count_ont()
returns zero when ->nr_items is negative.

Link: https://lkml.kernel.org/r/20211025124910.56433-1-songmuchun@bytedance.com
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Roman Gushchin <guro@fb.com>
Cc: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/list_lru.c