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,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 1BEE2C433E0 for ; Thu, 11 Mar 2021 09:09:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 73B8664DEC for ; Thu, 11 Mar 2021 09:09:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73B8664DEC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DA0BE8D029F; Thu, 11 Mar 2021 04:09:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D505B8D028E; Thu, 11 Mar 2021 04:09:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA2AB8D029F; Thu, 11 Mar 2021 04:09:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9B09C8D028E for ; Thu, 11 Mar 2021 04:09:15 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 62596824999B for ; Thu, 11 Mar 2021 09:09:15 +0000 (UTC) X-FDA: 77907019470.11.9495196 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by imf06.hostedemail.com (Postfix) with ESMTP id 18F5BC0007CA for ; Thu, 11 Mar 2021 09:09:13 +0000 (UTC) Received: by mail-pg1-f179.google.com with SMTP id t26so13277598pgv.3 for ; Thu, 11 Mar 2021 01:09:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mCTW04T6FDAWe0y3Y8uvQz02hfd4dMHzD/jXKV5ni0E=; b=Y/r8l2GZWPIzxtFqFbqp+HB+jA7JeWZF1hQD73NXfYnjF7SBJAfx7VeoK/MbgtuJ+U /nBBJotqN2Mf403kEiXPK8qB0HtHD4oVOQdAxqrVeKM/nu+s/VuXYV2gBCN4W6HX8uUd vrlV2K+JzGTmxQ8VNsMRMYR0xV1FySxGdV/tAsHBP6a9Xyqf59Dr/rvMS/pCQ+oMIKrm id/jvwgp6/1c/a6VOGgI7xfYp90v/9KaF9LCFSevI00Yja48jSe7n/pfx2xds0CdvsS8 VdmbKG4CLJuM6nK+lyVt5r5YTVtHvHQzI+p8VOlhWeuwc9FCEFFJLYVMrFQUcSzY1eiQ 0vrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mCTW04T6FDAWe0y3Y8uvQz02hfd4dMHzD/jXKV5ni0E=; b=lx0fGjp+IGKdMtY8ZiwBuxx2x8ELv1OLMH5ssoOLxmzBu6D+BKYoUzKczi/EaA8AS2 B/51rFlwUGviR3pGdLinLJfV2kCQixGKic2O97oevEq7nR6uhEcSkcSYn8UrwGdl8PAO WpfiUgBqLAy3cujPalCRbHOYBOfBBWhGOoOZkUVoRXauMJsA5eAsWBiBjCDN6+yFbgVQ BCWFtRPL0HaLFxad3rWMgXMTqUV27dsobKQf8MI2VqMOQYqVJN7+kT9lGThddHo8WuBL 2cPMsagnmnmNI1UOjM23T/ndjEhXkcABzCXQbBpzxuKGkNkFdDHudQeAVMj+Wx/43CsH 7N7Q== X-Gm-Message-State: AOAM532E8CPdB/p+aJaDclmdkzG5PBQnqGgpJtjdrEy1xVg0Yf5s5W+2 b1/1Xy1YxX0PC45cYyYazbfUpJr4sFDFMziywDGtJg== X-Google-Smtp-Source: ABdhPJy8F/wYop3dZx7C28eOxSytt+4LbTA89Xyq6VmeWP+d2mbk9yMNhz3RbMDYqCmWI6x0q8mz5dNpU7Fue42Xc3E= X-Received: by 2002:aa7:910c:0:b029:1ed:ef1:81b with SMTP id 12-20020aa7910c0000b02901ed0ef1081bmr6861804pfh.49.1615453752720; Thu, 11 Mar 2021 01:09:12 -0800 (PST) MIME-Version: 1.0 References: <20210308102807.59745-1-songmuchun@bytedance.com> <20210308102807.59745-10-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Thu, 11 Mar 2021 17:08:34 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v18 9/9] mm: hugetlb: optimize the code with the help of the compiler To: Michal Hocko 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 , =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , Joao Martins , Xiongchun duan , linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel , Miaohe Lin , Chen Huang , Bodeddula Balasubramaniam Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: jzxzdexrf4zaonhyrir8bkbtm8jergmy X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 18F5BC0007CA Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=mail-pg1-f179.google.com; client-ip=209.85.215.179 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615453753-531378 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, Mar 11, 2021 at 4:55 PM Michal Hocko wrote: > > 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? Right. > Is this measurable to warrant more code? I have disassembled the code to confirm this behavior. I know this is not the hot path. But it actually can decrease the code size. Thanks. > -- > Michal Hocko > SUSE Labs