Blame view

include/linux/hugetlb_cgroup.h 2.93 KB
2bc64a204   Aneesh Kumar K.V   mm/hugetlb: add n...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  /*
   * Copyright IBM Corporation, 2012
   * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
   *
   * This program is free software; you can redistribute it and/or modify it
   * under the terms of version 2.1 of the GNU Lesser General Public License
   * as published by the Free Software Foundation.
   *
   * This program is distributed in the hope that it would be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   *
   */
  
  #ifndef _LINUX_HUGETLB_CGROUP_H
  #define _LINUX_HUGETLB_CGROUP_H
309381fea   Sasha Levin   mm: dump page whe...
17
  #include <linux/mmdebug.h>
2bc64a204   Aneesh Kumar K.V   mm/hugetlb: add n...
18
19
  
  struct hugetlb_cgroup;
9dd540e23   Aneesh Kumar K.V   hugetlb/cgroup: a...
20
21
22
23
24
  /*
   * Minimum page order trackable by hugetlb cgroup.
   * At least 3 pages are necessary for all the tracking information.
   */
  #define HUGETLB_CGROUP_MIN_ORDER	2
2bc64a204   Aneesh Kumar K.V   mm/hugetlb: add n...
25
26
  
  #ifdef CONFIG_CGROUP_HUGETLB
9dd540e23   Aneesh Kumar K.V   hugetlb/cgroup: a...
27
28
29
  
  static inline struct hugetlb_cgroup *hugetlb_cgroup_from_page(struct page *page)
  {
309381fea   Sasha Levin   mm: dump page whe...
30
  	VM_BUG_ON_PAGE(!PageHuge(page), page);
9dd540e23   Aneesh Kumar K.V   hugetlb/cgroup: a...
31
32
33
  
  	if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER)
  		return NULL;
1d798ca3f   Kirill A. Shutemov   mm: make compound...
34
  	return (struct hugetlb_cgroup *)page[2].private;
9dd540e23   Aneesh Kumar K.V   hugetlb/cgroup: a...
35
36
37
38
39
  }
  
  static inline
  int set_hugetlb_cgroup(struct page *page, struct hugetlb_cgroup *h_cg)
  {
309381fea   Sasha Levin   mm: dump page whe...
40
  	VM_BUG_ON_PAGE(!PageHuge(page), page);
9dd540e23   Aneesh Kumar K.V   hugetlb/cgroup: a...
41
42
43
  
  	if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER)
  		return -1;
1d798ca3f   Kirill A. Shutemov   mm: make compound...
44
  	page[2].private	= (unsigned long)h_cg;
9dd540e23   Aneesh Kumar K.V   hugetlb/cgroup: a...
45
46
  	return 0;
  }
2bc64a204   Aneesh Kumar K.V   mm/hugetlb: add n...
47
48
  static inline bool hugetlb_cgroup_disabled(void)
  {
fc5ed1e95   Tejun Heo   cgroup: replace c...
49
  	return !cgroup_subsys_enabled(hugetlb_cgrp_subsys);
2bc64a204   Aneesh Kumar K.V   mm/hugetlb: add n...
50
  }
6d76dcf40   Aneesh Kumar K.V   hugetlb/cgroup: a...
51
52
53
54
55
56
57
58
59
  extern int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
  					struct hugetlb_cgroup **ptr);
  extern void hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages,
  					 struct hugetlb_cgroup *h_cg,
  					 struct page *page);
  extern void hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages,
  					 struct page *page);
  extern void hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages,
  					   struct hugetlb_cgroup *h_cg);
7179e7bf4   Jianguo Wu   mm/hugetlb: creat...
60
  extern void hugetlb_cgroup_file_init(void) __init;
8e6ac7fab   Aneesh Kumar K.V   hugetlb/cgroup: m...
61
62
  extern void hugetlb_cgroup_migrate(struct page *oldhpage,
  				   struct page *newhpage);
6d76dcf40   Aneesh Kumar K.V   hugetlb/cgroup: a...
63

2bc64a204   Aneesh Kumar K.V   mm/hugetlb: add n...
64
  #else
9dd540e23   Aneesh Kumar K.V   hugetlb/cgroup: a...
65
66
67
68
69
70
71
72
73
74
  static inline struct hugetlb_cgroup *hugetlb_cgroup_from_page(struct page *page)
  {
  	return NULL;
  }
  
  static inline
  int set_hugetlb_cgroup(struct page *page, struct hugetlb_cgroup *h_cg)
  {
  	return 0;
  }
2bc64a204   Aneesh Kumar K.V   mm/hugetlb: add n...
75
76
77
78
  static inline bool hugetlb_cgroup_disabled(void)
  {
  	return true;
  }
6d76dcf40   Aneesh Kumar K.V   hugetlb/cgroup: a...
79
80
81
82
83
84
85
86
87
88
89
90
  static inline int
  hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
  			     struct hugetlb_cgroup **ptr)
  {
  	return 0;
  }
  
  static inline void
  hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages,
  			     struct hugetlb_cgroup *h_cg,
  			     struct page *page)
  {
6d76dcf40   Aneesh Kumar K.V   hugetlb/cgroup: a...
91
92
93
94
95
  }
  
  static inline void
  hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages, struct page *page)
  {
6d76dcf40   Aneesh Kumar K.V   hugetlb/cgroup: a...
96
97
98
99
100
101
  }
  
  static inline void
  hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages,
  			       struct hugetlb_cgroup *h_cg)
  {
6d76dcf40   Aneesh Kumar K.V   hugetlb/cgroup: a...
102
  }
7179e7bf4   Jianguo Wu   mm/hugetlb: creat...
103
  static inline void hugetlb_cgroup_file_init(void)
abb8206cb   Aneesh Kumar K.V   hugetlb/cgroup: a...
104
  {
abb8206cb   Aneesh Kumar K.V   hugetlb/cgroup: a...
105
  }
8e6ac7fab   Aneesh Kumar K.V   hugetlb/cgroup: m...
106
107
108
  static inline void hugetlb_cgroup_migrate(struct page *oldhpage,
  					  struct page *newhpage)
  {
8e6ac7fab   Aneesh Kumar K.V   hugetlb/cgroup: m...
109
  }
2bc64a204   Aneesh Kumar K.V   mm/hugetlb: add n...
110
111
  #endif  /* CONFIG_MEM_RES_CTLR_HUGETLB */
  #endif