Re: [bug report] mm: memcg: move charge migration code to memcontrol-v1.c

From: Roman Gushchin
Date: Fri Jul 12 2024 - 14:56:24 EST


On Fri, Jul 12, 2024 at 09:07:45AM -0500, Dan Carpenter wrote:
> Hello Roman Gushchin,
>
> Commit e548ad4a7cbf ("mm: memcg: move charge migration code to
> memcontrol-v1.c") from Jun 24, 2024 (linux-next), leads to the
> following Smatch static checker warning:
>
> mm/memcontrol-v1.c:609 mem_cgroup_move_charge_write()
> warn: was expecting a 64 bit value instead of '~(1 | 2)'
>
> mm/memcontrol-v1.c
> 599 #ifdef CONFIG_MMU
> 600 static int mem_cgroup_move_charge_write(struct cgroup_subsys_state *css,
> 601 struct cftype *cft, u64 val)
> 602 {
> 603 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
> 604
> 605 pr_warn_once("Cgroup memory moving (move_charge_at_immigrate) is deprecated. "
> 606 "Please report your usecase to linux-mm@xxxxxxxxx if you "
> 607 "depend on this functionality.\n");
> 608
> --> 609 if (val & ~MOVE_MASK)
>
> val is a u64 and MOVE_MASK is a u32. This only checks if something in the low
> 32 bits is set and it ignores the high 32 bits.

Hi Dan,

thank you for the report!

The mentioned commit just moved to code from memcontrol.c to memcontrol-v1.c,
so the bug is actually much much older. Anyway, the fix is attached below.

Andrew, can you please pick it up?

I don't think the problem and the fix deserve a stable backport.

Thank you!

--