~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/ref_tracker.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 #ifndef _LINUX_REF_TRACKER_H
  3 #define _LINUX_REF_TRACKER_H
  4 #include <linux/refcount.h>
  5 #include <linux/types.h>
  6 #include <linux/spinlock.h>
  7 #include <linux/stackdepot.h>
  8 
  9 struct ref_tracker;
 10 
 11 struct ref_tracker_dir {
 12 #ifdef CONFIG_REF_TRACKER
 13         spinlock_t              lock;
 14         unsigned int            quarantine_avail;
 15         refcount_t              untracked;
 16         refcount_t              no_tracker;
 17         bool                    dead;
 18         struct list_head        list; /* List of active trackers */
 19         struct list_head        quarantine; /* List of dead trackers */
 20         char                    name[32];
 21 #endif
 22 };
 23 
 24 #ifdef CONFIG_REF_TRACKER
 25 
 26 static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
 27                                         unsigned int quarantine_count,
 28                                         const char *name)
 29 {
 30         INIT_LIST_HEAD(&dir->list);
 31         INIT_LIST_HEAD(&dir->quarantine);
 32         spin_lock_init(&dir->lock);
 33         dir->quarantine_avail = quarantine_count;
 34         dir->dead = false;
 35         refcount_set(&dir->untracked, 1);
 36         refcount_set(&dir->no_tracker, 1);
 37         strscpy(dir->name, name, sizeof(dir->name));
 38         stack_depot_init();
 39 }
 40 
 41 void ref_tracker_dir_exit(struct ref_tracker_dir *dir);
 42 
 43 void ref_tracker_dir_print_locked(struct ref_tracker_dir *dir,
 44                                   unsigned int display_limit);
 45 
 46 void ref_tracker_dir_print(struct ref_tracker_dir *dir,
 47                            unsigned int display_limit);
 48 
 49 int ref_tracker_dir_snprint(struct ref_tracker_dir *dir, char *buf, size_t size);
 50 
 51 int ref_tracker_alloc(struct ref_tracker_dir *dir,
 52                       struct ref_tracker **trackerp, gfp_t gfp);
 53 
 54 int ref_tracker_free(struct ref_tracker_dir *dir,
 55                      struct ref_tracker **trackerp);
 56 
 57 #else /* CONFIG_REF_TRACKER */
 58 
 59 static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
 60                                         unsigned int quarantine_count,
 61                                         const char *name)
 62 {
 63 }
 64 
 65 static inline void ref_tracker_dir_exit(struct ref_tracker_dir *dir)
 66 {
 67 }
 68 
 69 static inline void ref_tracker_dir_print_locked(struct ref_tracker_dir *dir,
 70                                                 unsigned int display_limit)
 71 {
 72 }
 73 
 74 static inline void ref_tracker_dir_print(struct ref_tracker_dir *dir,
 75                                          unsigned int display_limit)
 76 {
 77 }
 78 
 79 static inline int ref_tracker_dir_snprint(struct ref_tracker_dir *dir,
 80                                           char *buf, size_t size)
 81 {
 82         return 0;
 83 }
 84 
 85 static inline int ref_tracker_alloc(struct ref_tracker_dir *dir,
 86                                     struct ref_tracker **trackerp,
 87                                     gfp_t gfp)
 88 {
 89         return 0;
 90 }
 91 
 92 static inline int ref_tracker_free(struct ref_tracker_dir *dir,
 93                                    struct ref_tracker **trackerp)
 94 {
 95         return 0;
 96 }
 97 
 98 #endif
 99 
100 #endif /* _LINUX_REF_TRACKER_H */
101 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php