Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: memcontrol: correct the nr_pages parameter type of mem_cgroup_update_lru_size()

The nr_pages parameter of mem_cgroup_update_lru_size() represents a page
count. During the reparenting of LRU folios, the value passed to it can
potentially exceed the maximum value of a 32-bit integer. It should be
declared as long instead of int to match the types used in lruvec size
accounting and to prevent possible overflow.

Update the parameter type to long to ensure correctness.

Link: https://lore.kernel.org/fd4140de44fa0a3978e4e2426731187fe8625f0b.1774604356.git.zhengqi.arch@bytedance.com
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Reviewed-by: Harry Yoo (Oracle) <harry@kernel.org>
Cc: Allen Pais <apais@linux.microsoft.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Imran Khan <imran.f.khan@oracle.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Usama Arif <usamaarif642@gmail.com>
Cc: Wei Xu <weixugc@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Qi Zheng and committed by
Andrew Morton
1c514a2c 85358bad

+3 -3
+1 -1
include/linux/memcontrol.h
··· 878 878 } 879 879 880 880 void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru, 881 - int zid, int nr_pages); 881 + int zid, long nr_pages); 882 882 883 883 static inline 884 884 unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec,
+2 -2
mm/memcontrol.c
··· 1472 1472 * to or just after a page is removed from an lru list. 1473 1473 */ 1474 1474 void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru, 1475 - int zid, int nr_pages) 1475 + int zid, long nr_pages) 1476 1476 { 1477 1477 struct mem_cgroup_per_node *mz; 1478 1478 unsigned long *lru_size; ··· 1489 1489 1490 1490 size = *lru_size; 1491 1491 if (WARN_ONCE(size < 0, 1492 - "%s(%p, %d, %d): lru_size %ld\n", 1492 + "%s(%p, %d, %ld): lru_size %ld\n", 1493 1493 __func__, lruvec, lru, nr_pages, size)) { 1494 1494 VM_BUG_ON(1); 1495 1495 *lru_size = 0;