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=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 23FDFC55ABD for ; Tue, 10 Nov 2020 09:48:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7291420780 for ; Tue, 10 Nov 2020 09:48:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7291420780 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ABEA66B0036; Tue, 10 Nov 2020 04:48:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A47196B005C; Tue, 10 Nov 2020 04:48:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90D6E6B005D; Tue, 10 Nov 2020 04:48:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id 641976B0036 for ; Tue, 10 Nov 2020 04:48:40 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 08462181AEF09 for ; Tue, 10 Nov 2020 09:48:40 +0000 (UTC) X-FDA: 77468034000.13.run85_5d0d050272f4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id DA7C818140B69 for ; Tue, 10 Nov 2020 09:48:39 +0000 (UTC) X-HE-Tag: run85_5d0d050272f4 X-Filterd-Recvd-Size: 3679 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 09:48:39 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 18320AC1D; Tue, 10 Nov 2020 09:48:38 +0000 (UTC) Date: Tue, 10 Nov 2020 10:48:34 +0100 From: Oscar Salvador To: Muchun Song 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 , Xiongchun duan , linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel Subject: Re: [External] Re: [PATCH v3 09/21] mm/hugetlb: Free the vmemmap pages associated with each hugetlb page Message-ID: <20201110094830.GA25373@linux> References: <20201108141113.65450-1-songmuchun@bytedance.com> <20201108141113.65450-10-songmuchun@bytedance.com> <20201109185138.GD17356@linux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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 Tue, Nov 10, 2020 at 02:40:54PM +0800, Muchun Song wrote: > Only the first HugeTLB page should split the PMD to PTE. The other 63 > HugeTLB pages > do not need to split. Here I want to make sure we are the first. I think terminology is loosing me here. Say you allocate a 2MB HugeTLB page at ffffea0004100000. The vmemmap range that the represents this is ffffea0004000000 - ffffea0004200000. That is a 2MB chunk PMD-mapped. So, in order to free some of those vmemmap pages, we need to break down that area, remapping it to PTE-based. I know what you mean, but we are not really splitting hugetlg pages, but the memmap range they are represented with. About: "Only the first HugeTLB page should split the PMD to PTE. The other 63 HugeTLB pages do not need to split. Here I want to make sure we are the first." That only refers to gigantic pages, right? > > > +static void free_huge_page_vmemmap(struct hstate *h, struct page *head) > > > +{ > > > + pmd_t *pmd; > > > + spinlock_t *ptl; > > > + LIST_HEAD(free_pages); > > > + > > > + if (!free_vmemmap_pages_per_hpage(h)) > > > + return; > > > + > > > + pmd = vmemmap_to_pmd(head); > > > + ptl = vmemmap_pmd_lock(pmd); > > > + if (vmemmap_pmd_huge(pmd)) { > > > + VM_BUG_ON(!pgtable_pages_to_prealloc_per_hpage(h)); > > > > I think that checking for free_vmemmap_pages_per_hpage is enough. > > In the end, pgtable_pages_to_prealloc_per_hpage uses free_vmemmap_pages_per_hpage. > > The free_vmemmap_pages_per_hpage is not enough. See the comments above. My comment was about the VM_BUG_ON. -- Oscar Salvador SUSE L3