Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2570120pxj; Mon, 10 May 2021 06:08:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyU0AuPVxvfdi2OclNYfNLtu1NDfRGenT8/Snm8Qdew2GwuRpiCPX+JnNcn5MlHuyG2WivI X-Received: by 2002:a1c:4c10:: with SMTP id z16mr38039235wmf.134.1620652130935; Mon, 10 May 2021 06:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620652130; cv=none; d=google.com; s=arc-20160816; b=m2MKLc9nHGzOQEQUgmKHV/RPev3VKwd9uH5Ax7F7oTwIFCJrLfWkQdvmQ3jk+J8UkK hl8jQGDhLNaR8LBhTWjXTAei4VBo7cXZ95pi1wv3wX5R+mpl3B1a0v0VRVyXv6JRI2cL AGXuYdbhDZzy304cG2zrfNx0J2v57usFY9Xve5SNcVXFFDzPQeMqIogqucobJUWVy+nJ h3QEbS9zARjSQWd9YeM1HOoD4tLqDEb/q45L8HD93TrLDwa77iwwE2qmz/Aqy2EVqVmN fOLv32fwWvT5xmS0FQRQvQY6oXVVzk7whkoNmCWUJoHu8Apcz0Q1qCbGBUdb3HoEiw7M VUIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=4BI1jSnICccHTcWNyJHFkwBq+AW9OzrNQiZKeObmRK4=; b=hTgy0l39QZeIUFzC5yiXZBY9H/kgp+QaEqQNQzZGLGdcFeGk6nnzVDxTag0fL/e2U7 6YRB5XI3wsKC5fpsaROR4ks5czKLLp8KfexomHoI+nVa2q9C4c2HlQoqbgBruMBB+wrk AUzj02q3MPhgdN1iC9CLmoy0P6ce5KIfXsCpOGYQt0TRrkHXWPW9jJsy69vtYeEJTuH3 UMWTVA6y2aBhUCE2sAA92AmMV0BWr+Iu3cA9PSHPANxYDm+TLMevrua1eXP4EoleftQS OwXpvsn9+ftiepIrGBjRl7x3SsJxBQcSNAXvBb9h/JjD7qBzHngylHzc45JvU/gankpX mLJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=a8rST2mi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b23si13962933edv.199.2021.05.10.06.08.05; Mon, 10 May 2021 06:08:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=a8rST2mi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350123AbhEJM4T (ORCPT + 99 others); Mon, 10 May 2021 08:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237145AbhEJM24 (ORCPT ); Mon, 10 May 2021 08:28:56 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAA83C061362 for ; Mon, 10 May 2021 05:20:24 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id lj11-20020a17090b344bb029015bc3073608so10208888pjb.3 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=YVwhXm5KnFtC4rM5NW1zMAvIdMspLs3eo7IwieQzWenhubxwZJ2kcFcmuCv9QmWXko up5KmSO5xuJOOAY0LCvS1tR+jXgkVi4Y/b7Qmm1l97B/J1kHU8YibwNsvFRjGEkToUt5 5X2scE6whUlN0y/jz5KdK/nHGmTr879IpsdhAXteJUU0WX7XyMl0csEsY2ed+FauIi8y Lu4Kp43i2vrZAvyLiSYq+SR4a+pfavL0Q0FWR3jmnlxQIuf9BOBfkG4q8yXhXBC+hRh5 rOOXzUGk6p6Vdt2xo5YqviSbkiPmRqqqOUv3PMTMwZ/rfGp8XvivhkqGGWTAyKiBARBW xyKA== X-Gm-Message-State: AOAM5322ufOIgpAKrAyW6gSW2BbaHpH6KIJXk514E0+blb1HtmKV1ovz tHeiC/iyThYQ1+c6qiTInLTiFDBtDOPZjeNgpt0rsg== 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-kernel@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