Re: [PATCH v2 2/9] mm/memory_hotplug: introduce "auto-movable" online policy

David Hildenbrand
2021-07-26T07:15:43Z

>
> +struct auto_movable_stats {
> + unsigned long kernel_early_pages;
> + unsigned long movable_pages;
> +};
> +
> +static void auto_movable_stats_account_zone(struct auto_movable_stats *stats,
> + struct zone *zone)
> +{
> + if (zone_idx(zone) == ZONE_MOVABLE) {
> + stats->movable_pages += zone->present_pages;
> + } else {
> + /*
> + * CMA pages (never on hotplugged memory) behave like
> + * ZONE_MOVABLE.
> + */
> + stats->movable_pages += zone->cma_pages;
> + stats->kernel_early_pages += zone->present_early_pages;
> + stats->kernel_early_pages -= zone->cma_pages;
> + }
> +}

The following on top to make it compile without CONFIG_CMA (thanks Randy):

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index bfdaa28eb86f..fa1a0afd32ba 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -741,13 +741,15 @@ static void auto_movable_stats_account_zone(struct auto_movable_stats *stats,
if (zone_idx(zone) == ZONE_MOVABLE) {
stats->movable_pages += zone->present_pages;
} else {
+ stats->kernel_early_pages += zone->present_early_pages;
+#ifdef CONFIG_CMA
/*
* CMA pages (never on hotplugged memory) behave like
* ZONE_MOVABLE.
*/
stats->movable_pages += zone->cma_pages;
- stats->kernel_early_pages += zone->present_early_pages;
stats->kernel_early_pages -= zone->cma_pages;
+#endif /* CONFIG_CMA */
}
}
struct auto_movable_group_stats {

--
Thanks,

David / dhildenb