From nobody Fri Apr 3 16:05:30 2026 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 EFAE43630A4 for ; Tue, 24 Mar 2026 11:32:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774351952; cv=none; b=QgDePEBNvF9i6veKwnnpd9hsHZ72Yd1vTihKzzhWxfxigZ1yUl3sxXWwCZ4ctD5tABNyK9p/ShpN4ycnITNQVLheMHXrx/H0gF/pBqwqVv2Yw569gRlRfTgOAp5GKTg3wBPWPI0q0nloICT7FokMit3qJ/BTwkzlxpwJ0NVXw5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774351952; c=relaxed/simple; bh=LeFERY5fpqwSuejpimhOa0Eveubb3hi6ECN0tf5vCfk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PNl1QGwdEe5qofnVfwyub5Oy7gmyPPfIKaLpKMEec+ckGr+NxJdQOjsiY5hGUFnaUMe81NZ35j29uMQJDn36faEaJZLMkCVfXDkSim36j4We61fopQ5d82+eR0v1WXiQrZjV/U2zDU2JtH6f8qIsLoY0XTwlGWrp+C2t1CqPv9M= 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=ieg4jbYX; arc=none smtp.client-ip=91.218.175.173 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="ieg4jbYX" 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=1774351948; 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=yNYpUOaMZIeZUWxbOHw8FLcvpCl6K8p2fZA9SJluFcw=; b=ieg4jbYXQyfGbDByIxQL9Y6ghz7w9XESh4i7xYz6KL8RXyVjW6kO6tWU27EiTzzHjzwLZJ khFvHaxvCXrzVN5ss/OceXPXFAoV3kqiiMHZpHVSPjL9nAZk2AzX2q9C4wMUUeGBnt5Thl /Q4ckhoHwiyoKQewfEMysZU4TvgXFDk= 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, lorenzo.stoakes@oracle.com, 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 1/3] mm: memcontrol: correct the type of stats_updates to unsigned long Date: Tue, 24 Mar 2026 19:31:27 +0800 Message-ID: <74022705dc8d5209ff7e603a178044fe4cfbae09.1774342371.git.zhengqi.arch@bytedance.com> 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 Now, the memcg_rstat_updated() is for vmstats_percpu->state and lruvec_stats_percpu->state, which are both of type long, so let's change the type of stats_updates to unsigned long as well. Signed-off-by: Qi Zheng --- mm/memcontrol.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a47fb68dd65f1..7fb9cbc10dfbb 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -608,7 +608,7 @@ static inline int memcg_events_index(enum vm_event_item= idx) =20 struct memcg_vmstats_percpu { /* Stats updates since the last flush */ - unsigned int stats_updates; + unsigned long stats_updates; =20 /* Cached pointers for fast iteration in memcg_rstat_updated() */ struct memcg_vmstats_percpu __percpu *parent_pcpu; @@ -639,7 +639,7 @@ struct memcg_vmstats { unsigned long events_pending[NR_MEMCG_EVENTS]; =20 /* Stats updates since the last flush */ - atomic_t stats_updates; + atomic_long_t stats_updates; }; =20 /* @@ -665,16 +665,16 @@ static u64 flush_last_time; =20 static bool memcg_vmstats_needs_flush(struct memcg_vmstats *vmstats) { - return atomic_read(&vmstats->stats_updates) > + return atomic_long_read(&vmstats->stats_updates) > MEMCG_CHARGE_BATCH * num_online_cpus(); } =20 -static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val, +static inline void memcg_rstat_updated(struct mem_cgroup *memcg, long val, int cpu) { struct memcg_vmstats_percpu __percpu *statc_pcpu; struct memcg_vmstats_percpu *statc; - unsigned int stats_updates; + unsigned long stats_updates; =20 if (!val) return; @@ -697,7 +697,7 @@ static inline void memcg_rstat_updated(struct mem_cgrou= p *memcg, int val, continue; =20 stats_updates =3D this_cpu_xchg(statc_pcpu->stats_updates, 0); - atomic_add(stats_updates, &statc->vmstats->stats_updates); + atomic_long_add(stats_updates, &statc->vmstats->stats_updates); } } =20 @@ -705,7 +705,7 @@ static void __mem_cgroup_flush_stats(struct mem_cgroup = *memcg, bool force) { bool needs_flush =3D memcg_vmstats_needs_flush(memcg->vmstats); =20 - trace_memcg_flush_stats(memcg, atomic_read(&memcg->vmstats->stats_updates= ), + trace_memcg_flush_stats(memcg, atomic_long_read(&memcg->vmstats->stats_up= dates), force, needs_flush); =20 if (!force && !needs_flush) @@ -4406,8 +4406,8 @@ static void mem_cgroup_css_rstat_flush(struct cgroup_= subsys_state *css, int cpu) } WRITE_ONCE(statc->stats_updates, 0); /* We are in a per-cpu loop here, only do the atomic write once */ - if (atomic_read(&memcg->vmstats->stats_updates)) - atomic_set(&memcg->vmstats->stats_updates, 0); + if (atomic_long_read(&memcg->vmstats->stats_updates)) + atomic_long_set(&memcg->vmstats->stats_updates, 0); } =20 static void mem_cgroup_fork(struct task_struct *task) --=20 2.20.1