aboutsummaryrefslogtreecommitdiffstats
path: root/features/cgroups/vm_cgroup-backport-dependence-to-fix-vm_cgroup-infra.patch
blob: 99f025f546ed50666794230e40f64240e88055ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
From bedc10dde746fc832539ae51cfa1913adc4cf42a Mon Sep 17 00:00:00 2001
From: He Zhe <zhe.he@windriver.com>
Date: Fri, 8 Aug 2014 09:20:34 +0800
Subject: [PATCH 2/7] vm_cgroup: backport dependence to fix vm_cgroup
 infrastructure compile failure

Backport necessary dependence from v3.16-rc2 on which the original patch is
based to fix compile failure.
 - Change IS_ENABLED to IS_SUBSYS_ENABLED which is defined by
   include/linux/subsys_cgroup.h
 - Modify proc interface to meet current definition
 - Change vm_cgrp_subsys to vm_subsys which is generated by
   include/linux/cgroup.h
 - Add name and subsys_id fields for vm_subsys

Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
---
 include/linux/cgroup_subsys.h |  2 +-
 include/linux/vm_cgroup.h     |  2 +-
 mm/vm_cgroup.c                | 36 +++++++++++++++---------------------
 3 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index b42297397959..38ae1fcc46b0 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -55,7 +55,7 @@ SUBSYS(hugetlb)
 SUBSYS(files)
 #endif
 
-#if IS_ENABLED(CONFIG_CGROUP_VM)
+#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_VM)
 SUBSYS(vm)
 #endif
 
diff --git a/include/linux/vm_cgroup.h b/include/linux/vm_cgroup.h
index b629c9affa4b..3694bc447231 100644
--- a/include/linux/vm_cgroup.h
+++ b/include/linux/vm_cgroup.h
@@ -4,7 +4,7 @@
 #ifdef CONFIG_CGROUP_VM
 static inline bool vm_cgroup_disabled(void)
 {
-	if (vm_cgrp_subsys.disabled)
+	if (vm_subsys.disabled)
 		return true;
 	return false;
 }
diff --git a/mm/vm_cgroup.c b/mm/vm_cgroup.c
index 7f5b81482748..9f3178e506ba 100644
--- a/mm/vm_cgroup.c
+++ b/mm/vm_cgroup.c
@@ -59,30 +59,22 @@ static u64 vm_cgroup_read_u64(struct cgroup_subsys_state *css,
 	return res_counter_read_u64(&vmcg->res, memb);
 }
 
-static ssize_t vm_cgroup_write(struct kernfs_open_file *of,
-			       char *buf, size_t nbytes, loff_t off)
+static int vm_cgroup_write(struct cgroup_subsys_state *css,
+		struct cftype *cft, u64 value)
 {
-	struct vm_cgroup *vmcg = vm_cgroup_from_css(of_css(of));
-	unsigned long long val;
-	int ret;
+	struct vm_cgroup *vmcg = vm_cgroup_from_css(css);
 
 	if (vm_cgroup_is_root(vmcg))
 		return -EINVAL;
 
-	buf = strstrip(buf);
-	ret = res_counter_memparse_write_strategy(buf, &val);
-	if (ret)
-		return ret;
-
-	ret = res_counter_set_limit(&vmcg->res, val);
-	return ret ?: nbytes;
+	return res_counter_set_limit(&vmcg->res, value);
 }
 
-static ssize_t vm_cgroup_reset(struct kernfs_open_file *of, char *buf,
-			       size_t nbytes, loff_t off)
+static int vm_cgroup_reset(struct cgroup_subsys_state *css,
+		struct cftype *cft, u64 value)
 {
-	struct vm_cgroup *vmcg= vm_cgroup_from_css(of_css(of));
-	int memb = of_cft(of)->private;
+	struct vm_cgroup *vmcg= vm_cgroup_from_css(css);
+	int memb = cft->private;
 
 	switch (memb) {
 	case RES_MAX_USAGE:
@@ -94,7 +86,7 @@ static ssize_t vm_cgroup_reset(struct kernfs_open_file *of, char *buf,
 	default:
 		BUG();
 	}
-	return nbytes;
+	return 0;
 }
 
 static struct cftype vm_cgroup_files[] = {
@@ -106,26 +98,28 @@ static struct cftype vm_cgroup_files[] = {
 	{
 		.name = "max_usage_in_bytes",
 		.private = RES_MAX_USAGE,
-		.write = vm_cgroup_reset,
+		.write_u64 = vm_cgroup_reset,
 		.read_u64 = vm_cgroup_read_u64,
 	},
 	{
 		.name = "limit_in_bytes",
 		.private = RES_LIMIT,
-		.write = vm_cgroup_write,
+		.write_u64 = vm_cgroup_write,
 		.read_u64 = vm_cgroup_read_u64,
 	},
 	{
 		.name = "failcnt",
 		.private = RES_FAILCNT,
-		.write = vm_cgroup_reset,
+		.write_u64 = vm_cgroup_reset,
 		.read_u64 = vm_cgroup_read_u64,
 	},
 	{ },	/* terminate */
 };
 
-struct cgroup_subsys vm_cgrp_subsys = {
+struct cgroup_subsys vm_subsys = {
+	.name = "vm",
 	.css_alloc = vm_cgroup_css_alloc,
 	.css_free = vm_cgroup_css_free,
 	.base_cftypes = vm_cgroup_files,
+	.subsys_id = vm_subsys_id,
 };
-- 
1.8.1.2