lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 18 Sep 2011 00:32:27 -0300
From:	Glauber Costa <glommer@...allels.com>
To:	"Kirill A. Shutemov" <kirill@...temov.name>
CC:	<linux-kernel@...r.kernel.org>, <paul@...lmenage.org>,
	<lizf@...fujitsu.com>, <kamezawa.hiroyu@...fujitsu.com>,
	<ebiederm@...ssion.com>, <davem@...emloft.net>,
	<gthelen@...gle.com>, <netdev@...r.kernel.org>,
	<linux-mm@...ck.org>
Subject: Re: [PATCH v2 2/7] socket: initial cgroup code.

On 09/17/2011 02:52 PM, Kirill A. Shutemov wrote:
> On Wed, Sep 14, 2011 at 10:46:10PM -0300, Glauber Costa wrote:
>> We aim to control the amount of kernel memory pinned at any
>> time by tcp sockets. To lay the foundations for this work,
>> this patch adds a pointer to the kmem_cgroup to the socket
>> structure.
>>
>> Signed-off-by: Glauber Costa<glommer@...allels.com>
>> CC: David S. Miller<davem@...emloft.net>
>> CC: Hiroyouki Kamezawa<kamezawa.hiroyu@...fujitsu.com>
>> CC: Eric W. Biederman<ebiederm@...ssion.com>
>> ---
>>   include/linux/memcontrol.h |   38 ++++++++++++++++++++++++++++++++++++++
>>   include/net/sock.h         |    2 ++
>>   net/core/sock.c            |    3 +++
>>   3 files changed, 43 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
>> index 3b535db..be457ce 100644
>> --- a/include/linux/memcontrol.h
>> +++ b/include/linux/memcontrol.h
>> @@ -395,5 +395,43 @@ mem_cgroup_print_bad_page(struct page *page)
>>   }
>>   #endif
>>
>> +#ifdef CONFIG_INET
>> +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM
>> +#include<net/sock.h>
>> +static inline void sock_update_memcg(struct sock *sk)
>> +{
>> +	/* right now a socket spends its whole life in the same cgroup */
>> +	BUG_ON(sk->sk_cgrp);
>> +
>> +	rcu_read_lock();
>> +	sk->sk_cgrp = mem_cgroup_from_task(current);
>> +
>> +	/*
>> +	 * We don't need to protect against anything task-related, because
>> +	 * we are basically stuck with the sock pointer that won't change,
>> +	 * even if the task that originated the socket changes cgroups.
>> +	 *
>> +	 * What we do have to guarantee, is that the chain leading us to
>> +	 * the top level won't change under our noses. Incrementing the
>> +	 * reference count via cgroup_exclude_rmdir guarantees that.
>> +	 */
>> +	cgroup_exclude_rmdir(mem_cgroup_css(sk->sk_cgrp));
>> +	rcu_read_unlock();
>> +}
>> +
>> +static inline void sock_release_memcg(struct sock *sk)
>> +{
>> +	cgroup_release_and_wakeup_rmdir(mem_cgroup_css(sk->sk_cgrp));
>> +}
>
> Do we really need to have these functions in the header?
>
No, I can move it to memcontrol.c

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

Powered by blists - more mailing lists