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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 0172EC43460 for ; Mon, 10 May 2021 13:06:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D358D611CE for ; Mon, 10 May 2021 13:06:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236038AbhEJNHI (ORCPT ); Mon, 10 May 2021 09:07:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237151AbhEJM24 (ORCPT ); Mon, 10 May 2021 08:28:56 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB8C2C061364 for ; Mon, 10 May 2021 05:20:24 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id t21so9050140plo.2 for ; Mon, 10 May 2021 05:20:24 -0700 (PDT) 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=4BI1jSnICccHTcWNyJHFkwBq+AW9OzrNQiZKeObmRK4=; b=a8rST2miP7qSaV/2yY/wevlxGY74E+Twgg6XlkrTXm9yArxegR0bQChWDP+s2oe3lk BYGJZwfrSQ7xEy7+8wD4MZyIUpcKi1cIOpoK4RcJWRMhPo4wioG9Vd/g+cTV6dlZr4+8 6Xz7tpl9dw7r2TgkygHob6pyhmnugAmmI+gzeYcgh/Zwbe8D3acYULeOZ5eqte8BIrmX Rqz6Q9vqKqo66QIglUJlEvHgc/jx0/+aOnhmezipMbFM8OnN7KzA6Bup4IihaTvHBgFN YvQQhkoqySQ3/LlALHoPPPNGIRtdHg3kqgJjIIZcAXgoW4qwHyGYZhFLHUKkk8XaCCw8 pkDw== 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=4BI1jSnICccHTcWNyJHFkwBq+AW9OzrNQiZKeObmRK4=; b=rxVLv+eIa0SE3+ZpwQ76hEtro49KaQGOMgEEyqzrNJPBi7MjxkRr0im6f2KMPbUU9g 1Y9BPABwfoH07n+FKCv2zpgFbvdFEX/QgPbiY6Mgcf2vNWD2XJTpqDKJISXQnmSx9cEw zXsexmBXZl9EFFtifSZcoWPJ6O7Cr9kgRLRzT2fCf8mC3UPL/2tee/RJESky8AhYUsH4 sNUWu7NAgJ8cb/iD7BqlY7Lj1ldkihdnlIQlanzr617vDiAqb7zAe4ATt7LtAfMy6jYA l5pLoB4ci3731ett3U0uqWHuUeJdQkfYjpwU/1WXAxHkHp+rmJFP0v1f61FxZTMnKYdQ AlsQ== X-Gm-Message-State: AOAM531KH3ApCJTdDS21UQj3nPVby+c4XbEUcm2pEXkqsfzV0SRCl3GP /DX9Og52ynxtq9S9BVXk3Uvh3qnlCzPJ7KFCLciSVA== X-Google-Smtp-Source: ABdhPJzjSdNf9S10m0zIQ+hBoQkHxcth5YYGDzQqqyXgieyswQfDpPrpCdqsF2ikjcZd73al3xYDipgLwoxSN2xsA+4= X-Received: by 2002:a17:90a:3c8d:: with SMTP id g13mr27968104pjc.13.1620649224150; Mon, 10 May 2021 05:20:24 -0700 (PDT) MIME-Version: 1.0 References: <20210510030027.56044-1-songmuchun@bytedance.com> <20210510030027.56044-7-songmuchun@bytedance.com> <20210510104524.GD22664@linux> In-Reply-To: <20210510104524.GD22664@linux> From: Muchun Song Date: Mon, 10 May 2021 20:19:47 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v23 6/9] mm: hugetlb: alloc the vmemmap pages associated with each HugeTLB page To: Oscar Salvador Cc: Jonathan Corbet , Mike Kravetz , Thomas Gleixner , Ingo Molnar , bp@alien8.de, X86 ML , hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, Peter Zijlstra , Alexander Viro , Andrew Morton , paulmck@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 , =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , Joao Martins , Xiongchun duan , fam.zheng@bytedance.com, zhengqi.arch@bytedance.com, 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-doc@vger.kernel.org On Mon, May 10, 2021 at 6:45 PM Oscar Salvador wrote: > > On Mon, May 10, 2021 at 11:00:24AM +0800, Muchun Song wrote: > > --- a/mm/hugetlb.c > > +++ b/mm/hugetlb.c > > @@ -1376,6 +1376,39 @@ static void remove_hugetlb_page(struct hstate *h, struct page *page, > > h->nr_huge_pages_node[nid]--; > > } > > > > +static void add_hugetlb_page(struct hstate *h, struct page *page, > > + bool adjust_surplus) > > +{ > > + int zeroed; > > + int nid = page_to_nid(page); > > + > > + VM_BUG_ON_PAGE(!HPageVmemmapOptimized(page), page); > > + > > + lockdep_assert_held(&hugetlb_lock); > > + > > + INIT_LIST_HEAD(&page->lru); > > + h->nr_huge_pages++; > > + h->nr_huge_pages_node[nid]++; > > + > > + if (adjust_surplus) { > > + h->surplus_huge_pages++; > > + h->surplus_huge_pages_node[nid]++; > > + } > > + > > + set_compound_page_dtor(page, HUGETLB_PAGE_DTOR); > > + set_page_private(page, 0); > > I think this has already been discused, so sorry about this. > > The only reason to need the set_page_private() is because of the dissolving > function right? add_hugetlb_page() can only get reached via free_huge_page(), > or dissolve_free_huge_page, and while the former clears the flags, the latter > it does not. Not exactly right. free_huge_page() does not clear HPageTemporary if the page is temporarily allocated when freeing. You are right that dissolve_free_huge_page() does not clear HPageFreed. > > I think this function would benefit from some renaming. add_hugetlb_page() gives > me no hint of what is this about, although I can figure it out reading the code. Because I think it is the reverse operation of remove_hugetlb_page, I named it add_hugetlb_page. Do you have any suggestions for renaming? Thanks. > > With that: Reviewed-by: Oscar Salvador > > > > > -- > Oscar Salvador > SUSE L3