From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BC0AC433FE for ; Thu, 10 Dec 2020 13:16:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7F27223DE8 for ; Thu, 10 Dec 2020 13:16:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F27223DE8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 98D1D6B0036; Thu, 10 Dec 2020 08:16:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 916D56B005D; Thu, 10 Dec 2020 08:16:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DFD46B0068; Thu, 10 Dec 2020 08:16:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0128.hostedemail.com [216.40.44.128]) by kanga.kvack.org (Postfix) with ESMTP id 6512B6B0036 for ; Thu, 10 Dec 2020 08:16:15 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 242E7181AEF2A for ; Thu, 10 Dec 2020 13:16:15 +0000 (UTC) X-FDA: 77577421110.12.news33_3b144f8273f8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id F1F0F18056270 for ; Thu, 10 Dec 2020 13:16:14 +0000 (UTC) X-HE-Tag: news33_3b144f8273f8 X-Filterd-Recvd-Size: 2810 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Dec 2020 13:16:14 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 17C02AB91; Thu, 10 Dec 2020 13:16:13 +0000 (UTC) Date: Thu, 10 Dec 2020 14:16:08 +0100 From: Oscar Salvador To: Muchun Song Cc: Jonathan Corbet , Mike Kravetz , Thomas Gleixner , mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, Peter Zijlstra , viro@zeniv.linux.org.uk, Andrew Morton , paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, Randy Dunlap , oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, Mina Almasry , David Rientjes , Matthew Wilcox , Michal Hocko , "Song Bao Hua (Barry Song)" , David Hildenbrand , Xiongchun duan , linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel Subject: Re: [External] Re: [PATCH v8 12/12] mm/hugetlb: Optimize the code with the help of the compiler Message-ID: <20201210131608.GA7811@localhost.localdomain> References: <20201210035526.38938-1-songmuchun@bytedance.com> <20201210035526.38938-13-songmuchun@bytedance.com> <375d6bad6bb37e3626f71bfabc20b384@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Dec 10, 2020 at 08:14:18PM +0800, Muchun Song wrote: > Yeah, you are right. But if we do this check can make the code simple. > > For example, here is a code snippet. > > void func(void) > { > if (free_vmemmap_pages_per_hpage()) > return; > /* Do something */ > } > > With this patch, the func will be optimized to null when is_power_of_2 > returns false. > > void func(void) > { > } > > Without this patch, the compiler cannot do this optimization. Ok, I misread the changelog. So, then is_hugetlb_free_vmemmap_enabled, free_huge_page_vmemmap, free_vmemmap_pages_per_hpage and hugetlb_vmemmap_init are optimized out, right? -- Oscar Salvador SUSE L3