1 /* include/linux/ckrm_mem.h : memory control for CKRM
3 * Copyright (C) Jiantao Kong, IBM Corp. 2003
4 * (C) Shailabh Nagar, IBM Corp. 2003
5 * (C) Chandra Seetharaman, IBM Corp. 2004
8 * Memory control functions of the CKRM kernel API
10 * Latest version, more details at http://ckrm.sf.net
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
19 #ifndef _LINUX_CKRM_MEM_H
20 #define _LINUX_CKRM_MEM_H
22 #ifdef CONFIG_CKRM_RES_MEM
24 #include <linux/list.h>
25 #include <linux/ckrm_rc.h>
26 #include <linux/kref.h>
29 struct list_head active_list;
30 struct list_head inactive_list;
32 unsigned long nr_active;
33 unsigned long nr_inactive;
34 unsigned long active_over;
35 unsigned long inactive_over;
37 unsigned long shrink_active;
38 unsigned long shrink_inactive;
40 unsigned long shrink_flag;
41 struct list_head victim_list; /* list of ckrm_zones chosen for
42 * shrinking. These are over their
46 struct ckrm_mem_res *memcls;
51 struct ckrm_core_class *core; /* the core i am part of... */
52 struct ckrm_core_class *parent; /* parent of the core i am part of */
53 struct ckrm_shares shares;
54 struct list_head mcls_list; /* list of all 1-level classes */
55 struct kref nr_users; /* ref count */
56 atomic_t pg_total; /* # of pages used by this class */
57 int pg_guar; /* absolute # of guarantee */
58 int pg_limit; /* absolute # of limit */
59 int pg_borrowed; /* # of pages borrowed from parent */
60 int pg_lent; /* # of pages lent to children */
61 int pg_unused; /* # of pages left to this class
62 * (after giving the guarantees to
63 * children. need to borrow from
64 * parent if more than this is needed.
66 int hier; /* hiearchy level, root = 0 */
67 int impl_guar; /* for classes with don't care guar */
68 int nr_dontcare; /* # of dont care children */
70 struct ckrm_zone ckrm_zone[MAX_NR_ZONES];
72 struct list_head shrink_list; /* list of classes that are near
73 * limit and need to be shrunk
76 unsigned long last_shrink;
79 #define CLS_SHRINK_BIT (1)
81 #define CLS_AT_LIMIT (1)
83 extern atomic_t ckrm_mem_real_count;
84 extern struct ckrm_res_ctlr mem_rcbs;
85 extern struct ckrm_mem_res *ckrm_mem_root_class;
86 extern struct list_head ckrm_memclass_list;
87 extern struct list_head ckrm_shrink_list;
88 extern spinlock_t ckrm_mem_lock;
89 extern int ckrm_nr_mem_classes;
90 extern unsigned int ckrm_tot_lru_pages;
91 extern int ckrm_mem_shrink_count;
92 extern int ckrm_mem_shrink_to;
93 extern int ckrm_mem_shrink_interval ;
95 extern void ckrm_mem_migrate_mm(struct mm_struct *, struct ckrm_mem_res *);
96 extern void ckrm_mem_migrate_all_pages(struct ckrm_mem_res *,
97 struct ckrm_mem_res *);
98 extern void memclass_release(struct kref *);
99 extern void shrink_get_victims(struct zone *, unsigned long ,
100 unsigned long, struct list_head *);
101 extern void ckrm_shrink_atlimit(struct ckrm_mem_res *);
104 #define ckrm_mem_migrate_mm(a, b) do {} while (0)
105 #define ckrm_mem_migrate_all_pages(a, b) do {} while (0)
107 #endif /* CONFIG_CKRM_RES_MEM */
109 #endif /* _LINUX_CKRM_MEM_H */