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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 CCADEC433E0 for ; Thu, 11 Mar 2021 08:56:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78E0164FB1 for ; Thu, 11 Mar 2021 08:56:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231814AbhCKIzm (ORCPT ); Thu, 11 Mar 2021 03:55:42 -0500 Received: from mx2.suse.de ([195.135.220.15]:39160 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231440AbhCKIze (ORCPT ); Thu, 11 Mar 2021 03:55:34 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1615452933; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2w5ANi1macvYiB3pDe4T+IEha3dZ9yAJ5puO2kAQ6Ro=; b=lo3a+pfMdhV6Wh7ucDBmOJEKVOFP3mbkP+QeNwaDcBq24Zk7acF4BUqNrSU+sJNsY9aZJJ UBHU3squ8fz7EZKVUakckTKgd8ForrzC68n1aAr3YS/65BdLXj7+Q9kzJYzrLJ6pfjTvwK aH4yPIpb/Q1IneABSwpG9SWq6v1KTpo= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C0646AC16; Thu, 11 Mar 2021 08:55:32 +0000 (UTC) Date: Thu, 11 Mar 2021 09:55:32 +0100 From: Michal Hocko To: Muchun Song Cc: Jonathan Corbet , Mike Kravetz , Thomas Gleixner , Ingo Molnar , bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, Peter Zijlstra , Alexander Viro , 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 , Oscar Salvador , "Song Bao Hua (Barry Song)" , David Hildenbrand , HORIGUCHI =?utf-8?B?TkFPWUEo5aCA5Y+jIOebtOS5nyk=?= , Joao Martins , Xiongchun duan , linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel , Miaohe Lin , Chen Huang , Bodeddula Balasubramaniam Subject: Re: [External] Re: [PATCH v18 9/9] mm: hugetlb: optimize the code with the help of the compiler Message-ID: References: <20210308102807.59745-1-songmuchun@bytedance.com> <20210308102807.59745-10-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 11-03-21 15:33:20, Muchun Song wrote: > On Wed, Mar 10, 2021 at 11:41 PM Michal Hocko wrote: > > > > On Mon 08-03-21 18:28:07, Muchun Song wrote: > > > When the "struct page size" crosses page boundaries we cannot > > > make use of this feature. Let free_vmemmap_pages_per_hpage() > > > return zero if that is the case, most of the functions can be > > > optimized away. > > > > I am confused. Don't you check for this in early_hugetlb_free_vmemmap_param already? > > Right. > > > Why do we need any runtime checks? > > If the size of the struct page is not power of 2, compiler can think > is_hugetlb_free_vmemmap_enabled() always return false. So > the code snippet of this user can be optimized away. > > E.g. > > if (is_hugetlb_free_vmemmap_enabled()) > /* do something */ > > The compiler can drop "/* do something */" directly, because > it knows is_hugetlb_free_vmemmap_enabled() always returns > false. OK, so this is a micro-optimization to generate a better code? Is this measurable to warrant more code? -- Michal Hocko SUSE Labs