mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
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>
This commit is contained in:
committed by
mobile promotions
parent
c49160127a
commit
8f2f979428
@@ -20,12 +20,6 @@
|
||||
|
||||
#include <nvgpu/allocator.h>
|
||||
|
||||
void nvgpu_alloc_print_stats(struct nvgpu_allocator *__a,
|
||||
struct seq_file *s, int lock)
|
||||
{
|
||||
__a->ops->print_stats(__a, s, lock);
|
||||
}
|
||||
|
||||
static int __alloc_show(struct seq_file *s, void *unused)
|
||||
{
|
||||
struct nvgpu_allocator *a = s->private;
|
||||
|
||||
@@ -311,7 +311,7 @@ static void nvgpu_bitmap_alloc_destroy(struct nvgpu_allocator *__a)
|
||||
nvgpu_kfree(nvgpu_alloc_to_gpu(__a), a);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#ifdef __KERNEL__
|
||||
static void nvgpu_bitmap_print_stats(struct nvgpu_allocator *__a,
|
||||
struct seq_file *s, int lock)
|
||||
{
|
||||
@@ -347,7 +347,7 @@ static const struct nvgpu_allocator_ops bitmap_ops = {
|
||||
|
||||
.fini = nvgpu_bitmap_alloc_destroy,
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#ifdef __KERNEL__
|
||||
.print_stats = nvgpu_bitmap_print_stats,
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -1076,7 +1076,7 @@ static u64 nvgpu_buddy_alloc_space(struct nvgpu_allocator *a)
|
||||
return space;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#ifdef __KERNEL__
|
||||
/*
|
||||
* Print the buddy allocator top level stats. If you pass @s as NULL then the
|
||||
* 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 = {
|
||||
|
||||
.fini = nvgpu_buddy_allocator_destroy,
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#ifdef __KERNEL__
|
||||
.print_stats = nvgpu_buddy_print_stats,
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -116,7 +116,7 @@ static void nvgpu_lockless_alloc_destroy(struct nvgpu_allocator *a)
|
||||
nvgpu_kfree(nvgpu_alloc_to_gpu(a), pa);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#ifdef __KERNEL__
|
||||
static void nvgpu_lockless_print_stats(struct nvgpu_allocator *a,
|
||||
struct seq_file *s, int lock)
|
||||
{
|
||||
@@ -146,7 +146,7 @@ static const struct nvgpu_allocator_ops pool_ops = {
|
||||
|
||||
.fini = nvgpu_lockless_alloc_destroy,
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#ifdef __KERNEL__
|
||||
.print_stats = nvgpu_lockless_print_stats,
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -114,6 +114,14 @@ void nvgpu_alloc_destroy(struct nvgpu_allocator *a)
|
||||
memset(a, 0, sizeof(*a));
|
||||
}
|
||||
|
||||
#ifdef __KERNEL__
|
||||
void nvgpu_alloc_print_stats(struct nvgpu_allocator *__a,
|
||||
struct seq_file *s, int lock)
|
||||
{
|
||||
__a->ops->print_stats(__a, s, lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Handle the common init stuff for a nvgpu_allocator.
|
||||
*/
|
||||
|
||||
@@ -756,7 +756,7 @@ static void nvgpu_page_allocator_destroy(struct nvgpu_allocator *__a)
|
||||
alloc_unlock(__a);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#ifdef __KERNEL__
|
||||
static void nvgpu_page_print_stats(struct nvgpu_allocator *__a,
|
||||
struct seq_file *s, int lock)
|
||||
{
|
||||
@@ -833,7 +833,7 @@ static const struct nvgpu_allocator_ops page_ops = {
|
||||
|
||||
.fini = nvgpu_page_allocator_destroy,
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#ifdef __KERNEL__
|
||||
.print_stats = nvgpu_page_print_stats,
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -17,8 +17,16 @@
|
||||
#ifndef __NVGPU_ALLOCATOR_H__
|
||||
#define __NVGPU_ALLOCATOR_H__
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/*
|
||||
* The Linux kernel has this notion of seq_files for printing info to userspace.
|
||||
* One of the allocator function pointers takes advantage of this and allows the
|
||||
* debug output to be directed either to nvgpu_log() or a seq_file.
|
||||
*/
|
||||
#include <linux/seq_file.h>
|
||||
#endif
|
||||
|
||||
#include <nvgpu/log.h>
|
||||
#include <nvgpu/lock.h>
|
||||
#include <nvgpu/list.h>
|
||||
|
||||
@@ -72,7 +80,7 @@ struct nvgpu_allocator_ops {
|
||||
/* Destructor. */
|
||||
void (*fini)(struct nvgpu_allocator *allocator);
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#ifdef __KERNEL__
|
||||
/* Debugging. */
|
||||
void (*print_stats)(struct nvgpu_allocator *allocator,
|
||||
struct seq_file *s, int lock);
|
||||
@@ -246,7 +254,7 @@ u64 nvgpu_alloc_space(struct nvgpu_allocator *a);
|
||||
|
||||
void nvgpu_alloc_destroy(struct nvgpu_allocator *allocator);
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#ifdef __KERNEL__
|
||||
void nvgpu_alloc_print_stats(struct nvgpu_allocator *a,
|
||||
struct seq_file *s, int lock);
|
||||
#endif
|
||||
@@ -281,35 +289,36 @@ static inline void nvgpu_alloc_disable_dbg(struct nvgpu_allocator *a)
|
||||
/*
|
||||
* Debug stuff.
|
||||
*/
|
||||
#ifdef __KERNEL__
|
||||
#define __alloc_pstat(seq, allocator, fmt, arg...) \
|
||||
do { \
|
||||
if (s) \
|
||||
if (seq) \
|
||||
seq_printf(seq, fmt, ##arg); \
|
||||
else \
|
||||
alloc_dbg(allocator, fmt, ##arg); \
|
||||
} while (0)
|
||||
|
||||
#define __alloc_dbg(a, fmt, arg...) \
|
||||
pr_info("%-25s %25s() " fmt, (a)->name, __func__, ##arg)
|
||||
|
||||
#if defined(ALLOCATOR_DEBUG)
|
||||
/*
|
||||
* Always print the debug messages...
|
||||
*/
|
||||
#define alloc_dbg(a, fmt, arg...) __alloc_dbg(a, fmt, ##arg)
|
||||
#else
|
||||
/*
|
||||
* Only print debug messages if debug is enabled for a given allocator.
|
||||
*/
|
||||
#define alloc_dbg(a, fmt, arg...) \
|
||||
do { \
|
||||
if ((a)->debug) \
|
||||
__alloc_dbg((a), fmt, ##arg); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
#define balloc_pr(alloctor, format, arg...) \
|
||||
pr_info("%-25s %25s() " format, \
|
||||
alloctor->name, __func__, ##arg)
|
||||
|
||||
#define __alloc_dbg(a, fmt, arg...) \
|
||||
nvgpu_log((a)->g, gpu_dbg_alloc, "%25s " fmt, (a)->name, ##arg)
|
||||
|
||||
/*
|
||||
* This gives finer control over debugging messages. By defining the
|
||||
* ALLOCATOR_DEBUG 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
|
||||
* is set gpu_dbg_alloc must still also be set to true.
|
||||
*/
|
||||
#if defined(ALLOCATOR_DEBUG)
|
||||
#define alloc_dbg(a, fmt, arg...) \
|
||||
do { \
|
||||
if ((a)->debug) \
|
||||
__alloc_dbg((a), fmt, ##arg); \
|
||||
} while (0)
|
||||
#else
|
||||
#define alloc_dbg(a, fmt, arg...) __alloc_dbg(a, fmt, ##arg)
|
||||
#endif
|
||||
|
||||
#endif /* NVGPU_ALLOCATOR_H */
|
||||
|
||||
@@ -69,6 +69,7 @@ enum nvgpu_log_categories {
|
||||
gpu_dbg_shutdown = BIT(18), /* GPU shutdown tracing. */
|
||||
gpu_dbg_kmem = BIT(19), /* Kmem tracking debugging. */
|
||||
gpu_dbg_pd_cache = BIT(20), /* PD cache traces. */
|
||||
gpu_dbg_alloc = BIT(21), /* Allocator debugging. */
|
||||
gpu_dbg_mem = BIT(31), /* memory accesses; very verbose. */
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user