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

TOMOYO Linux Cross Reference
Linux/mm/memcontrol-v1.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 
  3 #ifndef __MM_MEMCONTROL_V1_H
  4 #define __MM_MEMCONTROL_V1_H
  5 
  6 #include <linux/cgroup-defs.h>
  7 
  8 /* Cgroup v1 and v2 common declarations */
  9 
 10 void mem_cgroup_charge_statistics(struct mem_cgroup *memcg, int nr_pages);
 11 int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
 12                      unsigned int nr_pages);
 13 
 14 static inline int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 15                              unsigned int nr_pages)
 16 {
 17         if (mem_cgroup_is_root(memcg))
 18                 return 0;
 19 
 20         return try_charge_memcg(memcg, gfp_mask, nr_pages);
 21 }
 22 
 23 void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n);
 24 void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n);
 25 
 26 /*
 27  * Iteration constructs for visiting all cgroups (under a tree).  If
 28  * loops are exited prematurely (break), mem_cgroup_iter_break() must
 29  * be used for reference counting.
 30  */
 31 #define for_each_mem_cgroup_tree(iter, root)            \
 32         for (iter = mem_cgroup_iter(root, NULL, NULL);  \
 33              iter != NULL;                              \
 34              iter = mem_cgroup_iter(root, iter, NULL))
 35 
 36 #define for_each_mem_cgroup(iter)                       \
 37         for (iter = mem_cgroup_iter(NULL, NULL, NULL);  \
 38              iter != NULL;                              \
 39              iter = mem_cgroup_iter(NULL, iter, NULL))
 40 
 41 /* Whether legacy memory+swap accounting is active */
 42 static bool do_memsw_account(void)
 43 {
 44         return !cgroup_subsys_on_dfl(memory_cgrp_subsys);
 45 }
 46 
 47 /*
 48  * Per memcg event counter is incremented at every pagein/pageout. With THP,
 49  * it will be incremented by the number of pages. This counter is used
 50  * to trigger some periodic events. This is straightforward and better
 51  * than using jiffies etc. to handle periodic memcg event.
 52  */
 53 enum mem_cgroup_events_target {
 54         MEM_CGROUP_TARGET_THRESH,
 55         MEM_CGROUP_TARGET_SOFTLIMIT,
 56         MEM_CGROUP_NTARGETS,
 57 };
 58 
 59 bool mem_cgroup_event_ratelimit(struct mem_cgroup *memcg,
 60                                 enum mem_cgroup_events_target target);
 61 unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap);
 62 
 63 void drain_all_stock(struct mem_cgroup *root_memcg);
 64 
 65 unsigned long memcg_events(struct mem_cgroup *memcg, int event);
 66 unsigned long memcg_events_local(struct mem_cgroup *memcg, int event);
 67 unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx);
 68 unsigned long memcg_page_state_output(struct mem_cgroup *memcg, int item);
 69 unsigned long memcg_page_state_local_output(struct mem_cgroup *memcg, int item);
 70 int memory_stat_show(struct seq_file *m, void *v);
 71 
 72 /* Cgroup v1-specific declarations */
 73 #ifdef CONFIG_MEMCG_V1
 74 void memcg1_memcg_init(struct mem_cgroup *memcg);
 75 void memcg1_remove_from_trees(struct mem_cgroup *memcg);
 76 
 77 static inline void memcg1_soft_limit_reset(struct mem_cgroup *memcg)
 78 {
 79         WRITE_ONCE(memcg->soft_limit, PAGE_COUNTER_MAX);
 80 }
 81 
 82 bool memcg1_wait_acct_move(struct mem_cgroup *memcg);
 83 
 84 struct cgroup_taskset;
 85 int memcg1_can_attach(struct cgroup_taskset *tset);
 86 void memcg1_cancel_attach(struct cgroup_taskset *tset);
 87 void memcg1_move_task(void);
 88 void memcg1_css_offline(struct mem_cgroup *memcg);
 89 
 90 /* for encoding cft->private value on file */
 91 enum res_type {
 92         _MEM,
 93         _MEMSWAP,
 94         _KMEM,
 95         _TCP,
 96 };
 97 
 98 bool memcg1_oom_prepare(struct mem_cgroup *memcg, bool *locked);
 99 void memcg1_oom_finish(struct mem_cgroup *memcg, bool locked);
100 void memcg1_oom_recover(struct mem_cgroup *memcg);
101 
102 void memcg1_check_events(struct mem_cgroup *memcg, int nid);
103 
104 void memcg1_stat_format(struct mem_cgroup *memcg, struct seq_buf *s);
105 
106 void memcg1_account_kmem(struct mem_cgroup *memcg, int nr_pages);
107 static inline bool memcg1_tcpmem_active(struct mem_cgroup *memcg)
108 {
109         return memcg->tcpmem_active;
110 }
111 bool memcg1_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages,
112                          gfp_t gfp_mask);
113 static inline void memcg1_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages)
114 {
115         page_counter_uncharge(&memcg->tcpmem, nr_pages);
116 }
117 
118 extern struct cftype memsw_files[];
119 extern struct cftype mem_cgroup_legacy_files[];
120 
121 #else   /* CONFIG_MEMCG_V1 */
122 
123 static inline void memcg1_memcg_init(struct mem_cgroup *memcg) {}
124 static inline void memcg1_remove_from_trees(struct mem_cgroup *memcg) {}
125 static inline void memcg1_soft_limit_reset(struct mem_cgroup *memcg) {}
126 static inline bool memcg1_wait_acct_move(struct mem_cgroup *memcg) { return false; }
127 static inline void memcg1_css_offline(struct mem_cgroup *memcg) {}
128 
129 static inline bool memcg1_oom_prepare(struct mem_cgroup *memcg, bool *locked) { return true; }
130 static inline void memcg1_oom_finish(struct mem_cgroup *memcg, bool locked) {}
131 static inline void memcg1_oom_recover(struct mem_cgroup *memcg) {}
132 
133 static inline void memcg1_check_events(struct mem_cgroup *memcg, int nid) {}
134 
135 static inline void memcg1_stat_format(struct mem_cgroup *memcg, struct seq_buf *s) {}
136 
137 static inline void memcg1_account_kmem(struct mem_cgroup *memcg, int nr_pages) {}
138 static inline bool memcg1_tcpmem_active(struct mem_cgroup *memcg) { return false; }
139 static inline bool memcg1_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages,
140                                        gfp_t gfp_mask) { return true; }
141 static inline void memcg1_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages) {}
142 
143 extern struct cftype memsw_files[];
144 extern struct cftype mem_cgroup_legacy_files[];
145 #endif  /* CONFIG_MEMCG_V1 */
146 
147 #endif  /* __MM_MEMCONTROL_V1_H */
148 

~ [ 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