From: David Hildenbrand <[email protected]>

mm/cma: print RHEL-specific warnings when CMA is first invoked

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1945002
Upstream: RHEL only

CMA is Tech Preview in RHEL 9; to detect the use of CMA easily, let's print
warninigs when
* Activating a CMA region succeeds
* cma_alloc() is called for the first time
* cma_release() is called for the first time

Print when cma_alloc()/cma_release() will actually do some work; for
example, cma_release() is sometimes called for memory regions even though
the memory isn't managed by CMA.

Signed-off-by: David Hildenbrand <[email protected]>

diff a/mm/cma.c b/mm/cma.c
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -125,6 +125,12 @@ static void __init cma_activate_area(struct cma *cma)
        spin_lock_init(&cma->mem_head_lock);
 #endif
 
+#ifdef CONFIG_RHEL_DIFFERENCES
+       pr_warn("CMA area %s at [0x%llx-0x%llx] was activated\n", cma->name,
+               (unsigned long long)PFN_PHYS(cma->base_pfn),
+               (unsigned long long)PFN_PHYS(cma->base_pfn + cma->count) - 1);
+#endif /* CONFIG_RHEL_DIFFERENCES */
+
        return;
 
 not_in_zone:
@@ -437,6 +443,10 @@ struct page *cma_alloc(struct cma *cma, size_t count, 
unsigned int align,
        if (!cma || !cma->count || !cma->bitmap)
                return NULL;
 
+#ifdef CONFIG_RHEL_DIFFERENCES
+       pr_warn_once("%s() got called for the first time\n", __func__);
+#endif /* CONFIG_RHEL_DIFFERENCES */
+
        pr_debug("%s(cma %p, count %zu, align %d)\n", __func__, (void *)cma,
                 count, align);
 
@@ -533,6 +543,10 @@ bool cma_release(struct cma *cma, const struct page 
*pages, unsigned int count)
        if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count)
                return false;
 
+#ifdef CONFIG_RHEL_DIFFERENCES
+       pr_warn_once("%s() got called for the first time\n", __func__);
+#endif /* CONFIG_RHEL_DIFFERENCES */
+
        VM_BUG_ON(pfn + count > cma->base_pfn + cma->count);
 
        free_contig_range(pfn, count);

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1023
_______________________________________________
kernel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/[email protected]
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to