From b46045f3fe71fad703ee7d689657af16925d78ca Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Wed, 29 Nov 2017 23:48:10 +0000 Subject: gpu: nvgpu: Cleanup '\n' usage in allocator debugging These '\n' were leftover from the previous debugging macro usage which did no add the '\n' automagically. However, once swapped over to the nvgpu logging system the '\n' is added and no longer needs to be present in the code. This did require one extra modification though to keep things consistent. The __alloc_pstat() macro, used for sending output either to a seq_file or the terminal, needed to add the '\n' for seq_printf() calls and the '\n' had to be deleted in the C files. Change-Id: I4d56317fe2a87bd00033cfe79d06ffc048d91049 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1613641 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/bitmap_allocator.c | 44 ++++++------ drivers/gpu/nvgpu/common/mm/buddy_allocator.c | 92 ++++++++++++------------ drivers/gpu/nvgpu/common/mm/lockless_allocator.c | 32 ++++----- drivers/gpu/nvgpu/common/mm/page_allocator.c | 90 +++++++++++------------ drivers/gpu/nvgpu/include/nvgpu/allocator.h | 10 +-- 5 files changed, 134 insertions(+), 134 deletions(-) diff --git a/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c b/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c index 6bd654b8..f75f9a1f 100644 --- a/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c @@ -91,13 +91,13 @@ static u64 nvgpu_bitmap_alloc_fixed(struct nvgpu_allocator *__a, a->nr_fixed_allocs++; alloc_unlock(__a); - alloc_dbg(__a, "Alloc-fixed 0x%-10llx 0x%-5llx [bits=0x%llx (%llu)]\n", + alloc_dbg(__a, "Alloc-fixed 0x%-10llx 0x%-5llx [bits=0x%llx (%llu)]", base, len, blks, blks); return base; fail: alloc_unlock(__a); - alloc_dbg(__a, "Alloc-fixed failed! (0x%llx)\n", base); + alloc_dbg(__a, "Alloc-fixed failed! (0x%llx)", base); return 0; } @@ -129,7 +129,7 @@ static void nvgpu_bitmap_free_fixed(struct nvgpu_allocator *__a, a->bytes_freed += blks * a->blk_size; alloc_unlock(__a); - alloc_dbg(__a, "Free-fixed 0x%-10llx 0x%-5llx [bits=0x%llx (%llu)]\n", + alloc_dbg(__a, "Free-fixed 0x%-10llx 0x%-5llx [bits=0x%llx (%llu)]", base, len, blks, blks); } @@ -238,7 +238,7 @@ static u64 nvgpu_bitmap_alloc(struct nvgpu_allocator *__a, u64 len) __nvgpu_bitmap_store_alloc(a, addr, blks * a->blk_size)) goto fail_reset_bitmap; - alloc_dbg(__a, "Alloc 0x%-10llx 0x%-5llx [bits=0x%llx (%llu)]\n", + alloc_dbg(__a, "Alloc 0x%-10llx 0x%-5llx [bits=0x%llx (%llu)]", addr, len, blks, blks); a->nr_allocs++; @@ -252,7 +252,7 @@ fail_reset_bitmap: fail: a->next_blk = 0; alloc_unlock(__a); - alloc_dbg(__a, "Alloc failed!\n"); + alloc_dbg(__a, "Alloc failed!"); return 0; } @@ -283,7 +283,7 @@ static void nvgpu_bitmap_free(struct nvgpu_allocator *__a, u64 addr) blks = alloc->length >> a->blk_shift; bitmap_clear(a->bitmap, offs, blks); - alloc_dbg(__a, "Free 0x%-10llx\n", addr); + alloc_dbg(__a, "Free 0x%-10llx", addr); a->bytes_freed += alloc->length; @@ -323,18 +323,18 @@ static void nvgpu_bitmap_print_stats(struct nvgpu_allocator *__a, { struct nvgpu_bitmap_allocator *a = bitmap_allocator(__a); - __alloc_pstat(s, __a, "Bitmap allocator params:\n"); - __alloc_pstat(s, __a, " start = 0x%llx\n", a->base); - __alloc_pstat(s, __a, " end = 0x%llx\n", a->base + a->length); - __alloc_pstat(s, __a, " blks = 0x%llx\n", a->num_bits); + __alloc_pstat(s, __a, "Bitmap allocator params:"); + __alloc_pstat(s, __a, " start = 0x%llx", a->base); + __alloc_pstat(s, __a, " end = 0x%llx", a->base + a->length); + __alloc_pstat(s, __a, " blks = 0x%llx", a->num_bits); /* Actual stats. */ - __alloc_pstat(s, __a, "Stats:\n"); - __alloc_pstat(s, __a, " Number allocs = 0x%llx\n", a->nr_allocs); - __alloc_pstat(s, __a, " Number fixed = 0x%llx\n", a->nr_fixed_allocs); - __alloc_pstat(s, __a, " Bytes alloced = 0x%llx\n", a->bytes_alloced); - __alloc_pstat(s, __a, " Bytes freed = 0x%llx\n", a->bytes_freed); - __alloc_pstat(s, __a, " Outstanding = 0x%llx\n", + __alloc_pstat(s, __a, "Stats:"); + __alloc_pstat(s, __a, " Number allocs = 0x%llx", a->nr_allocs); + __alloc_pstat(s, __a, " Number fixed = 0x%llx", a->nr_fixed_allocs); + __alloc_pstat(s, __a, " Bytes alloced = 0x%llx", a->bytes_alloced); + __alloc_pstat(s, __a, " Bytes freed = 0x%llx", a->bytes_freed); + __alloc_pstat(s, __a, " Outstanding = 0x%llx", a->bytes_alloced - a->bytes_freed); } #endif @@ -421,12 +421,12 @@ int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, #ifdef CONFIG_DEBUG_FS nvgpu_init_alloc_debug(g, __a); #endif - alloc_dbg(__a, "New allocator: type bitmap\n"); - alloc_dbg(__a, " base 0x%llx\n", a->base); - alloc_dbg(__a, " bit_offs 0x%llx\n", a->bit_offs); - alloc_dbg(__a, " size 0x%llx\n", a->length); - alloc_dbg(__a, " blk_size 0x%llx\n", a->blk_size); - alloc_dbg(__a, " flags 0x%llx\n", a->flags); + alloc_dbg(__a, "New allocator: type bitmap"); + alloc_dbg(__a, " base 0x%llx", a->base); + alloc_dbg(__a, " bit_offs 0x%llx", a->bit_offs); + alloc_dbg(__a, " size 0x%llx", a->length); + alloc_dbg(__a, " blk_size 0x%llx", a->blk_size); + alloc_dbg(__a, " flags 0x%llx", a->flags); return 0; diff --git a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c index e5a9b62b..b986b29f 100644 --- a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c @@ -128,7 +128,7 @@ static void __balloc_buddy_list_add(struct nvgpu_buddy_allocator *a, { if (buddy_is_in_list(b)) { alloc_dbg(balloc_owner(a), - "Oops: adding added buddy (%llu:0x%llx)\n", + "Oops: adding added buddy (%llu:0x%llx)", b->order, b->start); BUG(); } @@ -152,7 +152,7 @@ static void __balloc_buddy_list_rem(struct nvgpu_buddy_allocator *a, { if (!buddy_is_in_list(b)) { alloc_dbg(balloc_owner(a), - "Oops: removing removed buddy (%llu:0x%llx)\n", + "Oops: removing removed buddy (%llu:0x%llx)", b->order, b->start); BUG(); } @@ -304,19 +304,19 @@ static void nvgpu_buddy_allocator_destroy(struct nvgpu_allocator *__a) if (a->buddy_list_len[i] != 0) { nvgpu_info(__a->g, - "Excess buddies!!! (%d: %llu)\n", + "Excess buddies!!! (%d: %llu)", i, a->buddy_list_len[i]); BUG(); } if (a->buddy_list_split[i] != 0) { nvgpu_info(__a->g, - "Excess split nodes!!! (%d: %llu)\n", + "Excess split nodes!!! (%d: %llu)", i, a->buddy_list_split[i]); BUG(); } if (a->buddy_list_alloced[i] != 0) { nvgpu_info(__a->g, - "Excess alloced nodes!!! (%d: %llu)\n", + "Excess alloced nodes!!! (%d: %llu)", i, a->buddy_list_alloced[i]); BUG(); } @@ -646,7 +646,7 @@ static struct nvgpu_buddy *__balloc_make_fixed_buddy( /* Welp, that's the end of that. */ alloc_dbg(balloc_owner(a), "Fixed buddy PTE " - "size mismatch!\n"); + "size mismatch!"); return NULL; } @@ -663,7 +663,7 @@ static struct nvgpu_buddy *__balloc_make_fixed_buddy( } if (cur_order > a->max_order) { - alloc_dbg(balloc_owner(a), "No buddy for range ???\n"); + alloc_dbg(balloc_owner(a), "No buddy for range ???"); return NULL; } @@ -671,7 +671,7 @@ static struct nvgpu_buddy *__balloc_make_fixed_buddy( while (bud->start != base || bud->order != order) { if (balloc_split_buddy(a, bud, pte_size)) { alloc_dbg(balloc_owner(a), - "split buddy failed? {0x%llx, %llu}\n", + "split buddy failed? {0x%llx, %llu}", bud->start, bud->order); balloc_coalesce(a, bud); return NULL; @@ -704,7 +704,7 @@ static u64 __balloc_do_alloc_fixed(struct nvgpu_buddy_allocator *a, if (align_order > a->max_order) { alloc_dbg(balloc_owner(a), - "Align order too big: %llu > %llu\n", + "Align order too big: %llu > %llu", align_order, a->max_order); return 0; } @@ -723,7 +723,7 @@ static u64 __balloc_do_alloc_fixed(struct nvgpu_buddy_allocator *a, align_order, pte_size); if (!bud) { alloc_dbg(balloc_owner(a), - "Fixed buddy failed: {0x%llx, %llu}!\n", + "Fixed buddy failed: {0x%llx, %llu}!", balloc_base_unshift(a, inc_base), align_order); goto err_and_cleanup; @@ -799,7 +799,7 @@ static u64 nvgpu_buddy_balloc(struct nvgpu_allocator *__a, u64 len) if (order > a->max_order) { alloc_unlock(__a); - alloc_dbg(balloc_owner(a), "Alloc fail\n"); + alloc_dbg(balloc_owner(a), "Alloc fail"); return 0; } @@ -814,13 +814,13 @@ static u64 nvgpu_buddy_balloc(struct nvgpu_allocator *__a, u64 len) a->bytes_alloced += len; a->bytes_alloced_real += balloc_order_to_len(a, order); alloc_dbg(balloc_owner(a), - "Alloc 0x%-10llx %3lld:0x%-10llx pte_size=%s\n", + "Alloc 0x%-10llx %3lld:0x%-10llx pte_size=%s", addr, order, len, pte_size == gmmu_page_size_big ? "big" : pte_size == gmmu_page_size_small ? "small" : "NA/any"); } else { - alloc_dbg(balloc_owner(a), "Alloc failed: no mem!\n"); + alloc_dbg(balloc_owner(a), "Alloc failed: no mem!"); } a->alloc_made = 1; @@ -869,7 +869,7 @@ static u64 __nvgpu_balloc_fixed_buddy(struct nvgpu_allocator *__a, if (!balloc_is_range_free(a, base, base + len)) { alloc_dbg(balloc_owner(a), - "Range not free: 0x%llx -> 0x%llx\n", + "Range not free: 0x%llx -> 0x%llx", base, base + len); goto fail_unlock; } @@ -877,7 +877,7 @@ static u64 __nvgpu_balloc_fixed_buddy(struct nvgpu_allocator *__a, ret = __balloc_do_alloc_fixed(a, falloc, base, len, pte_size); if (!ret) { alloc_dbg(balloc_owner(a), - "Alloc-fixed failed ?? 0x%llx -> 0x%llx\n", + "Alloc-fixed failed ?? 0x%llx -> 0x%llx", base, base + len); goto fail_unlock; } @@ -891,7 +891,7 @@ static u64 __nvgpu_balloc_fixed_buddy(struct nvgpu_allocator *__a, a->bytes_alloced += len; a->bytes_alloced_real += real_bytes; - alloc_dbg(balloc_owner(a), "Alloc (fixed) 0x%llx\n", base); + alloc_dbg(balloc_owner(a), "Alloc (fixed) 0x%llx", base); return base; @@ -962,7 +962,7 @@ static void nvgpu_buddy_bfree(struct nvgpu_allocator *__a, u64 addr) done: alloc_unlock(__a); - alloc_dbg(balloc_owner(a), "Free 0x%llx\n", addr); + alloc_dbg(balloc_owner(a), "Free 0x%llx", addr); return; } @@ -1018,7 +1018,7 @@ static int nvgpu_buddy_reserve_co(struct nvgpu_allocator *__a, if (!addr) { err = -ENOMEM; nvgpu_warn(__a->g, - "%s: Failed to reserve a valid carveout!\n", + "%s: Failed to reserve a valid carveout!", __func__); goto done; } @@ -1102,32 +1102,32 @@ static void nvgpu_buddy_print_stats(struct nvgpu_allocator *__a, struct nvgpu_alloc_carveout *tmp; struct nvgpu_buddy_allocator *a = __a->priv; - __alloc_pstat(s, __a, "base = %llu, limit = %llu, blk_size = %llu\n", + __alloc_pstat(s, __a, "base = %llu, limit = %llu, blk_size = %llu", a->base, a->length, a->blk_size); - __alloc_pstat(s, __a, "Internal params:\n"); - __alloc_pstat(s, __a, " start = 0x%llx\n", a->start); - __alloc_pstat(s, __a, " end = 0x%llx\n", a->end); - __alloc_pstat(s, __a, " count = 0x%llx\n", a->count); - __alloc_pstat(s, __a, " blks = 0x%llx\n", a->blks); - __alloc_pstat(s, __a, " max_order = %llu\n", a->max_order); + __alloc_pstat(s, __a, "Internal params:"); + __alloc_pstat(s, __a, " start = 0x%llx", a->start); + __alloc_pstat(s, __a, " end = 0x%llx", a->end); + __alloc_pstat(s, __a, " count = 0x%llx", a->count); + __alloc_pstat(s, __a, " blks = 0x%llx", a->blks); + __alloc_pstat(s, __a, " max_order = %llu", a->max_order); if (lock) alloc_lock(__a); if (!nvgpu_list_empty(&a->co_list)) { - __alloc_pstat(s, __a, "\n"); - __alloc_pstat(s, __a, "Carveouts:\n"); + __alloc_pstat(s, __a, ""); + __alloc_pstat(s, __a, "Carveouts:"); nvgpu_list_for_each_entry(tmp, &a->co_list, nvgpu_alloc_carveout, co_entry) __alloc_pstat(s, __a, - " CO %2d: %-20s 0x%010llx + 0x%llx\n", + " CO %2d: %-20s 0x%010llx + 0x%llx", i++, tmp->name, tmp->base, tmp->length); } - __alloc_pstat(s, __a, "\n"); - __alloc_pstat(s, __a, "Buddy blocks:\n"); - __alloc_pstat(s, __a, " Order Free Alloced Split\n"); - __alloc_pstat(s, __a, " ----- ---- ------- -----\n"); + __alloc_pstat(s, __a, ""); + __alloc_pstat(s, __a, "Buddy blocks:"); + __alloc_pstat(s, __a, " Order Free Alloced Split"); + __alloc_pstat(s, __a, " ----- ---- ------- -----"); for (i = a->max_order; i >= 0; i--) { if (a->buddy_list_len[i] == 0 && @@ -1135,31 +1135,31 @@ static void nvgpu_buddy_print_stats(struct nvgpu_allocator *__a, a->buddy_list_split[i] == 0) continue; - __alloc_pstat(s, __a, " %3d %-7llu %-9llu %llu\n", i, + __alloc_pstat(s, __a, " %3d %-7llu %-9llu %llu", i, a->buddy_list_len[i], a->buddy_list_alloced[i], a->buddy_list_split[i]); } - __alloc_pstat(s, __a, "\n"); + __alloc_pstat(s, __a, ""); nvgpu_rbtree_enum_start(0, &node, a->fixed_allocs); i = 1; while (node) { falloc = nvgpu_fixed_alloc_from_rbtree_node(node); - __alloc_pstat(s, __a, "Fixed alloc (%d): [0x%llx -> 0x%llx]\n", + __alloc_pstat(s, __a, "Fixed alloc (%d): [0x%llx -> 0x%llx]", i, falloc->start, falloc->end); nvgpu_rbtree_enum_next(&node, a->fixed_allocs); } - __alloc_pstat(s, __a, "\n"); - __alloc_pstat(s, __a, "Bytes allocated: %llu\n", + __alloc_pstat(s, __a, ""); + __alloc_pstat(s, __a, "Bytes allocated: %llu", a->bytes_alloced); - __alloc_pstat(s, __a, "Bytes allocated (real): %llu\n", + __alloc_pstat(s, __a, "Bytes allocated (real): %llu", a->bytes_alloced_real); - __alloc_pstat(s, __a, "Bytes freed: %llu\n", + __alloc_pstat(s, __a, "Bytes freed: %llu", a->bytes_freed); if (lock) @@ -1294,16 +1294,16 @@ int __nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, #ifdef CONFIG_DEBUG_FS nvgpu_init_alloc_debug(g, __a); #endif - alloc_dbg(__a, "New allocator: type buddy\n"); - alloc_dbg(__a, " base 0x%llx\n", a->base); - alloc_dbg(__a, " size 0x%llx\n", a->length); - alloc_dbg(__a, " blk_size 0x%llx\n", a->blk_size); + alloc_dbg(__a, "New allocator: type buddy"); + alloc_dbg(__a, " base 0x%llx", a->base); + alloc_dbg(__a, " size 0x%llx", a->length); + alloc_dbg(__a, " blk_size 0x%llx", a->blk_size); if (flags & GPU_ALLOC_GVA_SPACE) alloc_dbg(balloc_owner(a), - " pde_size 0x%llx\n", + " pde_size 0x%llx", balloc_order_to_len(a, a->pte_blk_order)); - alloc_dbg(__a, " max_order %llu\n", a->max_order); - alloc_dbg(__a, " flags 0x%llx\n", a->flags); + alloc_dbg(__a, " max_order %llu", a->max_order); + alloc_dbg(__a, " flags 0x%llx", a->flags); return 0; diff --git a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c index 3eb10fc4..5f48d606 100644 --- a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c @@ -73,7 +73,7 @@ static u64 nvgpu_lockless_alloc(struct nvgpu_allocator *a, u64 len) if (ret == head) { addr = pa->base + head * pa->blk_size; nvgpu_atomic_inc(&pa->nr_allocs); - alloc_dbg(a, "Alloc node # %d @ addr 0x%llx\n", head, + alloc_dbg(a, "Alloc node # %d @ addr 0x%llx", head, addr); break; } @@ -81,9 +81,9 @@ static u64 nvgpu_lockless_alloc(struct nvgpu_allocator *a, u64 len) } if (addr) - alloc_dbg(a, "Alloc node # %d @ addr 0x%llx\n", head, addr); + alloc_dbg(a, "Alloc node # %d @ addr 0x%llx", head, addr); else - alloc_dbg(a, "Alloc failed!\n"); + alloc_dbg(a, "Alloc failed!"); return addr; } @@ -96,7 +96,7 @@ static void nvgpu_lockless_free(struct nvgpu_allocator *a, u64 addr) cur_idx = (addr - pa->base) / pa->blk_size; - alloc_dbg(a, "Free node # %llu @ addr 0x%llx\n", cur_idx, addr); + alloc_dbg(a, "Free node # %llu @ addr 0x%llx", cur_idx, addr); while (1) { head = NV_ACCESS_ONCE(pa->head); @@ -104,7 +104,7 @@ static void nvgpu_lockless_free(struct nvgpu_allocator *a, u64 addr) ret = cmpxchg(&pa->head, head, cur_idx); if (ret == head) { nvgpu_atomic_dec(&pa->nr_allocs); - alloc_dbg(a, "Free node # %llu\n", cur_idx); + alloc_dbg(a, "Free node # %llu", cur_idx); break; } } @@ -128,15 +128,15 @@ static void nvgpu_lockless_print_stats(struct nvgpu_allocator *a, { struct nvgpu_lockless_allocator *pa = a->priv; - __alloc_pstat(s, a, "Lockless allocator params:\n"); - __alloc_pstat(s, a, " start = 0x%llx\n", pa->base); - __alloc_pstat(s, a, " end = 0x%llx\n", pa->base + pa->length); + __alloc_pstat(s, a, "Lockless allocator params:"); + __alloc_pstat(s, a, " start = 0x%llx", pa->base); + __alloc_pstat(s, a, " end = 0x%llx", pa->base + pa->length); /* Actual stats. */ - __alloc_pstat(s, a, "Stats:\n"); - __alloc_pstat(s, a, " Number allocs = %d\n", + __alloc_pstat(s, a, "Stats:"); + __alloc_pstat(s, a, " Number allocs = %d", nvgpu_atomic_read(&pa->nr_allocs)); - __alloc_pstat(s, a, " Number free = %d\n", + __alloc_pstat(s, a, " Number free = %d", pa->nr_nodes - nvgpu_atomic_read(&pa->nr_allocs)); } #endif @@ -211,11 +211,11 @@ int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, #ifdef CONFIG_DEBUG_FS nvgpu_init_alloc_debug(g, __a); #endif - alloc_dbg(__a, "New allocator: type lockless\n"); - alloc_dbg(__a, " base 0x%llx\n", a->base); - alloc_dbg(__a, " nodes %d\n", a->nr_nodes); - alloc_dbg(__a, " blk_size 0x%llx\n", a->blk_size); - alloc_dbg(__a, " flags 0x%llx\n", a->flags); + alloc_dbg(__a, "New allocator: type lockless"); + alloc_dbg(__a, " base 0x%llx", a->base); + alloc_dbg(__a, " nodes %d", a->nr_nodes); + alloc_dbg(__a, " blk_size 0x%llx", a->blk_size); + alloc_dbg(__a, " flags 0x%llx", a->flags); return 0; diff --git a/drivers/gpu/nvgpu/common/mm/page_allocator.c b/drivers/gpu/nvgpu/common/mm/page_allocator.c index e7738919..6dc1edf7 100644 --- a/drivers/gpu/nvgpu/common/mm/page_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/page_allocator.c @@ -279,7 +279,7 @@ static struct page_alloc_slab_page *alloc_slab_page( slab_page = nvgpu_kmem_cache_alloc(a->slab_page_cache); if (!slab_page) { - palloc_dbg(a, "OOM: unable to alloc slab_page struct!\n"); + palloc_dbg(a, "OOM: unable to alloc slab_page struct!"); return NULL; } @@ -288,7 +288,7 @@ static struct page_alloc_slab_page *alloc_slab_page( slab_page->page_addr = nvgpu_alloc(&a->source_allocator, a->page_size); if (!slab_page->page_addr) { nvgpu_kmem_cache_free(a->slab_page_cache, slab_page); - palloc_dbg(a, "OOM: vidmem is full!\n"); + palloc_dbg(a, "OOM: vidmem is full!"); return NULL; } @@ -301,7 +301,7 @@ static struct page_alloc_slab_page *alloc_slab_page( a->pages_alloced++; - palloc_dbg(a, "Allocated new slab page @ 0x%012llx size=%u\n", + palloc_dbg(a, "Allocated new slab page @ 0x%012llx size=%u", slab_page->page_addr, slab_page->slab_size); return slab_page; @@ -310,7 +310,7 @@ static struct page_alloc_slab_page *alloc_slab_page( static void free_slab_page(struct nvgpu_page_allocator *a, struct page_alloc_slab_page *slab_page) { - palloc_dbg(a, "Freeing slab page @ 0x%012llx\n", slab_page->page_addr); + palloc_dbg(a, "Freeing slab page @ 0x%012llx", slab_page->page_addr); BUG_ON((slab_page->state != SP_NONE && slab_page->state != SP_EMPTY) || slab_page->nr_objects_alloced != 0 || @@ -418,7 +418,7 @@ static struct nvgpu_page_alloc *__nvgpu_alloc_slab( alloc = nvgpu_kmem_cache_alloc(a->alloc_cache); if (!alloc) { - palloc_dbg(a, "OOM: could not alloc page_alloc struct!\n"); + palloc_dbg(a, "OOM: could not alloc page_alloc struct!"); goto fail; } @@ -426,7 +426,7 @@ static struct nvgpu_page_alloc *__nvgpu_alloc_slab( sgl = nvgpu_kzalloc(a->owner->g, sizeof(*sgl)); if (!sgl) { - palloc_dbg(a, "OOM: could not alloc sgl struct!\n"); + palloc_dbg(a, "OOM: could not alloc sgl struct!"); goto fail; } @@ -435,7 +435,7 @@ static struct nvgpu_page_alloc *__nvgpu_alloc_slab( if (err) goto fail; - palloc_dbg(a, "Alloc 0x%04llx sr=%d id=0x%010llx [slab]\n", + palloc_dbg(a, "Alloc 0x%04llx sr=%d id=0x%010llx [slab]", len, slab_nr, alloc->base); a->nr_slab_allocs++; @@ -549,7 +549,7 @@ static struct nvgpu_page_alloc *__do_nvgpu_alloc_pages( /* Divide by 2 and try again */ if (!chunk_addr) { - palloc_dbg(a, "balloc failed: 0x%llx\n", + palloc_dbg(a, "balloc failed: 0x%llx", chunk_len); chunk_len >>= 1; max_chunk_len = chunk_len; @@ -559,7 +559,7 @@ static struct nvgpu_page_alloc *__do_nvgpu_alloc_pages( chunk_pages = chunk_len >> a->page_shift; if (!chunk_addr) { - palloc_dbg(a, "bailing @ 0x%llx\n", chunk_len); + palloc_dbg(a, "bailing @ 0x%llx", chunk_len); goto fail_cleanup; } @@ -622,22 +622,22 @@ static struct nvgpu_page_alloc *__nvgpu_alloc_pages( alloc = __do_nvgpu_alloc_pages(a, pages); if (!alloc) { - palloc_dbg(a, "Alloc 0x%llx (%llu) (failed)\n", + palloc_dbg(a, "Alloc 0x%llx (%llu) (failed)", pages << a->page_shift, pages); return NULL; } - palloc_dbg(a, "Alloc 0x%llx (%llu) id=0x%010llx\n", + palloc_dbg(a, "Alloc 0x%llx (%llu) id=0x%010llx", pages << a->page_shift, pages, alloc->base); sgl = alloc->sgt.sgl; while (sgl) { - palloc_dbg(a, " Chunk %2d: 0x%010llx + 0x%llx\n", + palloc_dbg(a, " Chunk %2d: 0x%010llx + 0x%llx", i++, nvgpu_sgt_get_phys(&alloc->sgt, sgl), nvgpu_sgt_get_length(&alloc->sgt, sgl)); sgl = nvgpu_sgt_get_next(&alloc->sgt, sgl); } - palloc_dbg(a, "Alloc done\n"); + palloc_dbg(a, "Alloc done"); return alloc; } @@ -708,13 +708,13 @@ static void nvgpu_page_free(struct nvgpu_allocator *__a, u64 base) ((struct nvgpu_page_alloc *)(uintptr_t)base)->base); if (!alloc) { - palloc_dbg(a, "Hrm, found no alloc?\n"); + palloc_dbg(a, "Hrm, found no alloc?"); goto done; } a->nr_frees++; - palloc_dbg(a, "Free 0x%llx id=0x%010llx\n", + palloc_dbg(a, "Free 0x%llx id=0x%010llx", alloc->length, alloc->base); /* @@ -794,11 +794,11 @@ static u64 nvgpu_page_alloc_fixed(struct nvgpu_allocator *__a, __insert_page_alloc(a, alloc); alloc_unlock(__a); - palloc_dbg(a, "Alloc [fixed] @ 0x%010llx + 0x%llx (%llu)\n", + palloc_dbg(a, "Alloc [fixed] @ 0x%010llx + 0x%llx (%llu)", alloc->base, aligned_len, pages); sgl = alloc->sgt.sgl; while (sgl) { - palloc_dbg(a, " Chunk %2d: 0x%010llx + 0x%llx\n", + palloc_dbg(a, " Chunk %2d: 0x%010llx + 0x%llx", i++, nvgpu_sgt_get_phys(&alloc->sgt, sgl), nvgpu_sgt_get_length(&alloc->sgt, sgl)); @@ -830,7 +830,7 @@ static void nvgpu_page_free_fixed(struct nvgpu_allocator *__a, alloc = (struct nvgpu_page_alloc *) (uintptr_t) base; } - palloc_dbg(a, "Free [fixed] 0x%010llx + 0x%llx\n", + palloc_dbg(a, "Free [fixed] 0x%010llx + 0x%llx", alloc->base, alloc->length); a->nr_fixed_frees++; @@ -868,47 +868,47 @@ static void nvgpu_page_print_stats(struct nvgpu_allocator *__a, if (lock) alloc_lock(__a); - __alloc_pstat(s, __a, "Page allocator:\n"); - __alloc_pstat(s, __a, " allocs %lld\n", a->nr_allocs); - __alloc_pstat(s, __a, " frees %lld\n", a->nr_frees); - __alloc_pstat(s, __a, " fixed_allocs %lld\n", a->nr_fixed_allocs); - __alloc_pstat(s, __a, " fixed_frees %lld\n", a->nr_fixed_frees); - __alloc_pstat(s, __a, " slab_allocs %lld\n", a->nr_slab_allocs); - __alloc_pstat(s, __a, " slab_frees %lld\n", a->nr_slab_frees); - __alloc_pstat(s, __a, " pages alloced %lld\n", a->pages_alloced); - __alloc_pstat(s, __a, " pages freed %lld\n", a->pages_freed); - __alloc_pstat(s, __a, "\n"); - - __alloc_pstat(s, __a, "Page size: %lld KB\n", + __alloc_pstat(s, __a, "Page allocator:"); + __alloc_pstat(s, __a, " allocs %lld", a->nr_allocs); + __alloc_pstat(s, __a, " frees %lld", a->nr_frees); + __alloc_pstat(s, __a, " fixed_allocs %lld", a->nr_fixed_allocs); + __alloc_pstat(s, __a, " fixed_frees %lld", a->nr_fixed_frees); + __alloc_pstat(s, __a, " slab_allocs %lld", a->nr_slab_allocs); + __alloc_pstat(s, __a, " slab_frees %lld", a->nr_slab_frees); + __alloc_pstat(s, __a, " pages alloced %lld", a->pages_alloced); + __alloc_pstat(s, __a, " pages freed %lld", a->pages_freed); + __alloc_pstat(s, __a, ""); + + __alloc_pstat(s, __a, "Page size: %lld KB", a->page_size >> 10); - __alloc_pstat(s, __a, "Total pages: %lld (%lld MB)\n", + __alloc_pstat(s, __a, "Total pages: %lld (%lld MB)", a->length / a->page_size, a->length >> 20); - __alloc_pstat(s, __a, "Available pages: %lld (%lld MB)\n", + __alloc_pstat(s, __a, "Available pages: %lld (%lld MB)", nvgpu_alloc_space(&a->source_allocator) / a->page_size, nvgpu_alloc_space(&a->source_allocator) >> 20); - __alloc_pstat(s, __a, "\n"); + __alloc_pstat(s, __a, ""); /* * Slab info. */ if (a->flags & GPU_ALLOC_4K_VIDMEM_PAGES) { - __alloc_pstat(s, __a, "Slabs:\n"); - __alloc_pstat(s, __a, " size empty partial full\n"); - __alloc_pstat(s, __a, " ---- ----- ------- ----\n"); + __alloc_pstat(s, __a, "Slabs:"); + __alloc_pstat(s, __a, " size empty partial full"); + __alloc_pstat(s, __a, " ---- ----- ------- ----"); for (i = 0; i < a->nr_slabs; i++) { struct page_alloc_slab *slab = &a->slabs[i]; - __alloc_pstat(s, __a, " %-9u %-9d %-9u %u\n", + __alloc_pstat(s, __a, " %-9u %-9d %-9u %u", slab->slab_size, slab->nr_empty, slab->nr_partial, slab->nr_full); } - __alloc_pstat(s, __a, "\n"); + __alloc_pstat(s, __a, ""); } - __alloc_pstat(s, __a, "Source alloc: %s\n", + __alloc_pstat(s, __a, "Source alloc: %s", a->source_allocator.name); nvgpu_alloc_print_stats(&a->source_allocator, s, lock); @@ -1029,12 +1029,12 @@ int nvgpu_page_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, #ifdef CONFIG_DEBUG_FS nvgpu_init_alloc_debug(g, __a); #endif - palloc_dbg(a, "New allocator: type page\n"); - palloc_dbg(a, " base 0x%llx\n", a->base); - palloc_dbg(a, " size 0x%llx\n", a->length); - palloc_dbg(a, " page_size 0x%llx\n", a->page_size); - palloc_dbg(a, " flags 0x%llx\n", a->flags); - palloc_dbg(a, " slabs: %d\n", a->nr_slabs); + palloc_dbg(a, "New allocator: type page"); + palloc_dbg(a, " base 0x%llx", a->base); + palloc_dbg(a, " size 0x%llx", a->length); + palloc_dbg(a, " page_size 0x%llx", a->page_size); + palloc_dbg(a, " flags 0x%llx", a->flags); + palloc_dbg(a, " slabs: %d", a->nr_slabs); return 0; diff --git a/drivers/gpu/nvgpu/include/nvgpu/allocator.h b/drivers/gpu/nvgpu/include/nvgpu/allocator.h index 1e7ab38f..2ff7e950 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/allocator.h +++ b/drivers/gpu/nvgpu/include/nvgpu/allocator.h @@ -37,7 +37,7 @@ #include #include -/* #define ALLOCATOR_DEBUG */ +/* #define ALLOCATOR_DEBUG_FINE */ struct nvgpu_allocator; struct nvgpu_alloc_carveout; @@ -300,7 +300,7 @@ static inline void nvgpu_alloc_disable_dbg(struct nvgpu_allocator *a) #define __alloc_pstat(seq, allocator, fmt, arg...) \ do { \ if (seq) \ - seq_printf(seq, fmt, ##arg); \ + seq_printf(seq, fmt "\n", ##arg); \ else \ alloc_dbg(allocator, fmt, ##arg); \ } while (0) @@ -311,14 +311,14 @@ static inline void nvgpu_alloc_disable_dbg(struct nvgpu_allocator *a) /* * This gives finer control over debugging messages. By defining the - * ALLOCATOR_DEBUG macro prints for an allocator will only get made if + * ALLOCATOR_DEBUG_FINE macro prints for an allocator will only get made if * that allocator's debug flag is set. * * Otherwise debugging is as normal: debug statements for all allocators - * if the GPU debugging mask bit is set. Note: even when ALLOCATOR_DEBUG + * if the GPU debugging mask bit is set. Note: even when ALLOCATOR_DEBUG_FINE * is set gpu_dbg_alloc must still also be set to true. */ -#if defined(ALLOCATOR_DEBUG) +#if defined(ALLOCATOR_DEBUG_FINE) #define alloc_dbg(a, fmt, arg...) \ do { \ if ((a)->debug) \ -- cgit v1.2.2