include/linux/ref_tracker.h
Source file repositories/reference/linux-study-clean/include/linux/ref_tracker.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/ref_tracker.h- Extension
.h- Size
- 3527 bytes
- Lines
- 143
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/refcount.hlinux/types.hlinux/spinlock.hlinux/stackdepot.h
Detected Declarations
struct ref_trackerstruct ref_tracker_dirfunction ref_tracker_dir_debugfsfunction ref_tracker_dir_initfunction ref_tracker_allocfunction ref_tracker_free
Annotated Snippet
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 */
const char *class; /* object classname */
#endif
};
#ifdef CONFIG_REF_TRACKER
#ifdef CONFIG_DEBUG_FS
void ref_tracker_dir_debugfs(struct ref_tracker_dir *dir);
void ref_tracker_dir_symlink(struct ref_tracker_dir *dir, const char *fmt, ...);
#else /* CONFIG_DEBUG_FS */
static inline void ref_tracker_dir_debugfs(struct ref_tracker_dir *dir)
{
}
static inline __ostream_printf
void ref_tracker_dir_symlink(struct ref_tracker_dir *dir, const char *fmt, ...)
{
}
#endif /* CONFIG_DEBUG_FS */
/**
* ref_tracker_dir_init - initialize a ref_tracker dir
* @dir: ref_tracker_dir to be initialized
* @quarantine_count: max number of entries to be tracked
* @class: pointer to static string that describes object type
*
* Initialize a ref_tracker_dir. If debugfs is configured, then a file
* will also be created for it under the top-level ref_tracker debugfs
* directory.
*
* Note that @class must point to a static string.
*/
static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
unsigned int quarantine_count,
const char *class)
{
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);
dir->class = class;
ref_tracker_dir_debugfs(dir);
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_dir_snprint(struct ref_tracker_dir *dir, char *buf, size_t size);
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 *class)
{
}
static inline void ref_tracker_dir_debugfs(struct ref_tracker_dir *dir)
{
}
static inline __ostream_printf
Annotation
- Immediate include surface: `linux/refcount.h`, `linux/types.h`, `linux/spinlock.h`, `linux/stackdepot.h`.
- Detected declarations: `struct ref_tracker`, `struct ref_tracker_dir`, `function ref_tracker_dir_debugfs`, `function ref_tracker_dir_init`, `function ref_tracker_alloc`, `function ref_tracker_free`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.