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]
Message-ID: <4E8AA866.3010509@parallels.com>
Date:	Tue, 4 Oct 2011 10:32:06 +0400
From:	Glauber Costa <glommer@...allels.com>
To:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
CC:	<linux-kernel@...r.kernel.org>, <paul@...lmenage.org>,
	<lizf@...fujitsu.com>, <ebiederm@...ssion.com>,
	<davem@...emloft.net>, <gthelen@...gle.com>,
	<netdev@...r.kernel.org>, <linux-mm@...ck.org>,
	<kirill@...temov.name>, <avagin@...allels.com>
Subject: Re: [PATCH v4 3/8] foundations of per-cgroup memory pressure controlling.

On 10/04/2011 04:57 AM, KAMEZAWA Hiroyuki wrote:
> On Mon,  3 Oct 2011 14:18:38 +0400
> Glauber Costa<glommer@...allels.com>  wrote:
>
>> This patch converts struct sock fields memory_pressure,
>> memory_allocated, sockets_allocated, and sysctl_mem (now prot_mem)
>> to function pointers, receiving a struct mem_cgroup parameter.
>>
>> enter_memory_pressure is kept the same, since all its callers
>> have socket a context, and the kmem_cgroup can be derived from
>> the socket itself.
>>
>> To keep things working, the patch convert all users of those fields
>> to use acessor functions.
>>
>> In my benchmarks I didn't see a significant performance difference
>> with this patch applied compared to a baseline (around 1 % diff, thus
>> inside error margin).
>>
>> 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>
>
> A nitpick.
>
>
>>   #ifdef CONFIG_INET
>>   struct sock;
>> +struct proto;
>>   #ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM
>>   void sock_update_memcg(struct sock *sk);
>>   void sock_release_memcg(struct sock *sk);
>> -
>> +void memcg_sock_mem_alloc(struct mem_cgroup *mem, struct proto *prot,
>> +			  int amt, int *parent_failure);
>> +void memcg_sock_mem_free(struct mem_cgroup *mem, struct proto *prot, int amt);
>> +void memcg_sockets_allocated_dec(struct mem_cgroup *mem, struct proto *prot);
>> +void memcg_sockets_allocated_inc(struct mem_cgroup *mem, struct proto *prot);
>>   #else
>> +/* memcontrol includes sockets.h, that includes memcontrol.h ... */
>> +static inline void memcg_sock_mem_alloc(struct mem_cgroup *mem,
>> +					struct proto *prot, int amt,
>> +					int *parent_failure)
>> +{
>> +}
>
> In these days, at naming memory cgroup pointers, we use "memcg" instead of
> "mem". So, could you use "memcg" for represeinting memory cgroup ?
>
>
>> +
>> +void memcg_sock_mem_alloc(struct mem_cgroup *mem, struct proto *prot,
>> +			  int amt, int *parent_failure)
>> +{
>> +	mem = parent_mem_cgroup(mem);
>> +	for (; mem != NULL; mem = parent_mem_cgroup(mem)) {
>> +		long alloc;
>> +		long *prot_mem = prot->prot_mem(mem);
>> +		/*
>> +		 * Large nestings are not the common case, and stopping in the
>> +		 * middle would be complicated enough, that we bill it all the
>> +		 * way through the root, and if needed, unbill everything later
>> +		 */
>> +		alloc = atomic_long_add_return(amt,
>> +					       prot->memory_allocated(mem));
>> +		*parent_failure |= (alloc>  prot_mem[2]);
>> +	}
>> +}
>> +EXPORT_SYMBOL(memcg_sock_mem_alloc);
>
> Hmm. why not using res_counter ? for reusing 'unbill' code ?
>
Well,

res_counters are slightly more expensive than needed here, since we need 
to clear interrupts and hold a spinlock. No particular reason besides it.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ