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=-3.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 6B7F1C388F7 for ; Tue, 10 Nov 2020 10:47:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B2EB4207BB for ; Tue, 10 Nov 2020 10:47:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="xIqtmtgc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2EB4207BB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 92D106B0036; Tue, 10 Nov 2020 05:47:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B6106B005C; Tue, 10 Nov 2020 05:47:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72F056B005D; Tue, 10 Nov 2020 05:47:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id 41B736B0036 for ; Tue, 10 Nov 2020 05:47:47 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DD1F48249980 for ; Tue, 10 Nov 2020 10:47:46 +0000 (UTC) X-FDA: 77468182932.24.lead07_3311d6b272f4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id C33331A4A0 for ; Tue, 10 Nov 2020 10:47:46 +0000 (UTC) X-HE-Tag: lead07_3311d6b272f4 X-Filterd-Recvd-Size: 6044 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 10:47:45 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id i7so9809110pgh.6 for ; Tue, 10 Nov 2020 02:47:45 -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=Toc/1e3XZP6E3Q/GS14/EKWrJmH5Dil0O7B9AgVB8fQ=; b=xIqtmtgc4HMmDQO5cYNvT9oenNFNyBm4de07RNrCAmKL8NA+vkKWnUbTECqmYwJPbj /5FguZIa4jebLRz+my6Vov85DE2kLM8TIvUACojHoUCrNs636FkjcUejZtgkY2NxCcxN zC2RNDRLhy6ZAsouPM4Pq7Fk4HBxloDh1pkE/9uKEj6B6O/6if/W77dKY+mqAaffupRk M+lqp3qgD2QoMasQUEhfk/x2Hw7Qk+i2eKwrYFP+FEIetLn5CyGbAsM3+fxQPmEYKz/n qtUCNwd1JruN3PvyiKRJ9dJD89ldVlGc7dFWOvJd1GBJsyNJ5e5Si1fkw3+s3A0Ncm9G jqaQ== 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=Toc/1e3XZP6E3Q/GS14/EKWrJmH5Dil0O7B9AgVB8fQ=; b=b0uYZQeknsjwNJ+g+JMUo5ZWNV7AyRpLcEdAersMR57gUpMJ89Xqpliu/2uY8AEN3J HMeUHWh4+95Qx6jDQnlt3h42O1HmYNL4V/XDceVVSTgAnUcgONWgf4+Gb1dNS1T0QN/X /ju34vFRmOaRpYC6bst4bHbfis62YCYOvazBOWbjcGRb4UMd11OMt3py+R1yACYhitA/ y04K6pAkBvQOTdWyY59r0ptvTYDzSnK7zobgXn707dgWn4SRmAsa5PJZNfbMqHwmIRK+ 4VA3A3XZalBGwPbYyr7QUWXL7eY7oyC+XtkYpS2um2OqgLOErp2T1hDW6aJ9rAl23vct trMQ== X-Gm-Message-State: AOAM533kyySQLSeefWXO2AQp6xsWpYp4GIJaivhAnRUCQMAIsl+8SnHZ 6vYHUZmMnSUGmMU6XG9xCRuuhvY+oHmH0FPqvxfPTg== X-Google-Smtp-Source: ABdhPJx9kEy0Q3xDZ+PnVrlGbMTy6IdowDw+7yOHeSag6XbBXToDQ8IysFZVAeKrB0UhrKWsZW0NnmBu0qOPbrRJtN8= X-Received: by 2002:a63:7408:: with SMTP id p8mr16100765pgc.273.1605005264696; Tue, 10 Nov 2020 02:47:44 -0800 (PST) MIME-Version: 1.0 References: <20201108141113.65450-1-songmuchun@bytedance.com> <20201108141113.65450-10-songmuchun@bytedance.com> <20201109185138.GD17356@linux> <20201110094830.GA25373@linux> In-Reply-To: <20201110094830.GA25373@linux> From: Muchun Song Date: Tue, 10 Nov 2020 18:47:08 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v3 09/21] mm/hugetlb: Free the vmemmap pages associated with each hugetlb page 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 , Xiongchun duan , linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel Content-Type: text/plain; charset="UTF-8" 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 5:48 PM Oscar Salvador wrote: > > 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. Yeah, you are right. We are splitting the vmemmap instead of hugetlb. Sorry for the confusion. > > 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? Yeah, now it only refers to gigantic pages. Originally, I also wanted to merge vmemmap PTE to PMD for normal 2MB HugeTLB pages. So I introduced those macros(e.g. freed_vmemmap_hpage). For 2MB HugeTLB pages, I haven't found an elegant solution. Hopefully, when you or someone have read all of the patch series, we can come up with an elegant solution to merge PTE. Thanks. > > > > > +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. Sorry, yeah, we can drop it. Thanks. > > > -- > Oscar Salvador > SUSE L3 -- Yours, Muchun