aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2012-07-31 19:42:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-31 21:42:41 -0400
commit9dd540e23111d8884773ab942a736f3aba4040d4 (patch)
tree84c7dcfa97c43d1f09ad88cdc836ff1b99da76e4 /include
parent2bc64a2046975410505bb119bba32705892b9255 (diff)
hugetlb/cgroup: add the cgroup pointer to page lru
Add the hugetlb cgroup pointer to 3rd page lru.next. This limit the usage to hugetlb cgroup to only hugepages with 3 or more normal pages. I guess that is an acceptable limitation. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Cc: David Rientjes <rientjes@google.com> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Hillf Danton <dhillf@gmail.com> Reviewed-by: Michal Hocko <mhocko@suse.cz> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/hugetlb_cgroup.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h
index f19889e56b47..e5451a3b4ebc 100644
--- a/include/linux/hugetlb_cgroup.h
+++ b/include/linux/hugetlb_cgroup.h
@@ -18,8 +18,34 @@
18#include <linux/res_counter.h> 18#include <linux/res_counter.h>
19 19
20struct hugetlb_cgroup; 20struct hugetlb_cgroup;
21/*
22 * Minimum page order trackable by hugetlb cgroup.
23 * At least 3 pages are necessary for all the tracking information.
24 */
25#define HUGETLB_CGROUP_MIN_ORDER 2
21 26
22#ifdef CONFIG_CGROUP_HUGETLB 27#ifdef CONFIG_CGROUP_HUGETLB
28
29static inline struct hugetlb_cgroup *hugetlb_cgroup_from_page(struct page *page)
30{
31 VM_BUG_ON(!PageHuge(page));
32
33 if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER)
34 return NULL;
35 return (struct hugetlb_cgroup *)page[2].lru.next;
36}
37
38static inline
39int set_hugetlb_cgroup(struct page *page, struct hugetlb_cgroup *h_cg)
40{
41 VM_BUG_ON(!PageHuge(page));
42
43 if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER)
44 return -1;
45 page[2].lru.next = (void *)h_cg;
46 return 0;
47}
48
23static inline bool hugetlb_cgroup_disabled(void) 49static inline bool hugetlb_cgroup_disabled(void)
24{ 50{
25 if (hugetlb_subsys.disabled) 51 if (hugetlb_subsys.disabled)
@@ -28,6 +54,17 @@ static inline bool hugetlb_cgroup_disabled(void)
28} 54}
29 55
30#else 56#else
57static inline struct hugetlb_cgroup *hugetlb_cgroup_from_page(struct page *page)
58{
59 return NULL;
60}
61
62static inline
63int set_hugetlb_cgroup(struct page *page, struct hugetlb_cgroup *h_cg)
64{
65 return 0;
66}
67
31static inline bool hugetlb_cgroup_disabled(void) 68static inline bool hugetlb_cgroup_disabled(void)
32{ 69{
33 return true; 70 return true;