Revert "lib/ref_tracker: add unlocked leak print helper"

This reverts commit 9b9cd362c1.
This commit is contained in:
Junxiao Chang 2023-07-06 15:04:16 +08:00
parent 6aaa35a373
commit 6318ea22d4
2 changed files with 28 additions and 46 deletions

View File

@ -36,9 +36,6 @@ static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
void ref_tracker_dir_exit(struct ref_tracker_dir *dir);
void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
unsigned int display_limit);
void ref_tracker_dir_print(struct ref_tracker_dir *dir,
unsigned int display_limit);
@ -59,11 +56,6 @@ static inline void ref_tracker_dir_exit(struct ref_tracker_dir *dir)
{
}
static inline void __ref_tracker_dir_print(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)
{

View File

@ -14,38 +14,6 @@ struct ref_tracker {
depot_stack_handle_t free_stack_handle;
};
void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
unsigned int display_limit)
{
struct ref_tracker *tracker;
unsigned int i = 0;
lockdep_assert_held(&dir->lock);
list_for_each_entry(tracker, &dir->list, head) {
if (i < display_limit) {
pr_err("leaked reference.\n");
if (tracker->alloc_stack_handle)
stack_depot_print(tracker->alloc_stack_handle);
i++;
} else {
break;
}
}
}
EXPORT_SYMBOL(__ref_tracker_dir_print);
void ref_tracker_dir_print(struct ref_tracker_dir *dir,
unsigned int display_limit)
{
unsigned long flags;
spin_lock_irqsave(&dir->lock, flags);
__ref_tracker_dir_print(dir, display_limit);
spin_unlock_irqrestore(&dir->lock, flags);
}
EXPORT_SYMBOL(ref_tracker_dir_print);
void ref_tracker_dir_exit(struct ref_tracker_dir *dir)
{
struct ref_tracker *tracker, *n;
@ -59,13 +27,13 @@ void ref_tracker_dir_exit(struct ref_tracker_dir *dir)
kfree(tracker);
dir->quarantine_avail++;
}
if (!list_empty(&dir->list)) {
__ref_tracker_dir_print(dir, 16);
list_for_each_entry_safe(tracker, n, &dir->list, head) {
pr_err("leaked reference.\n");
if (tracker->alloc_stack_handle)
stack_depot_print(tracker->alloc_stack_handle);
leak = true;
list_for_each_entry_safe(tracker, n, &dir->list, head) {
list_del(&tracker->head);
kfree(tracker);
}
list_del(&tracker->head);
kfree(tracker);
}
spin_unlock_irqrestore(&dir->lock, flags);
WARN_ON_ONCE(leak);
@ -74,6 +42,28 @@ void ref_tracker_dir_exit(struct ref_tracker_dir *dir)
}
EXPORT_SYMBOL(ref_tracker_dir_exit);
void ref_tracker_dir_print(struct ref_tracker_dir *dir,
unsigned int display_limit)
{
struct ref_tracker *tracker;
unsigned long flags;
unsigned int i = 0;
spin_lock_irqsave(&dir->lock, flags);
list_for_each_entry(tracker, &dir->list, head) {
if (i < display_limit) {
pr_err("leaked reference.\n");
if (tracker->alloc_stack_handle)
stack_depot_print(tracker->alloc_stack_handle);
i++;
} else {
break;
}
}
spin_unlock_irqrestore(&dir->lock, flags);
}
EXPORT_SYMBOL(ref_tracker_dir_print);
int ref_tracker_alloc(struct ref_tracker_dir *dir,
struct ref_tracker **trackerp,
gfp_t gfp)