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=-8.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 90C54C4361B for ; Thu, 10 Dec 2020 12:27:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 642FB22D70 for ; Thu, 10 Dec 2020 12:27:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732370AbgLJM1r (ORCPT ); Thu, 10 Dec 2020 07:27:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728385AbgLJM1q (ORCPT ); Thu, 10 Dec 2020 07:27:46 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00D81C061793 for ; Thu, 10 Dec 2020 04:27:06 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id s21so3894500pfu.13 for ; Thu, 10 Dec 2020 04:27:05 -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=wRVH576RjUF7Hfh+GmVFJTHPtJJABCzK9jSLmoXeohM=; b=QGxx2uqjkZLjwdyE5TglOBgNyR7M/o3toVg0IHWs2Un4c798mQiWRI/NN0FMfX4/gg IJReYIcQ31zi26/7+syJfTE6ThijeQoZdGNcny52VUzZtPbGKiXISDRo3Ykuyf2ppOn8 6xYGIrmC+9Q1+oERfykes5HcLNdSI3l772nN6zLhVPDRCvVXv+9i/BeTzF7zR8vb/AxC 3JWAgmGWuNDJOT2d9hhfHKdfTBavQFlpTjzcV7qzNH3EgJ3QwGhm2wP6aFE5+PPqnnT+ 72IUhDliIa3zPo0K+5frDNU0xN5UolLIcgRimNQAVabHNmXiViBJ8dfiLQjFNntlUYSC 08oA== 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=wRVH576RjUF7Hfh+GmVFJTHPtJJABCzK9jSLmoXeohM=; b=mokbQWvxsics6qLC3bPzTk+iXs9AAWIbxFEJbmhuY6vr8eIzb0nelxAd1sJQW8hdMM sC54NSXaz/cU6KPOdHGib9pnY5AxU6OmuoMahuiduoPGkVu3pzI7N/fJpZv66kNDkIxK h50XJBizDnbWWaefB+yA3VHdp3h92FtZ2/6iRsga5P+FUu3oIqhS+7wMrCm/RpD529tv RTrZbA9Hsv8fHoesX8iTgWrsSjYXro/OqH0sVSMOrE2jn8ghik9HuhtcehnuZu0ifYrw osG1Uh1MDb1JL9OyU7yx6Vl9uBfGRljuqT9VkOzlpO6xMmM2Jf4BfoDRK+SLvrlwV25p 0uAg== X-Gm-Message-State: AOAM533Oev2Fpn7sX1w7guay1DeW/OB21mU3PMKK1VC8/ZGfTeuva1PV Nyc0rvu3WYNf5uiK9Ix+tgARb6vQ2PQA5xwVxJ4jcQ== X-Google-Smtp-Source: ABdhPJzJSSCikK3jOM3ONA3u/M/J74mq1J/fc+RbtNlN/9xfSaOqDZ4guFg9UoAE15TqPlyox8rej6pMBOvdcG5TA5k= X-Received: by 2002:a63:1203:: with SMTP id h3mr6352071pgl.273.1607603225499; Thu, 10 Dec 2020 04:27:05 -0800 (PST) MIME-Version: 1.0 References: <20201210035526.38938-1-songmuchun@bytedance.com> <20201210035526.38938-10-songmuchun@bytedance.com> <20201210100454.GB3613@localhost.localdomain> In-Reply-To: <20201210100454.GB3613@localhost.localdomain> From: Muchun Song Date: Thu, 10 Dec 2020 20:26:28 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v8 09/12] mm/hugetlb: Add a kernel parameter hugetlb_free_vmemmap 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:41 PM Oscar Salvador wrote: > > On Thu, Dec 10, 2020 at 11:55:23AM +0800, Muchun Song wrote: > > +hugetlb_free_vmemmap > > + When CONFIG_HUGETLB_PAGE_FREE_VMEMMAP is set, this enables freeing > > + unused vmemmap pages associated each HugeTLB page. > ^^^ with Thanks. > > > - if (end - start < PAGES_PER_SECTION * sizeof(struct page)) > > + if (is_hugetlb_free_vmemmap_enabled()) > > + err = vmemmap_populate_basepages(start, end, node, NULL); > > + else if (end - start < PAGES_PER_SECTION * sizeof(struct page)) > > err = vmemmap_populate_basepages(start, end, node, NULL); > > Not sure if joining those in an OR makes se.se Well, I can do it. > > > else if (boot_cpu_has(X86_FEATURE_PSE)) > > err = vmemmap_populate_hugepages(start, end, node, altmap); > > @@ -1610,7 +1613,8 @@ void register_page_bootmem_memmap(unsigned long section_nr, > > } > > get_page_bootmem(section_nr, pud_page(*pud), MIX_SECTION_INFO); > > > > - if (!boot_cpu_has(X86_FEATURE_PSE)) { > > + if (!boot_cpu_has(X86_FEATURE_PSE) || > > + is_hugetlb_free_vmemmap_enabled()) { > > I would add a variable at the beginning called "basepages_populated" > that holds the result of those two conditions. > I am not sure if it slightly improves the code as the conditions do > not need to be rechecked, but the readibility a bit. Agree. The condition does not need to be rechecked. Will do in the next version. Thanks. > > > +bool hugetlb_free_vmemmap_enabled; > > + > > +static int __init early_hugetlb_free_vmemmap_param(char *buf) > > +{ > > + if (!buf) > > + return -EINVAL; > > + > > + /* We cannot optimize if a "struct page" crosses page boundaries. */ > > I think this comment belongs to the last patch. > Thanks. > > -- > Oscar Salvador > SUSE L3 -- Yours, Muchun