mm/cma: fix placement of trace_cma_alloc_start/finish
[linux-2.6-block.git] / mm / cma.c
index 7c09c47e530bf624fd05cfec3456fbf2346446e3..e12cf41d83549aad4ab771b3379863c3cc1786fb 100644 (file)
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -436,6 +436,9 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
        unsigned long i;
        struct page *page = NULL;
        int ret = -ENOMEM;
+       const char *name = cma ? cma->name : NULL;
+
+       trace_cma_alloc_start(name, count, align);
 
        if (!cma || !cma->count || !cma->bitmap)
                goto out;
@@ -446,8 +449,6 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
        if (!count)
                goto out;
 
-       trace_cma_alloc_start(cma->name, count, align);
-
        mask = cma_bitmap_aligned_mask(cma, align);
        offset = cma_bitmap_aligned_offset(cma, align);
        bitmap_maxno = cma_bitmap_maxno(cma);
@@ -496,8 +497,6 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
                start = bitmap_no + mask + 1;
        }
 
-       trace_cma_alloc_finish(cma->name, pfn, page, count, align, ret);
-
        /*
         * CMA can allocate multiple page blocks, which results in different
         * blocks being marked with different tags. Reset the tags to ignore
@@ -516,6 +515,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
 
        pr_debug("%s(): returned %p\n", __func__, page);
 out:
+       trace_cma_alloc_finish(name, pfn, page, count, align, ret);
        if (page) {
                count_vm_event(CMA_ALLOC_SUCCESS);
                cma_sysfs_account_success_pages(cma, count);