cma: move memory allocation to a helper function
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Thu, 3 Jul 2025 18:47:11 +0000 (21:47 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 13 Jul 2025 23:38:24 +0000 (16:38 -0700)
commit8aa2c0bf0aa92044c8f20ba250448356da509859
tree362a67d39bed8393d6b180dc53d0806d4b918b0d
parentbef5871662efe251b9dae937d35b6d0db9fa127e
cma: move memory allocation to a helper function

__cma_declare_contiguous_nid() tries to allocate memory in several ways:
* on systems with 64 bit physical address and enough memory it first
  attempts to allocate memory just above 4GiB
* if that fails, on systems with HIGHMEM the next attempt is from high
  memory
* and at last, if none of the previous attempts succeeded, or was even
  tried because of incompatible configuration, the memory is allocated
  anywhere within specified limits.

Move all the allocation logic to a helper function to make these steps more
obvious.

Link: https://lkml.kernel.org/r/20250703184711.3485940-4-rppt@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Oscar Salvador <osalvador@suse.de>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Pratyush Yadav <ptyadav@amazon.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/cma.c