Merge branches 'acpica-fixes', 'acpi-pci-fixes' and 'acpi-debug-fixes'
[deliverable/linux.git] / include / linux / hugetlb_cgroup.h
CommitLineData
2bc64a20
AK
1/*
2 * Copyright IBM Corporation, 2012
3 * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2.1 of the GNU Lesser General Public License
7 * as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 *
13 */
14
15#ifndef _LINUX_HUGETLB_CGROUP_H
16#define _LINUX_HUGETLB_CGROUP_H
17
309381fe 18#include <linux/mmdebug.h>
2bc64a20
AK
19
20struct hugetlb_cgroup;
9dd540e2
AK
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
2bc64a20
AK
26
27#ifdef CONFIG_CGROUP_HUGETLB
9dd540e2
AK
28
29static inline struct hugetlb_cgroup *hugetlb_cgroup_from_page(struct page *page)
30{
309381fe 31 VM_BUG_ON_PAGE(!PageHuge(page), page);
9dd540e2
AK
32
33 if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER)
34 return NULL;
1d798ca3 35 return (struct hugetlb_cgroup *)page[2].private;
9dd540e2
AK
36}
37
38static inline
39int set_hugetlb_cgroup(struct page *page, struct hugetlb_cgroup *h_cg)
40{
309381fe 41 VM_BUG_ON_PAGE(!PageHuge(page), page);
9dd540e2
AK
42
43 if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER)
44 return -1;
1d798ca3 45 page[2].private = (unsigned long)h_cg;
9dd540e2
AK
46 return 0;
47}
48
2bc64a20
AK
49static inline bool hugetlb_cgroup_disabled(void)
50{
fc5ed1e9 51 return !cgroup_subsys_enabled(hugetlb_cgrp_subsys);
2bc64a20
AK
52}
53
6d76dcf4
AK
54extern int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
55 struct hugetlb_cgroup **ptr);
56extern void hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages,
57 struct hugetlb_cgroup *h_cg,
58 struct page *page);
59extern void hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages,
60 struct page *page);
61extern void hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages,
62 struct hugetlb_cgroup *h_cg);
7179e7bf 63extern void hugetlb_cgroup_file_init(void) __init;
8e6ac7fa
AK
64extern void hugetlb_cgroup_migrate(struct page *oldhpage,
65 struct page *newhpage);
6d76dcf4 66
2bc64a20 67#else
9dd540e2
AK
68static inline struct hugetlb_cgroup *hugetlb_cgroup_from_page(struct page *page)
69{
70 return NULL;
71}
72
73static inline
74int set_hugetlb_cgroup(struct page *page, struct hugetlb_cgroup *h_cg)
75{
76 return 0;
77}
78
2bc64a20
AK
79static inline bool hugetlb_cgroup_disabled(void)
80{
81 return true;
82}
83
6d76dcf4
AK
84static inline int
85hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
86 struct hugetlb_cgroup **ptr)
87{
88 return 0;
89}
90
91static inline void
92hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages,
93 struct hugetlb_cgroup *h_cg,
94 struct page *page)
95{
6d76dcf4
AK
96}
97
98static inline void
99hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages, struct page *page)
100{
6d76dcf4
AK
101}
102
103static inline void
104hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages,
105 struct hugetlb_cgroup *h_cg)
106{
6d76dcf4
AK
107}
108
7179e7bf 109static inline void hugetlb_cgroup_file_init(void)
abb8206c 110{
abb8206c
AK
111}
112
8e6ac7fa
AK
113static inline void hugetlb_cgroup_migrate(struct page *oldhpage,
114 struct page *newhpage)
115{
8e6ac7fa
AK
116}
117
2bc64a20
AK
118#endif /* CONFIG_MEM_RES_CTLR_HUGETLB */
119#endif
This page took 0.284864 seconds and 5 git commands to generate.