- PL2545 WAR: disable CKRM numtasks controller
[linux-2.6.git] / include / linux / ckrm_mem.h
1 /* include/linux/ckrm_mem.h : memory control for CKRM
2  *
3  * Copyright (C) Jiantao Kong, IBM Corp. 2003
4  *           (C) Shailabh Nagar, IBM Corp. 2003
5  *           (C) Chandra Seetharaman, IBM Corp. 2004
6  *
7  *
8  * Memory control functions of the CKRM kernel API
9  *
10  * Latest version, more details at http://ckrm.sf.net
11  *
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.
16  *
17  */
18
19 #ifndef _LINUX_CKRM_MEM_H
20 #define _LINUX_CKRM_MEM_H
21
22 #ifdef CONFIG_CKRM_RES_MEM
23
24 #include <linux/list.h>
25 #include <linux/ckrm_rc.h>
26 #include <linux/kref.h>
27
28 struct ckrm_zone {
29         struct list_head active_list;
30         struct list_head inactive_list;
31
32         unsigned long nr_active;        // # of pages in the active list
33         unsigned long nr_inactive;      // # of pages in the inactive list
34         unsigned long active_over;
35         unsigned long inactive_over;
36
37         unsigned long shrink_active;
38         unsigned long shrink_inactive;
39         long shrink_weight;
40         unsigned long shrink_flag;
41
42         struct list_head victim_list;   // list of ckrm_zones chosen for shrinking
43         struct zone *zone;
44         struct ckrm_mem_res *memcls;
45 };
46
47 struct ckrm_mem_res {
48         unsigned long flags;
49         struct ckrm_core_class *core;   // the core i am part of...
50         struct ckrm_core_class *parent; // parent of the core i am part of....
51         struct ckrm_shares shares;
52         struct list_head mcls_list;     // list of all 1-level classes
53         struct list_head shrink_list;   // list of classes need to be shrunk
54         struct kref nr_users;           // # of references to this class/data structure
55         atomic_t pg_total;              // # of pages used by this class
56         int pg_guar;                    // # of pages this class is guaranteed
57         int pg_limit;                   // max # of pages this class can get
58         int pg_borrowed;                // # of pages this class borrowed from its parent
59         int pg_lent;                    // # of pages this class lent to its children
60         int pg_unused;                  // # of pages left to this class (after giving the
61                                         // guarantees to children. need to borrow from parent if
62                                         // more than this is needed.
63         int impl_guar;                  // implicit guarantee for class with don't care guar
64         int nr_dontcare;                // # of children with don't care guarantee
65         struct ckrm_zone ckrm_zone[MAX_NR_ZONES];
66         int shrink_count;
67         unsigned long last_shrink;
68         int over_limit_failures;
69         int shrink_pages;               // # of pages to free in this class
70         int hier;                       // hiearchy, root = 0
71 };
72
73 extern atomic_t ckrm_mem_real_count;
74 extern unsigned int ckrm_tot_lru_pages;
75 extern int ckrm_nr_mem_classes;
76 extern struct list_head ckrm_shrink_list;
77 extern struct list_head ckrm_memclass_list;
78 extern spinlock_t ckrm_mem_lock;
79 extern struct ckrm_res_ctlr mem_rcbs;
80 extern struct ckrm_mem_res *ckrm_mem_root_class;
81
82 #define page_ckrmzone(page)     ((page)->ckrm_zone)
83
84 #define CLS_SHRINK_BIT  (1)
85
86 // used in flags. set when a class is more than 90% of its maxlimit
87 #define MEM_AT_LIMIT    1
88
89 extern void ckrm_init_mm_to_task(struct mm_struct *, struct task_struct *);
90 extern void ckrm_mem_evaluate_mm(struct mm_struct *, struct ckrm_mem_res *);
91 extern void ckrm_at_limit(struct ckrm_mem_res *);
92 extern int ckrm_memclass_valid(struct ckrm_mem_res *);
93 extern int ckrm_mem_get_shrink_to(void);
94 extern void check_memclass(struct ckrm_mem_res *, char *);
95 extern void memclass_release(struct kref *);
96
97 #else
98
99 #define ckrm_init_mm_to_current(a)                      do {} while (0)
100 #define ckrm_mem_evaluate_mm(a)                         do {} while (0)
101 #define ckrm_init_mm_to_task(a,b)                       do {} while (0)
102
103 #endif // CONFIG_CKRM_RES_MEM
104
105 #endif //_LINUX_CKRM_MEM_H