From nobody Thu Apr 2 18:40:10 2026 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90D5A265623 for ; Fri, 27 Mar 2026 10:17:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774606635; cv=none; b=BXpWvA5MGDXQ9st5obrR/4m3qvtDabyZ5cLwdSzXEcRZYKKAYYo605QxiUnB8sWsa5HwTfIHzsBH0qfq6waYWDv7f2Ce+GwvKwtEFClM3ZixLs2NxcApHj8z0JQHRUT11OPki8f6l3h2XLChTMzMTi0RLwLd6auYCtxyld8Hm74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774606635; c=relaxed/simple; bh=yMB3/ooHe2TsaSIm/80Fq3LtKHxedmgU+BSGA2qiWnw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZZL9t6SxDkzGSFjoYfz/pyWGy9G45nRTdvNdgbbsbe246//WyKlZ/aqQIXAch3P6MmUo6z1c73MGItgSEL62QavBaVs5ELQfW3ILVGEtmSb7OoUlRnF+t90ZsA2ZJE6tC0gBPX6zgZMrFiosx2lbIDy8wHlsZYyFkXmtf3lX1XQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vG1/z7mg; arc=none smtp.client-ip=95.215.58.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vG1/z7mg" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774606632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UVKpbAnwCWHxI9guS/ESyy7LHjntk0mlIyxKMppd3m0=; b=vG1/z7mgViJzxOnjTjMlweyBjtVjOGYcuMOZjqWfkr6P8/tf07CfNHrnXxPLk5C6N4hFyl FcnTxboGuJtqhJ9mYyHn6PLQiAbEhTC/oQg6+L7LFCdzPPc5cUodzxymTzhqfR5KxZfOqo ExSJSjgAUd4gfH0mk3etG+8nkXQLeLI= From: Qi Zheng To: hannes@cmpxchg.org, hughd@google.com, mhocko@suse.com, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, david@kernel.org, ljs@kernel.org, ziy@nvidia.com, harry.yoo@oracle.com, yosry.ahmed@linux.dev, imran.f.khan@oracle.com, kamalesh.babulal@oracle.com, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, chenridong@huaweicloud.com, mkoutny@suse.com, akpm@linux-foundation.org, hamzamahfooz@linux.microsoft.com, apais@linux.microsoft.com, lance.yang@linux.dev, bhe@redhat.com, usamaarif642@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng Subject: [PATCH v3 3/3] mm: memcontrol: correct the nr_pages parameter type of mem_cgroup_update_lru_size() Date: Fri, 27 Mar 2026 18:16:30 +0800 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Qi Zheng 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. Signed-off-by: Qi Zheng Acked-by: Zi Yan Reviewed-by: Harry Yoo (Oracle) Reviewed-by: Lorenzo Stoakes (Oracle) --- include/linux/memcontrol.h | 2 +- mm/memcontrol.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 0782c72a1997b..4a7d8c4f55b48 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -874,7 +874,7 @@ static inline bool mem_cgroup_online(struct mem_cgroup = *memcg) } =20 void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru, - int zid, int nr_pages); + int zid, long nr_pages); =20 static inline unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec, diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 51d72ddf08119..bf74167d77c5b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1472,7 +1472,7 @@ struct lruvec *folio_lruvec_lock_irqsave(struct folio= *folio, * to or just after a page is removed from an lru list. */ void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru, - int zid, int nr_pages) + int zid, long nr_pages) { struct mem_cgroup_per_node *mz; unsigned long *lru_size; @@ -1489,7 +1489,7 @@ void mem_cgroup_update_lru_size(struct lruvec *lruvec= , enum lru_list lru, =20 size =3D *lru_size; if (WARN_ONCE(size < 0, - "%s(%p, %d, %d): lru_size %ld\n", + "%s(%p, %d, %ld): lru_size %ld\n", __func__, lruvec, lru, nr_pages, size)) { VM_BUG_ON(1); *lru_size =3D 0; --=20 2.20.1