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  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:	Fri, 9 Dec 2011 12:48:16 -0200
From:	Glauber Costa <glommer@...allels.com>
To:	David Laight <David.Laight@...LAB.COM>
CC:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
	<linux-kernel@...r.kernel.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>, <devel@...nvz.org>,
	<eric.dumazet@...il.com>, <cgroups@...r.kernel.org>,
	<hannes@...xchg.org>, <mhocko@...e.cz>,
	Paul Menage <paul@...lmenage.org>
Subject: Re: [PATCH v8 1/9] Basic kernel memory functionality for the Memory
 Controller

On 12/09/2011 12:44 PM, David Laight wrote:
>
>> How about this?
>>
>>           val = !!val;
>>
>>           /*
>>            * This follows the same hierarchy restrictions than
>>            * mem_cgroup_hierarchy_write()
>>            */
>>           if (!parent || !parent->use_hierarchy) {
>>                   if (list_empty(&cgroup->children))
>>                           memcg->kmem_independent_accounting = val;
>>                   else
>>                           return -EBUSY;
>>           }
>>           else
>>                   return -EINVAL;
>>
>>           return 0;
>
> Inverting the tests gives easier to read code:
>
> 	if (parent&&  parent->user_hierarchy)
> 		return -EINVAL;
> 	if (!list_empty(&cgroup->children))
> 		return -EBUSY;
> 	memcg->kmem_independent_accounting = val != 0;
> 	return 0;

On the other hand, inconsistent with mem_cgroup_hierarchy_write(), which 
applies the logic in the same way I did here.

> NFI about the logic...
> On the face of it the tests don't seem related to each other
> or to the assignment!

How so?

If parent's use_hierarchy is set, we can't set this value (we need to 
have a parent for that to even matter).

We also can't set it if we already have any children - otherwise all the 
on-the-fly adjustments become hell-on-earth.

As for = val != 0, sorry, but I completely disagree this is easier than 
!!val. Not to mention the !!val notation is already pretty widespread in 
the kernel.

> 	David
>
> 	
>
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@...ck.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
> Don't email:<a href=ilto:"dont@...ck.org">  email@...ck.org</a>

--
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