^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) =====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) CMA Debugfs Interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) =====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) The CMA debugfs interface is useful to retrieve basic information out of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) different CMA areas and to test allocation/release in each of the areas.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) Each CMA zone represents a directory under <debugfs>/cma/, indexed by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) kernel's CMA index. So the first CMA zone would be:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) <debugfs>/cma/cma-0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) The structure of the files created under that directory is as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) - [RO] base_pfn: The base PFN (Page Frame Number) of the zone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) - [RO] count: Amount of memory in the CMA area.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) - [RO] order_per_bit: Order of pages represented by one bit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) - [RO] bitmap: The bitmap of page states in the zone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) - [WO] alloc: Allocate N pages from that CMA area. For example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) echo 5 > <debugfs>/cma/cma-2/alloc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) would try to allocate 5 pages from the cma-2 area.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) - [WO] free: Free N pages from that CMA area, similar to the above.