Commit 6c99816
mm: fix accounting of memmap pages
[ Upstream commit c357688 ]
For !CONFIG_SPARSEMEM_VMEMMAP, memmap page accounting is currently done
upfront in sparse_buffer_init(). However, sparse_buffer_alloc() may
return NULL in failure scenario.
Also, memmap pages may be allocated either from the memblock allocator
during early boot or from the buddy allocator. When removed via
arch_remove_memory(), accounting of memmap pages must reflect the original
allocation source.
To ensure correctness:
* Account memmap pages after successful allocation in sparse_init_nid()
and section_activate().
* Account memmap pages in section_deactivate() based on allocation
source.
Link: https://lkml.kernel.org/r/20250807183545.1424509-1-sumanthk@linux.ibm.com
Fixes: 15995a3 ("mm: report per-page metadata information")
Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Suggested-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 1ee0e14814b88ff1771c212a94226a624486637a)
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>1 parent 7ca37ab commit 6c99816
2 files changed
+9
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | 477 | | |
483 | 478 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | 465 | | |
469 | 466 | | |
470 | 467 | | |
| |||
532 | 529 | | |
533 | 530 | | |
534 | 531 | | |
| 532 | + | |
| 533 | + | |
535 | 534 | | |
536 | 535 | | |
537 | 536 | | |
| |||
643 | 642 | | |
644 | 643 | | |
645 | 644 | | |
646 | | - | |
647 | 645 | | |
648 | 646 | | |
649 | 647 | | |
| |||
819 | 817 | | |
820 | 818 | | |
821 | 819 | | |
822 | | - | |
| 820 | + | |
| 821 | + | |
823 | 822 | | |
824 | | - | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
825 | 826 | | |
| 827 | + | |
826 | 828 | | |
827 | 829 | | |
828 | 830 | | |
| |||
867 | 869 | | |
868 | 870 | | |
869 | 871 | | |
| 872 | + | |
870 | 873 | | |
871 | 874 | | |
872 | 875 | | |
| |||
0 commit comments