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 E3042C5517A for ; Tue, 10 Nov 2020 07:11:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 230822080A for ; Tue, 10 Nov 2020 07:11:23 +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="w6shu/O0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 230822080A 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 25D536B0036; Tue, 10 Nov 2020 02:11:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 20DA86B005C; Tue, 10 Nov 2020 02:11:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D54D6B005D; Tue, 10 Nov 2020 02:11:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id D0F866B0036 for ; Tue, 10 Nov 2020 02:11:22 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7897F8249980 for ; Tue, 10 Nov 2020 07:11:22 +0000 (UTC) X-FDA: 77467637604.10.run31_0d1494b272f3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 5A11E16A06B for ; Tue, 10 Nov 2020 07:11:22 +0000 (UTC) X-HE-Tag: run31_0d1494b272f3 X-Filterd-Recvd-Size: 5094 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 07:11:21 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id c66so4854763pfa.4 for ; Mon, 09 Nov 2020 23:11:21 -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=UlQT59tCD8Lul0BWpf5GF9dCDTyjNMETV0Q2jjk6K5c=; b=w6shu/O07nzqF+lqi/iGcNfpQe1U6qmJrLgGz0kpjhpCm9sCsCU/VmXA59A6UfM0OV YzFK1vR37tjuSJT5GbxO0/T2Ir0r7TFAuNhi2mLBlkqtQaVAVopnYQxJg+6ninNe3Cfv 3KZgdVHuhrgy2O4a8WM3yMfVHAdlEN13MEvr+RQCOfgRYU5CN29UlOED8E3Yc5J5mhxT pqnHqJyugYFyl/y6EKnOGf9Rpllke0irq006nZ5hxZEJbXKD8GqZ3o7e7rbbKQdagR15 +A55cq1UrHKQ2ErcRH6rFAF4zg/cvFj3diRH2aMlnoqRgEf7NCq37Vyqm2oFy5m/zvJC 8SwA== 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=UlQT59tCD8Lul0BWpf5GF9dCDTyjNMETV0Q2jjk6K5c=; b=fbroAXMZuTAz5fsxP8F5MxsT/Ufz6MZcQixARe48QewzuoaDKdPWm60PwYZQRX6tg1 nGRyCQ1XX414D0sd3STAtkOKZd7Lym7iUbaS022UB3wjvKtpU9CWuAvfZy0PKSwpAvDQ yGrs26Ct1/buxXWotv8wlwhHvzDnt2J4LECSw7ZWv9Ehh1srqXZ0PicBoZlQP2351Mum 8sPW9NHjhD93ndd/lbNk/XT9S0UJSC0ZfD7+QXo4wvDS2lPy5WMmiuHZML7Xe0Yu7Qgy pGmat+a+IqPRl3q+VIdbugM4Dby5RDaA3+sZ3+i1tiKJ3Hawzv/MMWPEu+kAT32VCAXF imtQ== X-Gm-Message-State: AOAM530ZSQLQXdUvmjBuf7e+4Um4QtSTmvZGNjSAGKinK3M0VU6f92yt hI6sMupJ+5PZlgM1bpeLF31NR3aYfdOgj7oBWmdsxQ== X-Google-Smtp-Source: ABdhPJz3ovoBuWkQkrA7YSi9Hd89lWM0yU7X6hXWN7PjXgUhVfEkL8F1YzWa+UsEyEvQk7eZ4RT/Dm7BWVzyxx8AhKU= X-Received: by 2002:a17:90b:385:: with SMTP id ga5mr3615777pjb.13.1604992280457; Mon, 09 Nov 2020 23:11:20 -0800 (PST) MIME-Version: 1.0 References: <20201110054250.GA2906@localhost.localdomain> <20201110063325.GA4286@localhost.localdomain> In-Reply-To: <20201110063325.GA4286@localhost.localdomain> From: Muchun Song Date: Tue, 10 Nov 2020 15:10:43 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v3 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 10, 2020 at 2:33 PM Oscar Salvador wrote: > > On Tue, Nov 10, 2020 at 02:08:46PM +0800, Muchun Song wrote: > > The check should be added here. > > > > if (!pgtable) > > return NULL; > > > > Just like my previous v2 patch does. In this case, we can drop those > > checks. What do you think? > > It is too early for me, so bear with me. > > page_huge_pte will only return NULL in case we did not get to preallocate > any pgtable right? The page_huge_pte only returns NULL when we did consume the page tables. Not each HugeTLB page need to split the vmemmap page tables. We preallocate page tables for each HugeTLB page, if we do not need to split PMD. We should free the preallocated page tables. Maybe you can see the comments of the other thread. [PATCH v3 09/21] mm/hugetlb: Free the vmemmap pages associated with each hugetlb page Thanks. > > What I was talimg about is that > > > > > page_huge_pte(page) = list_first_entry_or_null(&pgtable->lru, > > > struct page, lru); > > here we will get the either a pgtable entry or NULL in case we already consumed > all entries from the list. > If that is the case, we can return NULL and let the caller known that we > are done. > > Am I missing anything? > > > -- > Oscar Salvador > SUSE L3 -- Yours, Muchun