Re: [PATCH v3 4/7] per-cgroup tcp buffers control

From: Glauber Costa
Date: Mon Sep 26 2011 - 18:53:11 EST


On 09/26/2011 11:39 AM, Andrew Vagin wrote:
We can't change net.ipv4.tcp_mem if a cgroup with memory controller
isn't mounted.

[root@dhcp-10-30-20-19 ~]# sysctl -w net.ipv4.tcp_mem="3 2 3"
error: "Invalid argument" setting key "net.ipv4.tcp_mem"

It's because tcp_max_memory is initialized in mem_cgroup_populate:

mem_cgroup_populate->register_kmem_files->sockets_populate->tcp_init_cgroup

Thank you, will fix it

+int sockets_populate(struct cgroup *cgrp, struct cgroup_subsys *ss)
+{
+ struct proto *proto;
+ int ret = 0;
+
+ read_lock(&proto_list_lock);
+ list_for_each_entry(proto,&proto_list, node) {
+ if (proto->init_cgroup)
+ ret |= proto->init_cgroup(proto, cgrp, ss);
+ }
+ if (!ret)
+ goto out;
+
+ list_for_each_entry_continue_reverse(proto,&proto_list, node)
+ if (proto->destroy_cgroup)
+ proto->destroy_cgroup(proto, cgrp, ss);
+
+out:
+ read_unlock(&proto_list_lock);
+ return ret;
+}

@@ -198,6 +203,21 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
if (ret)
return ret;

+#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM
+ rcu_read_lock();
+ cg = mem_cgroup_from_task(current);
+ for (i = 0; i< 3; i++)
+ if (vec[i]> tcp_max_memory(cg)) {
+ rcu_read_unlock();
+ return -EINVAL;
+ }


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/