summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-08-21 16:29:46 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-08-28 11:54:36 -0400
commit8f2f979428e1e5a4ff71d91e30ba17813e6ee7be (patch)
treedd7ce212363bea8b3547811109f01b2397804613
parentc49160127acfa5a9f550ecfa2d61c054060dbab3 (diff)
gpu: nvgpu: cleanup allocator debugging
Remove debugging features that did not really get used and make the debugging code use the nvgpu_log() functionality. This ties the allocator debugging into the larger nvgpu debug framework. Also modify many of the places CONFIG_DEBUG_FS was used to conditionally compile allocator debug code to use __KERNEL__ instead. This is because that debug code can still be called even when debugfs is not present in Linux. Change-Id: I112ebe1cae22d6f8db96d023993498093e18d74a Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1544439 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_allocator.c6
-rw-r--r--drivers/gpu/nvgpu/common/mm/bitmap_allocator.c4
-rw-r--r--drivers/gpu/nvgpu/common/mm/buddy_allocator.c4
-rw-r--r--drivers/gpu/nvgpu/common/mm/lockless_allocator.c4
-rw-r--r--drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c8
-rw-r--r--drivers/gpu/nvgpu/common/mm/page_allocator.c4
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/allocator.h49
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/log.h1
8 files changed, 46 insertions, 34 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/debug_allocator.c b/drivers/gpu/nvgpu/common/linux/debug_allocator.c
index 766c8486..91ae0512 100644
--- a/drivers/gpu/nvgpu/common/linux/debug_allocator.c
+++ b/drivers/gpu/nvgpu/common/linux/debug_allocator.c
@@ -20,12 +20,6 @@
20 20
21#include <nvgpu/allocator.h> 21#include <nvgpu/allocator.h>
22 22
23void nvgpu_alloc_print_stats(struct nvgpu_allocator *__a,
24 struct seq_file *s, int lock)
25{
26 __a->ops->print_stats(__a, s, lock);
27}
28
29static int __alloc_show(struct seq_file *s, void *unused) 23static int __alloc_show(struct seq_file *s, void *unused)
30{ 24{
31 struct nvgpu_allocator *a = s->private; 25 struct nvgpu_allocator *a = s->private;
diff --git a/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c b/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c
index 274e9c93..9b3fccf1 100644
--- a/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c
+++ b/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c
@@ -311,7 +311,7 @@ static void nvgpu_bitmap_alloc_destroy(struct nvgpu_allocator *__a)
311 nvgpu_kfree(nvgpu_alloc_to_gpu(__a), a); 311 nvgpu_kfree(nvgpu_alloc_to_gpu(__a), a);
312} 312}
313 313
314#ifdef CONFIG_DEBUG_FS 314#ifdef __KERNEL__
315static void nvgpu_bitmap_print_stats(struct nvgpu_allocator *__a, 315static void nvgpu_bitmap_print_stats(struct nvgpu_allocator *__a,
316 struct seq_file *s, int lock) 316 struct seq_file *s, int lock)
317{ 317{
@@ -347,7 +347,7 @@ static const struct nvgpu_allocator_ops bitmap_ops = {
347 347
348 .fini = nvgpu_bitmap_alloc_destroy, 348 .fini = nvgpu_bitmap_alloc_destroy,
349 349
350#ifdef CONFIG_DEBUG_FS 350#ifdef __KERNEL__
351 .print_stats = nvgpu_bitmap_print_stats, 351 .print_stats = nvgpu_bitmap_print_stats,
352#endif 352#endif
353}; 353};
diff --git a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c
index a2e6c44a..2938bfac 100644
--- a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c
+++ b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c
@@ -1076,7 +1076,7 @@ static u64 nvgpu_buddy_alloc_space(struct nvgpu_allocator *a)
1076 return space; 1076 return space;
1077} 1077}
1078 1078
1079#ifdef CONFIG_DEBUG_FS 1079#ifdef __KERNEL__
1080/* 1080/*
1081 * Print the buddy allocator top level stats. If you pass @s as NULL then the 1081 * Print the buddy allocator top level stats. If you pass @s as NULL then the
1082 * stats are printed to the kernel log. This lets this code be used for 1082 * stats are printed to the kernel log. This lets this code be used for
@@ -1174,7 +1174,7 @@ static const struct nvgpu_allocator_ops buddy_ops = {
1174 1174
1175 .fini = nvgpu_buddy_allocator_destroy, 1175 .fini = nvgpu_buddy_allocator_destroy,
1176 1176
1177#ifdef CONFIG_DEBUG_FS 1177#ifdef __KERNEL__
1178 .print_stats = nvgpu_buddy_print_stats, 1178 .print_stats = nvgpu_buddy_print_stats,
1179#endif 1179#endif
1180}; 1180};
diff --git a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c
index 8f712a14..04df7e3f 100644
--- a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c
+++ b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c
@@ -116,7 +116,7 @@ static void nvgpu_lockless_alloc_destroy(struct nvgpu_allocator *a)
116 nvgpu_kfree(nvgpu_alloc_to_gpu(a), pa); 116 nvgpu_kfree(nvgpu_alloc_to_gpu(a), pa);
117} 117}
118 118
119#ifdef CONFIG_DEBUG_FS 119#ifdef __KERNEL__
120static void nvgpu_lockless_print_stats(struct nvgpu_allocator *a, 120static void nvgpu_lockless_print_stats(struct nvgpu_allocator *a,
121 struct seq_file *s, int lock) 121 struct seq_file *s, int lock)
122{ 122{
@@ -146,7 +146,7 @@ static const struct nvgpu_allocator_ops pool_ops = {
146 146
147 .fini = nvgpu_lockless_alloc_destroy, 147 .fini = nvgpu_lockless_alloc_destroy,
148 148
149#ifdef CONFIG_DEBUG_FS 149#ifdef __KERNEL__
150 .print_stats = nvgpu_lockless_print_stats, 150 .print_stats = nvgpu_lockless_print_stats,
151#endif 151#endif
152}; 152};
diff --git a/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c b/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c
index 1646d2b1..bc8d1b55 100644
--- a/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c
+++ b/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c
@@ -114,6 +114,14 @@ void nvgpu_alloc_destroy(struct nvgpu_allocator *a)
114 memset(a, 0, sizeof(*a)); 114 memset(a, 0, sizeof(*a));
115} 115}
116 116
117#ifdef __KERNEL__
118void nvgpu_alloc_print_stats(struct nvgpu_allocator *__a,
119 struct seq_file *s, int lock)
120{
121 __a->ops->print_stats(__a, s, lock);
122}
123#endif
124
117/* 125/*
118 * Handle the common init stuff for a nvgpu_allocator. 126 * Handle the common init stuff for a nvgpu_allocator.
119 */ 127 */
diff --git a/drivers/gpu/nvgpu/common/mm/page_allocator.c b/drivers/gpu/nvgpu/common/mm/page_allocator.c
index 0eda13ec..72ff8f2d 100644
--- a/drivers/gpu/nvgpu/common/mm/page_allocator.c
+++ b/drivers/gpu/nvgpu/common/mm/page_allocator.c
@@ -756,7 +756,7 @@ static void nvgpu_page_allocator_destroy(struct nvgpu_allocator *__a)
756 alloc_unlock(__a); 756 alloc_unlock(__a);
757} 757}
758 758
759#ifdef CONFIG_DEBUG_FS 759#ifdef __KERNEL__
760static void nvgpu_page_print_stats(struct nvgpu_allocator *__a, 760static void nvgpu_page_print_stats(struct nvgpu_allocator *__a,
761 struct seq_file *s, int lock) 761 struct seq_file *s, int lock)
762{ 762{
@@ -833,7 +833,7 @@ static const struct nvgpu_allocator_ops page_ops = {
833 833
834 .fini = nvgpu_page_allocator_destroy, 834 .fini = nvgpu_page_allocator_destroy,
835 835
836#ifdef CONFIG_DEBUG_FS 836#ifdef __KERNEL__
837 .print_stats = nvgpu_page_print_stats, 837 .print_stats = nvgpu_page_print_stats,
838#endif 838#endif
839}; 839};
diff --git a/drivers/gpu/nvgpu/include/nvgpu/allocator.h b/drivers/gpu/nvgpu/include/nvgpu/allocator.h
index 30bfa750..ac8a0645 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/allocator.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/allocator.h
@@ -17,8 +17,16 @@
17#ifndef __NVGPU_ALLOCATOR_H__ 17#ifndef __NVGPU_ALLOCATOR_H__
18#define __NVGPU_ALLOCATOR_H__ 18#define __NVGPU_ALLOCATOR_H__
19 19
20#ifdef __KERNEL__
21/*
22 * The Linux kernel has this notion of seq_files for printing info to userspace.
23 * One of the allocator function pointers takes advantage of this and allows the
24 * debug output to be directed either to nvgpu_log() or a seq_file.
25 */
20#include <linux/seq_file.h> 26#include <linux/seq_file.h>
27#endif
21 28
29#include <nvgpu/log.h>
22#include <nvgpu/lock.h> 30#include <nvgpu/lock.h>
23#include <nvgpu/list.h> 31#include <nvgpu/list.h>
24 32
@@ -72,7 +80,7 @@ struct nvgpu_allocator_ops {
72 /* Destructor. */ 80 /* Destructor. */
73 void (*fini)(struct nvgpu_allocator *allocator); 81 void (*fini)(struct nvgpu_allocator *allocator);
74 82
75#ifdef CONFIG_DEBUG_FS 83#ifdef __KERNEL__
76 /* Debugging. */ 84 /* Debugging. */
77 void (*print_stats)(struct nvgpu_allocator *allocator, 85 void (*print_stats)(struct nvgpu_allocator *allocator,
78 struct seq_file *s, int lock); 86 struct seq_file *s, int lock);
@@ -246,7 +254,7 @@ u64 nvgpu_alloc_space(struct nvgpu_allocator *a);
246 254
247void nvgpu_alloc_destroy(struct nvgpu_allocator *allocator); 255void nvgpu_alloc_destroy(struct nvgpu_allocator *allocator);
248 256
249#ifdef CONFIG_DEBUG_FS 257#ifdef __KERNEL__
250void nvgpu_alloc_print_stats(struct nvgpu_allocator *a, 258void nvgpu_alloc_print_stats(struct nvgpu_allocator *a,
251 struct seq_file *s, int lock); 259 struct seq_file *s, int lock);
252#endif 260#endif
@@ -281,35 +289,36 @@ static inline void nvgpu_alloc_disable_dbg(struct nvgpu_allocator *a)
281/* 289/*
282 * Debug stuff. 290 * Debug stuff.
283 */ 291 */
292#ifdef __KERNEL__
284#define __alloc_pstat(seq, allocator, fmt, arg...) \ 293#define __alloc_pstat(seq, allocator, fmt, arg...) \
285 do { \ 294 do { \
286 if (s) \ 295 if (seq) \
287 seq_printf(seq, fmt, ##arg); \ 296 seq_printf(seq, fmt, ##arg); \
288 else \ 297 else \
289 alloc_dbg(allocator, fmt, ##arg); \ 298 alloc_dbg(allocator, fmt, ##arg); \
290 } while (0) 299 } while (0)
300#endif
291 301
292#define __alloc_dbg(a, fmt, arg...) \ 302#define __alloc_dbg(a, fmt, arg...) \
293 pr_info("%-25s %25s() " fmt, (a)->name, __func__, ##arg) 303 nvgpu_log((a)->g, gpu_dbg_alloc, "%25s " fmt, (a)->name, ##arg)
294 304
295#if defined(ALLOCATOR_DEBUG)
296/* 305/*
297 * Always print the debug messages... 306 * This gives finer control over debugging messages. By defining the
298 */ 307 * ALLOCATOR_DEBUG macro prints for an allocator will only get made if
299#define alloc_dbg(a, fmt, arg...) __alloc_dbg(a, fmt, ##arg) 308 * that allocator's debug flag is set.
300#else 309 *
301/* 310 * Otherwise debugging is as normal: debug statements for all allocators
302 * Only print debug messages if debug is enabled for a given allocator. 311 * if the GPU debugging mask bit is set. Note: even when ALLOCATOR_DEBUG
312 * is set gpu_dbg_alloc must still also be set to true.
303 */ 313 */
304#define alloc_dbg(a, fmt, arg...) \ 314#if defined(ALLOCATOR_DEBUG)
305 do { \ 315#define alloc_dbg(a, fmt, arg...) \
306 if ((a)->debug) \ 316 do { \
307 __alloc_dbg((a), fmt, ##arg); \ 317 if ((a)->debug) \
318 __alloc_dbg((a), fmt, ##arg); \
308 } while (0) 319 } while (0)
309 320#else
321#define alloc_dbg(a, fmt, arg...) __alloc_dbg(a, fmt, ##arg)
310#endif 322#endif
311#define balloc_pr(alloctor, format, arg...) \
312 pr_info("%-25s %25s() " format, \
313 alloctor->name, __func__, ##arg)
314 323
315#endif /* NVGPU_ALLOCATOR_H */ 324#endif /* NVGPU_ALLOCATOR_H */
diff --git a/drivers/gpu/nvgpu/include/nvgpu/log.h b/drivers/gpu/nvgpu/include/nvgpu/log.h
index a1110a59..11e6dacb 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/log.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/log.h
@@ -69,6 +69,7 @@ enum nvgpu_log_categories {
69 gpu_dbg_shutdown = BIT(18), /* GPU shutdown tracing. */ 69 gpu_dbg_shutdown = BIT(18), /* GPU shutdown tracing. */
70 gpu_dbg_kmem = BIT(19), /* Kmem tracking debugging. */ 70 gpu_dbg_kmem = BIT(19), /* Kmem tracking debugging. */
71 gpu_dbg_pd_cache = BIT(20), /* PD cache traces. */ 71 gpu_dbg_pd_cache = BIT(20), /* PD cache traces. */
72 gpu_dbg_alloc = BIT(21), /* Allocator debugging. */
72 gpu_dbg_mem = BIT(31), /* memory accesses; very verbose. */ 73 gpu_dbg_mem = BIT(31), /* memory accesses; very verbose. */
73}; 74};
74 75