From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755468AbcGTVgG (ORCPT ); Wed, 20 Jul 2016 17:36:06 -0400 Received: from mga14.intel.com ([192.55.52.115]:32586 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753633AbcGTVgF (ORCPT ); Wed, 20 Jul 2016 17:36:05 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,396,1464678000"; d="scan'208";a="850175421" Subject: Re: [PATCH] make __section_nr more efficient To: Zhou Chengming , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <1468988310-11560-1-git-send-email-zhouchengming1@huawei.com> Cc: akpm@linux-foundation.org, tj@kernel.org, guohanjun@huawei.com, huawei.libin@huawei.com From: Dave Hansen Message-ID: <578FEEC4.9060209@intel.com> Date: Wed, 20 Jul 2016 14:36:04 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <1468988310-11560-1-git-send-email-zhouchengming1@huawei.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/19/2016 09:18 PM, Zhou Chengming wrote: > When CONFIG_SPARSEMEM_EXTREME is disabled, __section_nr can get > the section number with a subtraction directly. Does this actually *do* anything? It was a long time ago, but if I remember correctly, the entire loop in __section_nr() goes away because root_nr==NR_SECTION_ROOTS, so root_nr=1, and the compiler optimizes away the entire subtraction. So this basically adds an #ifdef and gets us nothing, although it makes the situation much more explicit. Perhaps the comment should say that this works *and* is efficient because the compiler can optimize all the extreme complexity away.