mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
In case the library is tracking busy subsystem, simply printing stack for every active reference will spam log with long, hard to read, redundant stack traces. To improve readabilty following changes have been made: - reports are printed per stack_handle - log is more compact, - added display name for ref_tracker_dir - it will differentiate multiple subsystems, - stack trace is printed indented, in the same printk call, - info about dropped references is printed as well. Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
93 lines
2.1 KiB
C
93 lines
2.1 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#ifndef _LINUX_REF_TRACKER_H
|
|
#define _LINUX_REF_TRACKER_H
|
|
#include <linux/refcount.h>
|
|
#include <linux/types.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/stackdepot.h>
|
|
|
|
struct ref_tracker;
|
|
|
|
struct ref_tracker_dir {
|
|
#ifdef CONFIG_REF_TRACKER
|
|
spinlock_t lock;
|
|
unsigned int quarantine_avail;
|
|
refcount_t untracked;
|
|
refcount_t no_tracker;
|
|
bool dead;
|
|
struct list_head list; /* List of active trackers */
|
|
struct list_head quarantine; /* List of dead trackers */
|
|
char name[32];
|
|
#endif
|
|
};
|
|
|
|
#ifdef CONFIG_REF_TRACKER
|
|
|
|
static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
|
|
unsigned int quarantine_count,
|
|
const char *name)
|
|
{
|
|
INIT_LIST_HEAD(&dir->list);
|
|
INIT_LIST_HEAD(&dir->quarantine);
|
|
spin_lock_init(&dir->lock);
|
|
dir->quarantine_avail = quarantine_count;
|
|
dir->dead = false;
|
|
refcount_set(&dir->untracked, 1);
|
|
refcount_set(&dir->no_tracker, 1);
|
|
strscpy(dir->name, name, sizeof(dir->name));
|
|
stack_depot_init();
|
|
}
|
|
|
|
void ref_tracker_dir_exit(struct ref_tracker_dir *dir);
|
|
|
|
void ref_tracker_dir_print_locked(struct ref_tracker_dir *dir,
|
|
unsigned int display_limit);
|
|
|
|
void ref_tracker_dir_print(struct ref_tracker_dir *dir,
|
|
unsigned int display_limit);
|
|
|
|
int ref_tracker_alloc(struct ref_tracker_dir *dir,
|
|
struct ref_tracker **trackerp, gfp_t gfp);
|
|
|
|
int ref_tracker_free(struct ref_tracker_dir *dir,
|
|
struct ref_tracker **trackerp);
|
|
|
|
#else /* CONFIG_REF_TRACKER */
|
|
|
|
static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
|
|
unsigned int quarantine_count,
|
|
const char *name)
|
|
{
|
|
}
|
|
|
|
static inline void ref_tracker_dir_exit(struct ref_tracker_dir *dir)
|
|
{
|
|
}
|
|
|
|
static inline void ref_tracker_dir_print_locked(struct ref_tracker_dir *dir,
|
|
unsigned int display_limit)
|
|
{
|
|
}
|
|
|
|
static inline void ref_tracker_dir_print(struct ref_tracker_dir *dir,
|
|
unsigned int display_limit)
|
|
{
|
|
}
|
|
|
|
static inline int ref_tracker_alloc(struct ref_tracker_dir *dir,
|
|
struct ref_tracker **trackerp,
|
|
gfp_t gfp)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int ref_tracker_free(struct ref_tracker_dir *dir,
|
|
struct ref_tracker **trackerp)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* _LINUX_REF_TRACKER_H */
|