aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
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;