Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp797240pxb; Fri, 16 Apr 2021 19:57:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVeLrCrM4Cm4sFjSCUKUIYAy86ltD6XzQXUvb6J8mvU+yOMKpPEP4KOWQmz3dWXxIdxSBD X-Received: by 2002:a17:907:9706:: with SMTP id jg6mr11542203ejc.515.1618628241321; Fri, 16 Apr 2021 19:57:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618628241; cv=none; d=google.com; s=arc-20160816; b=VvRrZ2XulNPMfw+TVeE2keRjEy3sMBM0btXShkwXq3B5V4f2abELRoqEOwpyq5d/fU TdH0WOYv6p/azdRb2XHT3ZVuQBqCFgcEOFul7NPlr5zCXJt69nTvXhBlgiD+zOILsshK lmDaB4TzKdtv6N9UaPN79rL1gLuYS49ikJod4Evg3Q+T1+Iy/YrvPQX7KdjqzkjEmNYk fMZvHcC0GDwlGXsBBVIy9/oRfuq5dS3t9/dC4Zuou+FTyT+50HIl4fJDb8wxhJMu6ojN lYRvdJvoXh8djGLd0RfRymmHCKJtyAGS0+pQEJF3y5LLNhX3zzK1sMqCvmOU2wpt+2Z6 DsXA== 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=M/WEoH5MRuctyP68fbGzySmbeyx0J6VUcO+fRuz+hj8=; b=p7OHG/mr4U2HgcQs4mGwt1Ut+8yyyUeUcgf7aUf44aqptUQ03WhF2NQAYmtQZTaERB hDfKjJELch3Nz84dwk5MuAobid+FqZQGiehzb16Zt84ptl1/nwNfXjg6RYGn2KF0ud8D oiaovovcGeHMCI5EdpZT5dLdgX2ZUTfAprF6l33g4S/WYySXbU/buY9iZ/BfMQcGzNxe faaeeksMcijXEBXY9ylYM8jKw6qVdUl66CDL7ImjPBuWAcT48lGn6TB25XDFrqg+OqVI H+XaubZoXqzJZlEP6gtQ0dbbAQy7nbSrFUbPafN1JeEwhTOwV6CPimCQp0lhj9Y1Pwg1 J9bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=Lj2mGHsP; 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 f5si4115699edq.421.2021.04.16.19.56.57; Fri, 16 Apr 2021 19:57:21 -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=Lj2mGHsP; 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 S235476AbhDQC4M (ORCPT + 99 others); Fri, 16 Apr 2021 22:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231997AbhDQC4L (ORCPT ); Fri, 16 Apr 2021 22:56:11 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60AEFC06175F for ; Fri, 16 Apr 2021 19:55:42 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id ot17-20020a17090b3b51b0290109c9ac3c34so17387750pjb.4 for ; Fri, 16 Apr 2021 19:55:42 -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=M/WEoH5MRuctyP68fbGzySmbeyx0J6VUcO+fRuz+hj8=; b=Lj2mGHsPw4xnwhkesCow25VFlttvdhVf7gVXMvx2REAQ5eoNTmWeeZmsRWOP8ukcGT bXq5PU/LuCsL5q8XI9ENTtCDVBjZtJxAHZfdNt2Glm+5UJj9oPsKvMbZ1SGA9/QesFSJ 4bFWv+gAnz+18Uzqzp1cREyLJp1AlwQS4apo49kvmH7jIHDfBnICtIfzD9RWyuVlgB5q soWJBLpSbTZ07UVyuiqQKD5NNHFnP6Y/HLyQd8h/CN781Ffkwv11JBcqm71d9oXpe1hP XIOcWTOIUPQfw7Ahtz+GVau8fHlEcMOO83twWZQIRbJeQMcdRkPyzPhHI9AzhixJ7ahb /x7w== 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=M/WEoH5MRuctyP68fbGzySmbeyx0J6VUcO+fRuz+hj8=; b=Qod9Vj9/KxWcHBakKrTWUtlMNLmtiT9dOBdKfc8MxRAVCS4MaxrsvOFXftI7iRjQZT HiFovIqyXqEARx1vynLlmJv9ELgDQ+7UDxLtF89BWcMyQeM7NFxLXxRFrkRX8LSVeWgX TXuBhs5CVboDdPwsVKX2Khj4Pa2wFaZtTRePDkX8uIjiAH1uhAQi6d6xBnl4tNnoMkQX DSr293/7VCy4wBo4o//68FGfHlGma6P3WGjNvqBKRu8U1y0edlztRjZ2YOhRwpYAfd9I EXw9ZlfmZW568oLRPezBE7Jh/a6XdoYqW/YTAdIkIqCASRU2Q/63aVKs9OKKax/A50NY 623g== X-Gm-Message-State: AOAM533kqckdAF3D2I/LsM4Qy7Hn+DtoJXwKMz9/ekITrA1tyKO2JMrM /T4GQ+owFh/5TRpNl72RqoEFpalrNIPpqgbM0/t7mQ== X-Received: by 2002:a17:90b:88f:: with SMTP id bj15mr13038117pjb.147.1618628141821; Fri, 16 Apr 2021 19:55:41 -0700 (PDT) MIME-Version: 1.0 References: <20210415084005.25049-1-songmuchun@bytedance.com> <20210415084005.25049-5-songmuchun@bytedance.com> <602af5f8-f103-438e-d88e-2819404b9dab@oracle.com> In-Reply-To: <602af5f8-f103-438e-d88e-2819404b9dab@oracle.com> From: Muchun Song Date: Sat, 17 Apr 2021 10:55:05 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v20 4/9] mm: hugetlb: free the vmemmap pages associated with each HugeTLB page To: Mike Kravetz Cc: Jonathan Corbet , 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 , Oscar Salvador , Michal Hocko , "Song Bao Hua (Barry Song)" , David Hildenbrand , =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , Joao Martins , Xiongchun duan , fam.zheng@bytedance.com, linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel , Chen Huang , Bodeddula Balasubramaniam Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 17, 2021 at 5:10 AM Mike Kravetz wrote: > > On 4/15/21 1:40 AM, Muchun Song wrote: > > Every HugeTLB has more than one struct page structure. We __know__ that > > we only use the first 4 (__NR_USED_SUBPAGE) struct page structures > > to store metadata associated with each HugeTLB. > > > > There are a lot of struct page structures associated with each HugeTLB > > page. For tail pages, the value of compound_head is the same. So we can > > reuse first page of tail page structures. We map the virtual addresses > > of the remaining pages of tail page structures to the first tail page > > struct, and then free these page frames. Therefore, we need to reserve > > two pages as vmemmap areas. > > > > When we allocate a HugeTLB page from the buddy, we can free some vmemmap > > pages associated with each HugeTLB page. It is more appropriate to do it > > in the prep_new_huge_page(). > > > > The free_vmemmap_pages_per_hpage(), which indicates how many vmemmap > > pages associated with a HugeTLB page can be freed, returns zero for > > now, which means the feature is disabled. We will enable it once all > > the infrastructure is there. > > > > Signed-off-by: Muchun Song > > Reviewed-by: Oscar Salvador > > Tested-by: Chen Huang > > Tested-by: Bodeddula Balasubramaniam > > Acked-by: Michal Hocko > > There may need to be some trivial rebasing due to Oscar's changes > when they go in. Yeah, thanks for your reminder. > > Reviewed-by: Mike Kravetz > -- > Mike Kravetz