From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933216Ab3HNVHE (ORCPT ); Wed, 14 Aug 2013 17:07:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55222 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933137Ab3HNVHD (ORCPT ); Wed, 14 Aug 2013 17:07:03 -0400 Date: Wed, 14 Aug 2013 14:07:00 -0700 From: Andrew Morton To: Tejun Heo Cc: Chris Metcalf , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Thomas Gleixner , Frederic Weisbecker , Cody P Schafer Subject: Re: [PATCH v8] mm: make lru_add_drain_all() selective Message-Id: <20130814140700.5fee193b193a529e72fa5a37@linux-foundation.org> In-Reply-To: <20130814205029.GN28628@htj.dyndns.org> References: <20130814200748.GI28628@htj.dyndns.org> <201308142029.r7EKTMRw023404@farm-0002.internal.tilera.com> <20130814134430.50cb8d609643620b00ab3705@linux-foundation.org> <20130814205029.GN28628@htj.dyndns.org> X-Mailer: Sylpheed 3.2.0beta5 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 14 Aug 2013 16:50:29 -0400 Tejun Heo wrote: > On Wed, Aug 14, 2013 at 01:44:30PM -0700, Andrew Morton wrote: > > > +static bool need_activate_page_drain(int cpu) > > > +{ > > > + return pagevec_count(&per_cpu(activate_page_pvecs, cpu)) != 0; > > > +} > > > > static int need_activate_page_drain(int cpu) > > { > > return pagevec_count(&per_cpu(activate_page_pvecs, cpu)); > > } > > > > would be shorter and faster. bool rather sucks that way. It's a > > performance-vs-niceness thing. I guess one has to look at the call > > frequency when deciding. > > "!= 0" can be dropped but I'm fairly sure the compiler would be able > to figure out that the type conversion can be skipped. It's a trivial > optimization. The != 0 can surely be removed and that shouldn't make any difference to generated code. The compiler will always need to do the int-to-bool conversion and that's overhead which is added by using bool. It's possible that the compiler will optmise away the int-to-bool conversion when inlining this function into a callsite. I don't know whether the compiler _does_ do this and it will be version dependent. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx156.postini.com [74.125.245.156]) by kanga.kvack.org (Postfix) with SMTP id 3BF0B6B0033 for ; Wed, 14 Aug 2013 17:07:03 -0400 (EDT) Date: Wed, 14 Aug 2013 14:07:00 -0700 From: Andrew Morton Subject: Re: [PATCH v8] mm: make lru_add_drain_all() selective Message-Id: <20130814140700.5fee193b193a529e72fa5a37@linux-foundation.org> In-Reply-To: <20130814205029.GN28628@htj.dyndns.org> References: <20130814200748.GI28628@htj.dyndns.org> <201308142029.r7EKTMRw023404@farm-0002.internal.tilera.com> <20130814134430.50cb8d609643620b00ab3705@linux-foundation.org> <20130814205029.GN28628@htj.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Tejun Heo Cc: Chris Metcalf , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Thomas Gleixner , Frederic Weisbecker , Cody P Schafer On Wed, 14 Aug 2013 16:50:29 -0400 Tejun Heo wrote: > On Wed, Aug 14, 2013 at 01:44:30PM -0700, Andrew Morton wrote: > > > +static bool need_activate_page_drain(int cpu) > > > +{ > > > + return pagevec_count(&per_cpu(activate_page_pvecs, cpu)) != 0; > > > +} > > > > static int need_activate_page_drain(int cpu) > > { > > return pagevec_count(&per_cpu(activate_page_pvecs, cpu)); > > } > > > > would be shorter and faster. bool rather sucks that way. It's a > > performance-vs-niceness thing. I guess one has to look at the call > > frequency when deciding. > > "!= 0" can be dropped but I'm fairly sure the compiler would be able > to figure out that the type conversion can be skipped. It's a trivial > optimization. The != 0 can surely be removed and that shouldn't make any difference to generated code. The compiler will always need to do the int-to-bool conversion and that's overhead which is added by using bool. It's possible that the compiler will optmise away the int-to-bool conversion when inlining this function into a callsite. I don't know whether the compiler _does_ do this and it will be version dependent. -- 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/ . Don't email: email@kvack.org