aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-21 15:32:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-21 15:32:08 -0500
commiteae21770b4fed5597623aad0d618190fa60426ff (patch)
tree23c59fb7a33e93a79525e2b10d56df54d40049d1 /net
parente9f57ebcba563e0cd532926cab83c92bb4d79360 (diff)
parent9f273c24ec5f4a6f785bb83e931b3808a07b459e (diff)
Merge branch 'akpm' (patches from Andrew)
Merge third patch-bomb from Andrew Morton: "I'm pretty much done for -rc1 now: - the rest of MM, basically - lib/ updates - checkpatch, epoll, hfs, fatfs, ptrace, coredump, exit - cpu_mask simplifications - kexec, rapidio, MAINTAINERS etc, etc. - more dma-mapping cleanups/simplifications from hch" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (109 commits) MAINTAINERS: add/fix git URLs for various subsystems mm: memcontrol: add "sock" to cgroup2 memory.stat mm: memcontrol: basic memory statistics in cgroup2 memory controller mm: memcontrol: do not uncharge old page in page cache replacement Documentation: cgroup: add memory.swap.{current,max} description mm: free swap cache aggressively if memcg swap is full mm: vmscan: do not scan anon pages if memcg swap limit is hit swap.h: move memcg related stuff to the end of the file mm: memcontrol: replace mem_cgroup_lruvec_online with mem_cgroup_online mm: vmscan: pass memcg to get_scan_count() mm: memcontrol: charge swap to cgroup2 mm: memcontrol: clean up alloc, online, offline, free functions mm: memcontrol: flatten struct cg_proto mm: memcontrol: rein in the CONFIG space madness net: drop tcp_memcontrol.c mm: memcontrol: introduce CONFIG_MEMCG_LEGACY_KMEM mm: memcontrol: allow to disable kmem accounting for cgroup2 mm: memcontrol: account "kmem" consumers in cgroup2 memory controller mm: memcontrol: move kmem accounting code to CONFIG_MEMCG mm: memcontrol: separate kmem code from legacy tcp accounting code ...
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/Makefile1
-rw-r--r--net/ipv4/sysctl_net_ipv4.c1
-rw-r--r--net/ipv4/tcp_ipv4.c1
-rw-r--r--net/ipv4/tcp_memcontrol.c200
-rw-r--r--net/ipv6/tcp_ipv6.c1
-rw-r--r--net/mac80211/debugfs.c7
6 files changed, 2 insertions, 209 deletions
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index c29809f765dc..62c049b647e9 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -56,7 +56,6 @@ obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o
56obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o 56obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o
57obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o 57obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o
58obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o 58obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o
59obj-$(CONFIG_MEMCG_KMEM) += tcp_memcontrol.o
60obj-$(CONFIG_NETLABEL) += cipso_ipv4.o 59obj-$(CONFIG_NETLABEL) += cipso_ipv4.o
61 60
62obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \ 61obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 46ce410703b1..4d367b4139a3 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -24,7 +24,6 @@
24#include <net/cipso_ipv4.h> 24#include <net/cipso_ipv4.h>
25#include <net/inet_frag.h> 25#include <net/inet_frag.h>
26#include <net/ping.h> 26#include <net/ping.h>
27#include <net/tcp_memcontrol.h>
28 27
29static int zero; 28static int zero;
30static int one = 1; 29static int one = 1;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index c7d1fb50f381..5ced3e4013e3 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -73,7 +73,6 @@
73#include <net/timewait_sock.h> 73#include <net/timewait_sock.h>
74#include <net/xfrm.h> 74#include <net/xfrm.h>
75#include <net/secure_seq.h> 75#include <net/secure_seq.h>
76#include <net/tcp_memcontrol.h>
77#include <net/busy_poll.h> 76#include <net/busy_poll.h>
78 77
79#include <linux/inet.h> 78#include <linux/inet.h>
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c
deleted file mode 100644
index 18bc7f745e9c..000000000000
--- a/net/ipv4/tcp_memcontrol.c
+++ /dev/null
@@ -1,200 +0,0 @@
1#include <net/tcp.h>
2#include <net/tcp_memcontrol.h>
3#include <net/sock.h>
4#include <net/ip.h>
5#include <linux/nsproxy.h>
6#include <linux/memcontrol.h>
7#include <linux/module.h>
8
9int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
10{
11 struct mem_cgroup *parent = parent_mem_cgroup(memcg);
12 struct page_counter *counter_parent = NULL;
13 /*
14 * The root cgroup does not use page_counters, but rather,
15 * rely on the data already collected by the network
16 * subsystem
17 */
18 if (memcg == root_mem_cgroup)
19 return 0;
20
21 memcg->tcp_mem.memory_pressure = 0;
22
23 if (parent)
24 counter_parent = &parent->tcp_mem.memory_allocated;
25
26 page_counter_init(&memcg->tcp_mem.memory_allocated, counter_parent);
27
28 return 0;
29}
30
31void tcp_destroy_cgroup(struct mem_cgroup *memcg)
32{
33 if (memcg == root_mem_cgroup)
34 return;
35
36 if (memcg->tcp_mem.active)
37 static_branch_dec(&memcg_sockets_enabled_key);
38}
39
40static int tcp_update_limit(struct mem_cgroup *memcg, unsigned long nr_pages)
41{
42 int ret;
43
44 if (memcg == root_mem_cgroup)
45 return -EINVAL;
46
47 ret = page_counter_limit(&memcg->tcp_mem.memory_allocated, nr_pages);
48 if (ret)
49 return ret;
50
51 if (!memcg->tcp_mem.active) {
52 /*
53 * The active flag needs to be written after the static_key
54 * update. This is what guarantees that the socket activation
55 * function is the last one to run. See sock_update_memcg() for
56 * details, and note that we don't mark any socket as belonging
57 * to this memcg until that flag is up.
58 *
59 * We need to do this, because static_keys will span multiple
60 * sites, but we can't control their order. If we mark a socket
61 * as accounted, but the accounting functions are not patched in
62 * yet, we'll lose accounting.
63 *
64 * We never race with the readers in sock_update_memcg(),
65 * because when this value change, the code to process it is not
66 * patched in yet.
67 */
68 static_branch_inc(&memcg_sockets_enabled_key);
69 memcg->tcp_mem.active = true;
70 }
71
72 return 0;
73}
74
75enum {
76 RES_USAGE,
77 RES_LIMIT,
78 RES_MAX_USAGE,
79 RES_FAILCNT,
80};
81
82static DEFINE_MUTEX(tcp_limit_mutex);
83
84static ssize_t tcp_cgroup_write(struct kernfs_open_file *of,
85 char *buf, size_t nbytes, loff_t off)
86{
87 struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
88 unsigned long nr_pages;
89 int ret = 0;
90
91 buf = strstrip(buf);
92
93 switch (of_cft(of)->private) {
94 case RES_LIMIT:
95 /* see memcontrol.c */
96 ret = page_counter_memparse(buf, "-1", &nr_pages);
97 if (ret)
98 break;
99 mutex_lock(&tcp_limit_mutex);
100 ret = tcp_update_limit(memcg, nr_pages);
101 mutex_unlock(&tcp_limit_mutex);
102 break;
103 default:
104 ret = -EINVAL;
105 break;
106 }
107 return ret ?: nbytes;
108}
109
110static u64 tcp_cgroup_read(struct cgroup_subsys_state *css, struct cftype *cft)
111{
112 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
113 u64 val;
114
115 switch (cft->private) {
116 case RES_LIMIT:
117 if (memcg == root_mem_cgroup)
118 val = PAGE_COUNTER_MAX;
119 else
120 val = memcg->tcp_mem.memory_allocated.limit;
121 val *= PAGE_SIZE;
122 break;
123 case RES_USAGE:
124 if (memcg == root_mem_cgroup)
125 val = atomic_long_read(&tcp_memory_allocated);
126 else
127 val = page_counter_read(&memcg->tcp_mem.memory_allocated);
128 val *= PAGE_SIZE;
129 break;
130 case RES_FAILCNT:
131 if (memcg == root_mem_cgroup)
132 return 0;
133 val = memcg->tcp_mem.memory_allocated.failcnt;
134 break;
135 case RES_MAX_USAGE:
136 if (memcg == root_mem_cgroup)
137 return 0;
138 val = memcg->tcp_mem.memory_allocated.watermark;
139 val *= PAGE_SIZE;
140 break;
141 default:
142 BUG();
143 }
144 return val;
145}
146
147static ssize_t tcp_cgroup_reset(struct kernfs_open_file *of,
148 char *buf, size_t nbytes, loff_t off)
149{
150 struct mem_cgroup *memcg;
151
152 memcg = mem_cgroup_from_css(of_css(of));
153 if (memcg == root_mem_cgroup)
154 return nbytes;
155
156 switch (of_cft(of)->private) {
157 case RES_MAX_USAGE:
158 page_counter_reset_watermark(&memcg->tcp_mem.memory_allocated);
159 break;
160 case RES_FAILCNT:
161 memcg->tcp_mem.memory_allocated.failcnt = 0;
162 break;
163 }
164
165 return nbytes;
166}
167
168static struct cftype tcp_files[] = {
169 {
170 .name = "kmem.tcp.limit_in_bytes",
171 .write = tcp_cgroup_write,
172 .read_u64 = tcp_cgroup_read,
173 .private = RES_LIMIT,
174 },
175 {
176 .name = "kmem.tcp.usage_in_bytes",
177 .read_u64 = tcp_cgroup_read,
178 .private = RES_USAGE,
179 },
180 {
181 .name = "kmem.tcp.failcnt",
182 .private = RES_FAILCNT,
183 .write = tcp_cgroup_reset,
184 .read_u64 = tcp_cgroup_read,
185 },
186 {
187 .name = "kmem.tcp.max_usage_in_bytes",
188 .private = RES_MAX_USAGE,
189 .write = tcp_cgroup_reset,
190 .read_u64 = tcp_cgroup_read,
191 },
192 { } /* terminate */
193};
194
195static int __init tcp_memcontrol_init(void)
196{
197 WARN_ON(cgroup_add_legacy_cftypes(&memory_cgrp_subsys, tcp_files));
198 return 0;
199}
200__initcall(tcp_memcontrol_init);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 4ad8edb46f7c..006396e31cb0 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -61,7 +61,6 @@
61#include <net/timewait_sock.h> 61#include <net/timewait_sock.h>
62#include <net/inet_common.h> 62#include <net/inet_common.h>
63#include <net/secure_seq.h> 63#include <net/secure_seq.h>
64#include <net/tcp_memcontrol.h>
65#include <net/busy_poll.h> 64#include <net/busy_poll.h>
66 65
67#include <linux/proc_fs.h> 66#include <linux/proc_fs.h>
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index abbdff03ce92..3e24d0ddb51b 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -91,7 +91,7 @@ static const struct file_operations reset_ops = {
91}; 91};
92#endif 92#endif
93 93
94static const char *hw_flag_names[NUM_IEEE80211_HW_FLAGS + 1] = { 94static const char *hw_flag_names[] = {
95#define FLAG(F) [IEEE80211_HW_##F] = #F 95#define FLAG(F) [IEEE80211_HW_##F] = #F
96 FLAG(HAS_RATE_CONTROL), 96 FLAG(HAS_RATE_CONTROL),
97 FLAG(RX_INCLUDES_FCS), 97 FLAG(RX_INCLUDES_FCS),
@@ -126,9 +126,6 @@ static const char *hw_flag_names[NUM_IEEE80211_HW_FLAGS + 1] = {
126 FLAG(SUPPORTS_AMSDU_IN_AMPDU), 126 FLAG(SUPPORTS_AMSDU_IN_AMPDU),
127 FLAG(BEACON_TX_STATUS), 127 FLAG(BEACON_TX_STATUS),
128 FLAG(NEEDS_UNIQUE_STA_ADDR), 128 FLAG(NEEDS_UNIQUE_STA_ADDR),
129
130 /* keep last for the build bug below */
131 (void *)0x1
132#undef FLAG 129#undef FLAG
133}; 130};
134 131
@@ -148,7 +145,7 @@ static ssize_t hwflags_read(struct file *file, char __user *user_buf,
148 /* fail compilation if somebody adds or removes 145 /* fail compilation if somebody adds or removes
149 * a flag without updating the name array above 146 * a flag without updating the name array above
150 */ 147 */
151 BUILD_BUG_ON(hw_flag_names[NUM_IEEE80211_HW_FLAGS] != (void *)0x1); 148 BUILD_BUG_ON(ARRAY_SIZE(hw_flag_names) != NUM_IEEE80211_HW_FLAGS);
152 149
153 for (i = 0; i < NUM_IEEE80211_HW_FLAGS; i++) { 150 for (i = 0; i < NUM_IEEE80211_HW_FLAGS; i++) {
154 if (test_bit(i, local->hw.flags)) 151 if (test_bit(i, local->hw.flags))