Skip to content

Commit 77f0813

Browse files
committed
Merge branch 'ref_tracker-add-ability-to-register-a-debugfs-file-for-a-ref_tracker_dir'
Jeff Layton says: ==================== ref_tracker: add ability to register a debugfs file for a ref_tracker_dir For those just joining in, this series adds a new top-level "ref_tracker" debugfs directory, and has each ref_tracker_dir register a file in there as part of its initialization. It also adds the ability to register a symlink with a more human-usable name that points to the file, and does some general cleanup of how the ref_tracker object names are handled. v14: https://lore.kernel.org/[email protected] v13: https://lore.kernel.org/[email protected] v12: https://lore.kernel.org/[email protected] v11: https://lore.kernel.org/[email protected] v10: https://lore.kernel.org/[email protected] v9: https://lore.kernel.org/[email protected] v8: https://lore.kernel.org/[email protected] v7: https://lore.kernel.org/[email protected] v6: https://lore.kernel.org/[email protected] v5: https://lore.kernel.org/[email protected] v4: https://lore.kernel.org/[email protected] v3: https://lore.kernel.org/[email protected] v2: https://lore.kernel.org/[email protected] v1: https://lore.kernel.org/[email protected] ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 4c6d203 + 707bd05 commit 77f0813

File tree

7 files changed

+352
-26
lines changed

7 files changed

+352
-26
lines changed

drivers/gpu/drm/display/drm_dp_tunnel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,7 @@ drm_dp_tunnel_mgr_create(struct drm_device *dev, int max_group_count)
19201920
}
19211921

19221922
#ifdef CONFIG_DRM_DISPLAY_DP_TUNNEL_STATE_DEBUG
1923-
ref_tracker_dir_init(&mgr->ref_tracker, 16, "dptun");
1923+
ref_tracker_dir_init(&mgr->ref_tracker, 16, "drm_dptun");
19241924
#endif
19251925

19261926
for (i = 0; i < max_group_count; i++) {

drivers/gpu/drm/i915/intel_runtime_pm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ static struct drm_i915_private *rpm_to_i915(struct intel_runtime_pm *rpm)
5959

6060
static void init_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm)
6161
{
62-
ref_tracker_dir_init(&rpm->debug, INTEL_REFTRACK_DEAD_COUNT, dev_name(rpm->kdev));
62+
if (!rpm->debug.class)
63+
ref_tracker_dir_init(&rpm->debug, INTEL_REFTRACK_DEAD_COUNT,
64+
"intel_runtime_pm");
6365
}
6466

6567
static intel_wakeref_t

drivers/gpu/drm/i915/intel_wakeref.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ void __intel_wakeref_init(struct intel_wakeref *wf,
114114
"wakeref.work", &key->work, 0);
115115

116116
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_WAKEREF)
117-
ref_tracker_dir_init(&wf->debug, INTEL_REFTRACK_DEAD_COUNT, name);
117+
if (!wf->debug.class)
118+
ref_tracker_dir_init(&wf->debug, INTEL_REFTRACK_DEAD_COUNT, "intel_wakeref");
118119
#endif
119120
}
120121

include/linux/ref_tracker.h

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <linux/spinlock.h>
77
#include <linux/stackdepot.h>
88

9+
#define __ostream_printf __printf(2, 3)
10+
911
struct ref_tracker;
1012

1113
struct ref_tracker_dir {
@@ -17,15 +19,45 @@ struct ref_tracker_dir {
1719
bool dead;
1820
struct list_head list; /* List of active trackers */
1921
struct list_head quarantine; /* List of dead trackers */
20-
char name[32];
22+
const char *class; /* object classname */
2123
#endif
2224
};
2325

2426
#ifdef CONFIG_REF_TRACKER
2527

28+
#ifdef CONFIG_DEBUG_FS
29+
30+
void ref_tracker_dir_debugfs(struct ref_tracker_dir *dir);
31+
void ref_tracker_dir_symlink(struct ref_tracker_dir *dir, const char *fmt, ...);
32+
33+
#else /* CONFIG_DEBUG_FS */
34+
35+
static inline void ref_tracker_dir_debugfs(struct ref_tracker_dir *dir)
36+
{
37+
}
38+
39+
static inline __ostream_printf
40+
void ref_tracker_dir_symlink(struct ref_tracker_dir *dir, const char *fmt, ...)
41+
{
42+
}
43+
44+
#endif /* CONFIG_DEBUG_FS */
45+
46+
/**
47+
* ref_tracker_dir_init - initialize a ref_tracker dir
48+
* @dir: ref_tracker_dir to be initialized
49+
* @quarantine_count: max number of entries to be tracked
50+
* @class: pointer to static string that describes object type
51+
*
52+
* Initialize a ref_tracker_dir. If debugfs is configured, then a file
53+
* will also be created for it under the top-level ref_tracker debugfs
54+
* directory.
55+
*
56+
* Note that @class must point to a static string.
57+
*/
2658
static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
2759
unsigned int quarantine_count,
28-
const char *name)
60+
const char *class)
2961
{
3062
INIT_LIST_HEAD(&dir->list);
3163
INIT_LIST_HEAD(&dir->quarantine);
@@ -34,7 +66,8 @@ static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
3466
dir->dead = false;
3567
refcount_set(&dir->untracked, 1);
3668
refcount_set(&dir->no_tracker, 1);
37-
strscpy(dir->name, name, sizeof(dir->name));
69+
dir->class = class;
70+
ref_tracker_dir_debugfs(dir);
3871
stack_depot_init();
3972
}
4073

@@ -58,7 +91,16 @@ int ref_tracker_free(struct ref_tracker_dir *dir,
5891

5992
static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
6093
unsigned int quarantine_count,
61-
const char *name)
94+
const char *class)
95+
{
96+
}
97+
98+
static inline void ref_tracker_dir_debugfs(struct ref_tracker_dir *dir)
99+
{
100+
}
101+
102+
static inline __ostream_printf
103+
void ref_tracker_dir_symlink(struct ref_tracker_dir *dir, const char *fmt, ...)
62104
{
63105
}
64106

0 commit comments

Comments
 (0)