Re: [PATCH] mm/mm_init.c: add debug messsge for dma zone

From: Michal Hocko
Date: Wed Jun 07 2023 - 06:16:20 EST


On Wed 07-06-23 09:07:34, Haifeng Xu wrote:
> If freesize is less than dma_reserve, print warning message to report
> this case.

Why?

> Signed-off-by: Haifeng Xu <haifeng.xu@xxxxxxxxxx>
> ---
> mm/mm_init.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 232efac9a929..9a9d6a52471c 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1561,9 +1561,14 @@ static void __init free_area_init_core(struct pglist_data *pgdat)
> }
>
> /* Account for reserved pages */
> - if (j == 0 && freesize > dma_reserve) {
> - freesize -= dma_reserve;
> - pr_debug(" %s zone: %lu pages reserved\n", zone_names[0], dma_reserve);
> + if (j == 0) {
> + if (freesize >= dma_reserve) {
> + freesize -= dma_reserve;
> + pr_debug(" %s zone: %lu pages reserved\n",
> + zone_names[0], dma_reserve);
> + } else
> + pr_warn(" %s zone: %lu reserved pages exceeds freesize %lu\n",
> + zone_names[0], dma_reserve, freesize);
> }
>
> if (!is_highmem_idx(j))
> --
> 2.25.1

--
Michal Hocko
SUSE Labs