Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755889Ab2F0JmR (ORCPT ); Wed, 27 Jun 2012 05:42:17 -0400 Received: from gir.skynet.ie ([193.1.99.77]:42846 "EHLO gir.skynet.ie" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753538Ab2F0JmQ (ORCPT ); Wed, 27 Jun 2012 05:42:16 -0400 Date: Wed, 27 Jun 2012 10:42:13 +0100 From: Mel Gorman To: Andi Kleen Cc: Rafael Aquini , linux-mm@kvack.org, Rik van Riel , "Michael S. Tsirkin" , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH 1/4] mm: introduce compaction and migration for virtio ballooned pages Message-ID: <20120627094213.GK8103@csn.ul.ie> References: <7f83427b3894af7969c67acc0f27ab5aa68b4279.1340665087.git.aquini@redhat.com> <20120626101729.GF8103@csn.ul.ie> <20120626165258.GY11413@one.firstfloor.org> <20120626201513.GJ8103@csn.ul.ie> <20120626203400.GA11413@one.firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20120626203400.GA11413@one.firstfloor.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2165 Lines: 55 On Tue, Jun 26, 2012 at 10:34:00PM +0200, Andi Kleen wrote: > > How is the compiler meant to optimise away "cond" if it's a function > > call? > > Inlines can be optimized away. These tests are usually inlines. > > > What did I miss? If nothing, then I will revert this particular change > > and Rafael will need to be sure his patch is not using VM_BUG_ON to call > > a function with side-effects. > > Do you have an example where the code is actually different, > or are you just speculating? > > FWIW for my config both generates the same code: > > size vmlinux-andi-vmbug vmlinux-vmbug-nothing > text data bss dec hex filename > 11809704 1457352 1159168 14426224 dc2070 vmlinux-andi-vmbug > 11809704 1457352 1159168 14426224 dc2070 vmlinux-vmbug-nothing > They are the same size because CONFIG_DEBUG_VM and !CONFIG_DEBUG_VM generate the same code! I applied the patch below again 3.4 and got the following results text data bss dec hex filename 6918617 1795640 2260992 10975249 a77811 vmlinux-default-no-vmdebug 6916633 1795640 2260992 10973265 a77051 vmlinux-patched-no-vmdebug That's almost 2K of text! I see now that in 3.5 this was already spotted and fixed by Konstantin in commit [02602a18: bug: completely remove code generated by disabled VM_BUG_ON()]. That patch restores the rule that VM_BUG_ON() cannot call anything with side-effects. So Rafael, watch your use of VM_BUG_ON or you'll find that the your patches work in 3.4 and leak in 3.5. diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h index c04ecfe..ee24ef8 100644 --- a/include/linux/mmdebug.h +++ b/include/linux/mmdebug.h @@ -4,7 +4,7 @@ #ifdef CONFIG_DEBUG_VM #define VM_BUG_ON(cond) BUG_ON(cond) #else -#define VM_BUG_ON(cond) do { (void)(cond); } while (0) +#define VM_BUG_ON(cond) do { } while (0) #endif #ifdef CONFIG_DEBUG_VIRTUAL -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/