From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754453Ab1LIOpB (ORCPT ); Fri, 9 Dec 2011 09:45:01 -0500 Received: from mx0.aculab.com ([213.249.233.131]:50373 "HELO mx0.aculab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754005Ab1LIOo7 convert rfc822-to-8bit (ORCPT ); Fri, 9 Dec 2011 09:44:59 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT Subject: RE: [PATCH v8 1/9] Basic kernel memory functionality for the Memory Controller Date: Fri, 9 Dec 2011 14:44:45 -0000 Message-ID: In-Reply-To: <4EE21D23.4000309@parallels.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v8 1/9] Basic kernel memory functionality for the Memory Controller Thread-Index: Acy2gEs9H2EJ/4kgRB+dTyn5866RcQAAEu8A From: "David Laight" To: "Glauber Costa" , "KAMEZAWA Hiroyuki" Cc: , , , , , , , , , , , , , , "Paul Menage" X-OriginalArrivalTime: 09 Dec 2011 14:44:45.0970 (UTC) FILETIME=[182F6F20:01CCB681] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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; NFI about the logic... On the face of it the tests don't seem related to each other or to the assignment! David