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=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 EA02AC4361B for ; Thu, 10 Dec 2020 15:27:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6B1C42332A for ; Thu, 10 Dec 2020 15:27:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B1C42332A 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 D333C6B006C; Thu, 10 Dec 2020 10:27:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D09016B006E; Thu, 10 Dec 2020 10:27:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAA3F6B0070; Thu, 10 Dec 2020 10:27:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0043.hostedemail.com [216.40.44.43]) by kanga.kvack.org (Postfix) with ESMTP id 9FFDA6B006C for ; Thu, 10 Dec 2020 10:27:35 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 51CE73626 for ; Thu, 10 Dec 2020 15:27:35 +0000 (UTC) X-FDA: 77577752070.29.push20_6310e07273f9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 215D918086CCB for ; Thu, 10 Dec 2020 15:27:35 +0000 (UTC) X-HE-Tag: push20_6310e07273f9 X-Filterd-Recvd-Size: 6943 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Dec 2020 15:27:34 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id d2so4398981pfq.5 for ; Thu, 10 Dec 2020 07:27:33 -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=rv3LvUpmaExydeU0HNZ3WNQ4lNYDnwxvurxewj7Gioo=; b=CUI3InpdCk2b2qqbrlYU3I+TKx8C7/x/zITj4+e6UHPTi4CztI5YFI6b6e4TYyB0zk 9GLSher1TjZWn3r++BtKviRXg9ASZRVOQ7hmDkSj9C+1ncPbu/rUkZGMkmForJvjvhR4 MPNgAfMF+W8VZQPCqhT99ceerjgW9inWSvOUSQbhtPq4XzPK/ZpJGUjqcp47FhLNS6Ce r+zPhxFsaUvhZ2nPGfUCZqYqrlEJCoMVzqzWr0qzrlK8ohEP3ptB6noQdCO6S3nDyRhM jkqD4svVWzg+/xae1eraU+L/DiJvBw3y01dqEZqp1D+OtXsez8UyLOrZX33W1QdCUK9r J2wg== 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=rv3LvUpmaExydeU0HNZ3WNQ4lNYDnwxvurxewj7Gioo=; b=udwSkbtaCW7F2k57tKJOuhRuYdu8G/by8RajIosOFZcaUdehSqklOPZJvH6xXNzGc5 AhIPvTnS+jzUYxstj7NNkf27HstIhVchTZBfFznxMsaD09rblcKqmmDKIMwOKKBmUjVi HYEeljlu0CDoNLtq5qJjTFvEzb0e/iGn3Dbse0x+0FIjTKz+0m1q42kHJqedkn6Q63pL mvwRGmkO7h3fqOoSe1D0u0gsWP+wxBlo4cdawtSEt5ATMCIJrrj05QpH0Jgl56csf+Ma IOEnmFMVqoXlvLr/iXYJ4q9FyjxowVlevTWo4pBgsmiJmLCzU5DKIvoGDKtnoaB10bV4 z1Ew== X-Gm-Message-State: AOAM533OQ0g7jb1u1IAR4aZcrxhOQ0EZOT/GWhSm0YYjQZoKC3BkFzwW spkx0kkleMJ4GQMJDHJpsYax3sIGyzPcBDf3QEWfVw== X-Google-Smtp-Source: ABdhPJyPxcHvN6IYlzC4n1GyRsUIJzjup9DkstN1YuVZ6rDsyWbcahJr0nfkJmjvBlP92tLmyVuV8gEVjalWAMva4PE= X-Received: by 2002:a62:4e4e:0:b029:19e:aaab:8be with SMTP id c75-20020a624e4e0000b029019eaaab08bemr5090266pfb.59.1607614052909; Thu, 10 Dec 2020 07:27:32 -0800 (PST) MIME-Version: 1.0 References: <20201210035526.38938-1-songmuchun@bytedance.com> <20201210035526.38938-4-songmuchun@bytedance.com> <20201210141547.GA8538@localhost.localdomain> In-Reply-To: From: Muchun Song Date: Thu, 10 Dec 2020 23:26:56 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v8 03/12] mm/bootmem_info: Introduce free_bootmem_page helper 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 , "Song Bao Hua (Barry Song)" , David Hildenbrand , 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 Thu, Dec 10, 2020 at 11:22 PM Muchun Song wrote: > > On Thu, Dec 10, 2020 at 10:16 PM Oscar Salvador wrote: > > > > On Thu, Dec 10, 2020 at 11:55:17AM +0800, Muchun Song wrote: > > > Any memory allocated via the memblock allocator and not via the buddy > > > will be makred reserved already in the memmap. For those pages, we can > > marked > > Thanks. > > > > call free_bootmem_page() to free it to buddy allocator. > > > > > > Becasue we wan to free some vmemmap pages of the HugeTLB to the buddy > > Because want > > > allocator, we can use this helper to do that in the later patchs. > > patches > > > > Thanks. > > > To be honest, I think if would be best to introduce this along with > > patch#4, so we get to see where it gets used. > > > > > Signed-off-by: Muchun Song > > > --- > > > include/linux/bootmem_info.h | 19 +++++++++++++++++++ > > > 1 file changed, 19 insertions(+) > > > > > > diff --git a/include/linux/bootmem_info.h b/include/linux/bootmem_info.h > > > index 4ed6dee1adc9..20a8b0df0c39 100644 > > > --- a/include/linux/bootmem_info.h > > > +++ b/include/linux/bootmem_info.h > > > @@ -3,6 +3,7 @@ > > > #define __LINUX_BOOTMEM_INFO_H > > > > > > #include > > > +#include > > > > already includes > > Yeah. Can remove this. > > > > > > +static inline void free_bootmem_page(struct page *page) > > > +{ > > > + unsigned long magic = (unsigned long)page->freelist; > > > + > > > + /* bootmem page has reserved flag in the reserve_bootmem_region */ > > reserve_bootmem_region sets the reserved flag on bootmem pages? > > Right. > > > > > > + VM_WARN_ON(!PageReserved(page) || page_ref_count(page) != 2); > > > > We do check for PageReserved in patch#4 before calling in here. > > Do we need yet another check here? IOW, do we need to be this paranoid? > > Yeah, do not need to check again. We can remove it. > > > > > > + if (magic == SECTION_INFO || magic == MIX_SECTION_INFO) > > > + put_page_bootmem(page); > > > + else > > > + WARN_ON(1); > > > > Lately, some people have been complaining about using WARN_ON as some > > systems come with panic_on_warn set. > > > > I would say that in this case it does not matter much as if the vmemmap > > pages are not either SECTION_INFO or MIX_SECTION_INFO it means that a > > larger corruption happened elsewhere. > > > > But I think I would align the checks here. > > It does not make sense to me to only scream under DEBUG_VM if page's > > refcount differs from 2, and have a WARN_ON if the page we are trying > > to free was not used for the memmap array. > > Both things imply a corruption, so I would set the checks under the same > > configurations. > > Do you suggest changing them all to VM_DEBUG_ON? Or VM_WARN_ON? > > > > > -- > > Oscar Salvador > > SUSE L3 > > > > -- > Yours, > Muchun -- Yours, Muchun