Commit aa555722 authored by David Wang's avatar David Wang Committed by Suren Baghdasaryan
Browse files

UPSTREAM: mm/codetag: swap tags when migrate pages

Current solution to adjust codetag references during page migration is
done in 3 steps:

1. sets the codetag reference of the old page as empty (not pointing
   to any codetag);

2. subtracts counters of the new page to compensate for its own
   allocation;

3. sets codetag reference of the new page to point to the codetag of
   the old page.

This does not work if CONFIG_MEM_ALLOC_PROFILING_DEBUG=n because
set_codetag_empty() becomes NOOP.  Instead, let's simply swap codetag
references so that the new page is referencing the old codetag and the old
page is referencing the new codetag.  This way accounting stays valid and
the logic makes more sense.

Link: https://lkml.kernel.org/r/20241129025213.34836-1-00107082@163.com


Fixes: e0a955bf ("mm/codetag: add pgalloc_tag_copy()")
Signed-off-by: default avatarDavid Wang <00107082@163.com>
Closes: https://lore.kernel.org/lkml/20241124074318.399027-1-00107082@163.com/


Acked-by: default avatarSuren Baghdasaryan <surenb@google.com>
Suggested-by: default avatarSuren Baghdasaryan <surenb@google.com>
Acked-by: default avatarYu Zhao <yuzhao@google.com>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 51f43d5d)
Bug: 380948583
Change-Id: I1f66fee446c96ec2ea7ccad62ae0479e0b14b2bf
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
parent bd70b68c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment