From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754251Ab1LIOs4 (ORCPT ); Fri, 9 Dec 2011 09:48:56 -0500 Received: from mx2.parallels.com ([64.131.90.16]:48535 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752158Ab1LIOsy (ORCPT ); Fri, 9 Dec 2011 09:48:54 -0500 Message-ID: <4EE21FB0.5090006@parallels.com> Date: Fri, 9 Dec 2011 12:48:16 -0200 From: Glauber Costa User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20110927 Thunderbird/7.0 MIME-Version: 1.0 To: David Laight CC: KAMEZAWA Hiroyuki , , , , , , , , , , , , , , , Paul Menage Subject: Re: [PATCH v8 1/9] Basic kernel memory functionality for the Memory Controller References: In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [201.82.130.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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@kvack.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: email@kvack.org