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.7 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 CEFE1C4361B for ; Thu, 10 Dec 2020 12:33:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89D1323B26 for ; Thu, 10 Dec 2020 12:33:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727221AbgLJMd3 (ORCPT ); Thu, 10 Dec 2020 07:33:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726439AbgLJMdX (ORCPT ); Thu, 10 Dec 2020 07:33:23 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86441C061793 for ; Thu, 10 Dec 2020 04:32:43 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id w4so4054741pgg.13 for ; Thu, 10 Dec 2020 04:32:43 -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=l2j9oJVLdw2ETVRjvlsUKZFYNsqLIEckkbStxyUbG4c=; b=Cf6GkzyVICZ2r+cphcXwh9MH72pN7NwUnmwu484SPDfOCSkIX7b16iRZS+XGbb0J9V ogHDXhnYLhGBT0lXSBZjMp/7JnxpPxncVqbvvGDSe2Yt7XZPb2/XdTar+rZ9E2dmC9gS fQH4+CLKK5F3vRAi+ixzmAIpBewwZZwKxPJom1P5o15wG7DUVUire3Az2R1rppKXtouM GO8fBMD+6tkECDO2+6w4HSxn705fER+7axAKl50N1I9U/c55lRj8rxuNS49h74n9EQiK KSQGY4SiMnuQb5zYN2yW3RKKa8RykPQTPPDWNy/ULPShCy1tFlsEejugZK4buXEFHUjh PReQ== 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=l2j9oJVLdw2ETVRjvlsUKZFYNsqLIEckkbStxyUbG4c=; b=L/ajpMdHlhj14J1/m5qYy4UA+vhed+AjUdOResn/aSdgHBgMbTUxqsRRRLtYqxyJyy cYUxwM18NlzPtmKCpyFoU/18VvlFn388zyd4athLgPInkClYtqpX9KNHoaCdGXJoy9sk LmcZPFJUKKFj0YLa+bEQtWa70BfEPdGi50df17HzyW9gQaC3B0WPiu/FUTgrOyzyTyo9 994Ri4xfzWsx+ftaDFT30VM8mnDblB+x4gDNEkCJXsaf+FvoOyj1ZdLkWS+XTOVEEv1h 9v0pEGqTHDwlFllEEu1ypnZA+FzD4IbeW1YymHd4rFIpvH809tLYFoSikg7YK2rTWFoM J6Fw== X-Gm-Message-State: AOAM532+aVR37sNhFYfvN84eDChWnumpOhwdmnAKokPAsAKbQXpUkeRk eF2wUlHd+TAgtKPuaoQk8ZQRVZ9GfZhXAdW3622Yiw== X-Google-Smtp-Source: ABdhPJzruP2FzeZRwPR6zyDb+MGWrPcKVuHVSHRiDqmTukJKyZeQtXXgwD7GQB8j4xgwJLtaqxztDYOUwhGdTqMth70= X-Received: by 2002:aa7:8105:0:b029:18e:c8d9:2c24 with SMTP id b5-20020aa781050000b029018ec8d92c24mr6569040pfi.49.1607603562910; Thu, 10 Dec 2020 04:32:42 -0800 (PST) MIME-Version: 1.0 References: <20201210035526.38938-1-songmuchun@bytedance.com> <20201210035526.38938-11-songmuchun@bytedance.com> <20201210101526.GA4525@localhost.localdomain> In-Reply-To: <20201210101526.GA4525@localhost.localdomain> From: Muchun Song Date: Thu, 10 Dec 2020 20:32:06 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v8 10/12] mm/hugetlb: Introduce nr_free_vmemmap_pages in the struct hstate To: Oscar Salvador 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 10, 2020 at 7:40 PM Oscar Salvador wrote: > > On Thu, Dec 10, 2020 at 11:55:24AM +0800, Muchun Song wrote: > > +void __init hugetlb_vmemmap_init(struct hstate *h) > > +{ > > + unsigned int nr_pages = pages_per_huge_page(h); > > + unsigned int vmemmap_pages; > > + > > + /* We cannot optimize if a "struct page" crosses page boundaries. */ > > + if (!is_power_of_2(sizeof(struct page))) > > + return; > > + > > + if (!hugetlb_free_vmemmap_enabled) > > + return; > > I think it would make sense to squash the last patch and this one. > As per the last patch, if "struct page" is not power of 2, > early_hugetlb_free_vmemmap_param() does not set > hugetlb_free_vmemmap_enabled, so the "!is_power_of_2" check from above > would become useless here. > We know that in order for hugetlb_free_vmemmap_enabled to become true, > the is_power_of_2 must have succeed early on when calling the early_ > function. Yeah, you are right. But if is_power_of_2 returns false. The compiler can optimize this function to null. If we remove the check, it prevents the compiler from optimizing the code of hugetlb_vmemmap_init(). So I think leaving it here makes sense. Right? > > -- > Oscar Salvador > SUSE L3 -- Yours, Muchun 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.7 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 11B1CC4361B for ; Thu, 10 Dec 2020 12:32:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7CD1023B26 for ; Thu, 10 Dec 2020 12:32:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CD1023B26 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 5D6F86B0068; Thu, 10 Dec 2020 07:32:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 588A06B006C; Thu, 10 Dec 2020 07:32:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 476616B006E; Thu, 10 Dec 2020 07:32:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2EFC56B0068 for ; Thu, 10 Dec 2020 07:32:45 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E63D61EE6 for ; Thu, 10 Dec 2020 12:32:44 +0000 (UTC) X-FDA: 77577311448.23.wax13_05152f1273f8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id C895737604 for ; Thu, 10 Dec 2020 12:32:44 +0000 (UTC) X-HE-Tag: wax13_05152f1273f8 X-Filterd-Recvd-Size: 5049 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Dec 2020 12:32:43 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id s21so3909364pfu.13 for ; Thu, 10 Dec 2020 04:32:43 -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=l2j9oJVLdw2ETVRjvlsUKZFYNsqLIEckkbStxyUbG4c=; b=Cf6GkzyVICZ2r+cphcXwh9MH72pN7NwUnmwu484SPDfOCSkIX7b16iRZS+XGbb0J9V ogHDXhnYLhGBT0lXSBZjMp/7JnxpPxncVqbvvGDSe2Yt7XZPb2/XdTar+rZ9E2dmC9gS fQH4+CLKK5F3vRAi+ixzmAIpBewwZZwKxPJom1P5o15wG7DUVUire3Az2R1rppKXtouM GO8fBMD+6tkECDO2+6w4HSxn705fER+7axAKl50N1I9U/c55lRj8rxuNS49h74n9EQiK KSQGY4SiMnuQb5zYN2yW3RKKa8RykPQTPPDWNy/ULPShCy1tFlsEejugZK4buXEFHUjh PReQ== 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=l2j9oJVLdw2ETVRjvlsUKZFYNsqLIEckkbStxyUbG4c=; b=D0Ycz1ftzMau6WoY+U2IwGwAx1Y1aG+kEY7rq3ADxMq2AssWUFukIROdl7zVPMJRAd s7H853ftadDdSpZ32tzgijlkTmo7R4yrO5N5/VZyfi772MYv3QYf8MsX5tROfzpRFsJC 8MkEwu3DKtyBGr/IeIVWFuxremz0xsm8qX5F5770Fo54bz1V6Hum/2z/HmeUw0vEIfsA qI6N+BYoga7aEfA3KOqgdTQfMbPqnDdcvbuW88lw6ZT3yQm3baGc4ETlcgj1SjpgtxmE MRaEASBMjv17xalmU8/Y1w9Pam1pR7+ZrEkZTuyRFI+z0PJH1/23XfM5ZGltumsa6G+J TN6Q== X-Gm-Message-State: AOAM532qnjImNOUoNPu/kkli3ITlJeOByzmOhdBblIR+BD9chozGE29q MgDohqtwB3LV1gXn6PQWMe5VOGwgNFkCF2JhNFAj0Q== X-Google-Smtp-Source: ABdhPJzruP2FzeZRwPR6zyDb+MGWrPcKVuHVSHRiDqmTukJKyZeQtXXgwD7GQB8j4xgwJLtaqxztDYOUwhGdTqMth70= X-Received: by 2002:aa7:8105:0:b029:18e:c8d9:2c24 with SMTP id b5-20020aa781050000b029018ec8d92c24mr6569040pfi.49.1607603562910; Thu, 10 Dec 2020 04:32:42 -0800 (PST) MIME-Version: 1.0 References: <20201210035526.38938-1-songmuchun@bytedance.com> <20201210035526.38938-11-songmuchun@bytedance.com> <20201210101526.GA4525@localhost.localdomain> In-Reply-To: <20201210101526.GA4525@localhost.localdomain> From: Muchun Song Date: Thu, 10 Dec 2020 20:32:06 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v8 10/12] mm/hugetlb: Introduce nr_free_vmemmap_pages in the struct hstate To: Oscar Salvador 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 Content-Type: text/plain; charset="UTF-8" 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 7:40 PM Oscar Salvador wrote: > > On Thu, Dec 10, 2020 at 11:55:24AM +0800, Muchun Song wrote: > > +void __init hugetlb_vmemmap_init(struct hstate *h) > > +{ > > + unsigned int nr_pages = pages_per_huge_page(h); > > + unsigned int vmemmap_pages; > > + > > + /* We cannot optimize if a "struct page" crosses page boundaries. */ > > + if (!is_power_of_2(sizeof(struct page))) > > + return; > > + > > + if (!hugetlb_free_vmemmap_enabled) > > + return; > > I think it would make sense to squash the last patch and this one. > As per the last patch, if "struct page" is not power of 2, > early_hugetlb_free_vmemmap_param() does not set > hugetlb_free_vmemmap_enabled, so the "!is_power_of_2" check from above > would become useless here. > We know that in order for hugetlb_free_vmemmap_enabled to become true, > the is_power_of_2 must have succeed early on when calling the early_ > function. Yeah, you are right. But if is_power_of_2 returns false. The compiler can optimize this function to null. If we remove the check, it prevents the compiler from optimizing the code of hugetlb_vmemmap_init(). So I think leaving it here makes sense. Right? > > -- > Oscar Salvador > SUSE L3 -- Yours, Muchun