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 AFC81C56202 for ; Tue, 17 Nov 2020 15:30:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 194562463D for ; Tue, 17 Nov 2020 15:30:28 +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="bhwrJmc0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 194562463D 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 5AFA36B0070; Tue, 17 Nov 2020 10:30:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 55E646B0072; Tue, 17 Nov 2020 10:30:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44D536B0073; Tue, 17 Nov 2020 10:30:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0067.hostedemail.com [216.40.44.67]) by kanga.kvack.org (Postfix) with ESMTP id 158E96B0070 for ; Tue, 17 Nov 2020 10:30:28 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 01D5B362A for ; Tue, 17 Nov 2020 15:30:26 +0000 (UTC) X-FDA: 77494296894.07.able89_3c15fb527332 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id C1A701803FF14 for ; Tue, 17 Nov 2020 15:30:26 +0000 (UTC) X-HE-Tag: able89_3c15fb527332 X-Filterd-Recvd-Size: 5427 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Nov 2020 15:30:25 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id f12so631711pjp.4 for ; Tue, 17 Nov 2020 07:30:25 -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=qIvZeddIQ2d7OXVk2Uvs8VZdn+XX8s/0AnrjeK+3CsU=; b=bhwrJmc0GjcqgX8OVmcbGhlIi+xRPTfFufg6IrO2IlzzbU2Ro3Dn1DorKGtrkbUhEY HfnFy5EeLrIq4OJNeRGdwTMen1DVJO+eQ9C7cHlEv+AzRolv5nul5z0n+C2yOfDcXnEc /wLam43UU7fEiHh4i7hNQOZNJ5Q0tk3KYhHoLz7WhPJiv3X2623wQ0g8ZvVZ3VeE3sFF yPpUA+21czYfv1dFNgXKviqcQPaRVTpcydWad4DAdlQ2fQxVYFTbG0R+HRg13t9aqvCx 92e93IxrRQspe2wBpWSCgI6jZi9VTzWlxzJ8zPyZPVjGAlxrtzGQWafIqKPs99SMpGxA bNKg== 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=qIvZeddIQ2d7OXVk2Uvs8VZdn+XX8s/0AnrjeK+3CsU=; b=cYoePjpD2Eux8SBS202GnNw2wxbYBrSqsnVdVYkmKW+WR+VE2sSkoJ4YIr3+sOr5+R zaGrxDMFCKAYd0tWZQF7XL55hswIBM2g/zpMiosSV+fPwBvyLw80Vf+V4VJAIHXGBPRd ZOiaX/mYtguv89JoK+xTvny/URbCXanGnFHEdZGAlf623D9vR+dSHwprJCE4tfI3wccb UZZxCkZAI7aivNJRGfpvWfpdllQxdE1g3cytYMycTV7i1kP6cqwj2Vi5lLQntc77dFsB TDKprFxOf/fKGS9PwqPMXro7/DddV0szjsGhPG7YtFF4y3Jud5DHFEO9Ky2RE4jNsdk3 CQsw== X-Gm-Message-State: AOAM532Ctlhna5jYxlqs8rRlkdTYSYrKZakcGqg8jfRvylEicMEEUInV YyXNMtuChxr1wxCEWkE5/+hvri15hR727BLfbkd/hw== X-Google-Smtp-Source: ABdhPJwIhciLv1sUAGBmks9JTdZrzhMo5xSdPzoc5eR6bFAjo9blSdT+iwLKdn8nt0XnjcldUMgbZHy6/eG17MNR+nw= X-Received: by 2002:a17:90b:88b:: with SMTP id bj11mr5214598pjb.229.1605627024793; Tue, 17 Nov 2020 07:30:24 -0800 (PST) MIME-Version: 1.0 References: <20201113105952.11638-1-songmuchun@bytedance.com> <20201113105952.11638-6-songmuchun@bytedance.com> <20201117150604.GA15679@linux> In-Reply-To: <20201117150604.GA15679@linux> From: Muchun Song Date: Tue, 17 Nov 2020 23:29:45 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v4 05/21] mm/hugetlb: Introduce pgtable allocation/freeing helpers 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 17, 2020 at 11:06 PM Oscar Salvador wrote: > > On Fri, Nov 13, 2020 at 06:59:36PM +0800, Muchun Song wrote: > > +#define page_huge_pte(page) ((page)->pmd_huge_pte) Yeah, I forgot to remove it. Thanks. > > Seems you do not need this one anymore. > > > +void vmemmap_pgtable_free(struct page *page) > > +{ > > + struct page *pte_page, *t_page; > > + > > + list_for_each_entry_safe(pte_page, t_page, &page->lru, lru) { > > + list_del(&pte_page->lru); > > + pte_free_kernel(&init_mm, page_to_virt(pte_page)); > > + } > > +} > > + > > +int vmemmap_pgtable_prealloc(struct hstate *h, struct page *page) > > +{ > > + unsigned int nr = pgtable_pages_to_prealloc_per_hpage(h); > > + > > + /* Store preallocated pages on huge page lru list */ > > + INIT_LIST_HEAD(&page->lru); > > + > > + while (nr--) { > > + pte_t *pte_p; > > + > > + pte_p = pte_alloc_one_kernel(&init_mm); > > + if (!pte_p) > > + goto out; > > + list_add(&virt_to_page(pte_p)->lru, &page->lru); > > + } > > Definetely this looks better and easier to handle. > Btw, did you explore Matthew's hint about instead of allocating a new page, > using one of the ones you are going to free to store the ptes? Oh, sorry for missing his reply. It is a good idea. I will start an investigation. Thanks for reminding me. > I am not sure whether it is feasible at all though. > > > > --- a/mm/hugetlb_vmemmap.h > > +++ b/mm/hugetlb_vmemmap.h > > @@ -9,12 +9,24 @@ > > #ifndef _LINUX_HUGETLB_VMEMMAP_H > > #define _LINUX_HUGETLB_VMEMMAP_H > > #include > > +#include > > why do we need this here? Yeah, also can remove:). > > -- > Oscar Salvador > SUSE L3 -- Yours, Muchun