66#include <linux/spinlock.h>
77#include <linux/stackdepot.h>
88
9+ #define __ostream_printf __printf(2, 3)
10+
911struct ref_tracker ;
1012
1113struct 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+ */
2658static 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
5992static 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