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.8 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 0CE71C5517A for ; Tue, 10 Nov 2020 02:42:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5CE2420809 for ; Tue, 10 Nov 2020 02:42:40 +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="ua6CPMSi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CE2420809 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 946FE6B0036; Mon, 9 Nov 2020 21:42:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F67D6B005C; Mon, 9 Nov 2020 21:42:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BF376B005D; Mon, 9 Nov 2020 21:42:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0001.hostedemail.com [216.40.44.1]) by kanga.kvack.org (Postfix) with ESMTP id 4E6DC6B0036 for ; Mon, 9 Nov 2020 21:42:39 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DDEC41EE6 for ; Tue, 10 Nov 2020 02:42:38 +0000 (UTC) X-FDA: 77466960396.21.death51_4704207272f1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id BC9B1180442C0 for ; Tue, 10 Nov 2020 02:42:38 +0000 (UTC) X-HE-Tag: death51_4704207272f1 X-Filterd-Recvd-Size: 5899 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 02:42:37 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id i26so8864256pgl.5 for ; Mon, 09 Nov 2020 18:42:37 -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=hq04zVLRq/Oo2lQxylxZrXiKhYhzc6TfqjzZNoQvjuk=; b=ua6CPMSivTkkMuhvjWiNRV2yogS0EvNQ/UC0Pjr/Rn5HdVis2pUSXYfVeL9vf1oxGT hCNvfo5Pw164JaLBYdyTMn1I9vyMaw4CPDyGyAAQQEmu/3yS7Cl6BXwukr/Oa/jpVg9f xhB6NeRSUW88dI30uqJwvQecdGD9os2f37RZrOP4CyYParHPpPokLNqLROUP1qzRpHRW 4Xz8hpE/LNMIS/HQqYUbDPSdHz1qHlN5p2bGS/YrOUZ6cg67gUs+3EKEhbwgT8oVzbU8 ObNl0hMOtWmdMLMkZLRkQVtNMbVPLUqFFhotzABsvrZyXICxjp4vW8Sa6WBblNtpCDzE Y8mw== 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=hq04zVLRq/Oo2lQxylxZrXiKhYhzc6TfqjzZNoQvjuk=; b=S8/LhHtuFQvn45mfurbqeljOKQ3ERvMll6DYKVJE8jfBKOvU9inHgyIa5XyZ8pHWC+ rzfLWsK9GBvunV+5aMLAnNYeyqPSHmmjM8EbBcJxCQF3bg5rHF9vm4G94FQcxk4AEMqw ix8k6Ti18twiB30oZxCqWqvsUT9bK8zZSeMG2AHKpmmFziZ2eU3pnFFsAm54tJuqnV/E /zvkPfKDaQYWcUTqceilULp3tbJVNn6KNzldkIhvylOQ8Ih0eZr+UNWEMF1rk6IcVxrk adE37UkB3FHJYPKZrfEbO1bFbB/8Vd1WeIO8ui1rsE/Jykflch1YAvCyE4CqkWEKEtoF UckQ== X-Gm-Message-State: AOAM53027ypUcXWimtpMw0FOTqjw4cGLi+cvUz5yKNdFWTos18DaxdRF 1GniQAbYow1rkDpXtcBym6JMhwUXMc3rydeHw0hpFg== X-Google-Smtp-Source: ABdhPJyrTFLtNejVARR0imvWvzZUIFnztiWYySVLVHRuSDfEWqoJITi1D9tdjXQtR+JXPvE8VQ2dZhviAg5bSaDPVbg= X-Received: by 2002:a17:90a:4749:: with SMTP id y9mr2531336pjg.229.1604976156656; Mon, 09 Nov 2020 18:42:36 -0800 (PST) MIME-Version: 1.0 References: <20201108141113.65450-1-songmuchun@bytedance.com> <20201108141113.65450-5-songmuchun@bytedance.com> <20201109164825.GA17356@linux> In-Reply-To: <20201109164825.GA17356@linux> From: Muchun Song Date: Tue, 10 Nov 2020 10:42:00 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v3 04/21] mm/hugetlb: Introduce nr_free_vmemmap_pages in the struct hstate 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 12:48 AM Oscar Salvador wrote: > > On Sun, Nov 08, 2020 at 10:10:56PM +0800, Muchun Song wrote: > > +#ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP > > +/* > > + * There are 512 struct page structs(8 pages) associated with each 2MB > > + * hugetlb page. For tail pages, the value of compound_dtor is the same. > I gess you meant "For tail pages, the value of compound_head ...", right? Yeah, Thanks. > > > + * So we can reuse first page of tail page structs. We map the virtual > > + * addresses of the remaining 6 pages of tail page structs to the first > > + * tail page struct, and then free these 6 pages. Therefore, we need to > > + * reserve at least 2 pages as vmemmap areas. > > + */ > > +#define RESERVE_VMEMMAP_NR 2U > > + > > +static void __init hugetlb_vmemmap_init(struct hstate *h) > > +{ > > + unsigned int order = huge_page_order(h); > > + unsigned int vmemmap_pages; > > + > > + vmemmap_pages = ((1 << order) * sizeof(struct page)) >> PAGE_SHIFT; > > + /* > > + * The head page and the first tail page not free to buddy system, > > "The head page and the first tail page are not to be freed to..." better? Yeah, sorry for my poor English :). > > > > + * the others page will map to the first tail page. So there are > > + * (@vmemmap_pages - RESERVE_VMEMMAP_NR) pages can be freed. > ^^^ > that > > > + else > > + h->nr_free_vmemmap_pages = 0; > > I would specify that this is not expected to happen. > (At least I could not come up with a real scenario unless the system is > corrupted) > So, I would drop a brief comment pointing out that it is only a safety > net. I will add a comment to point out this. > > > Unrelated to this patch but related in general, I am not sure about Mike but > would it be cleaner to move all the vmemmap functions to hugetlb_vmemmap.c? > hugetlb code is quite tricky, so I am not sure about stuffing more code > in there. > I also think that you are right, moving all the vmemmap functions to hugetlb_vmemmap.c may make the code cleaner. Hi Mike, what's your opinion? Thanks. > -- > Oscar Salvador > SUSE L3 -- Yours, Muchun