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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 D54D8C2D0A3 for ; Mon, 9 Nov 2020 16:48:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 472D121D46 for ; Mon, 9 Nov 2020 16:48:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 472D121D46 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BB2886B005C; Mon, 9 Nov 2020 11:48:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B88626B006C; Mon, 9 Nov 2020 11:48:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A774B6B0070; Mon, 9 Nov 2020 11:48:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0076.hostedemail.com [216.40.44.76]) by kanga.kvack.org (Postfix) with ESMTP id 7BE9B6B005C for ; Mon, 9 Nov 2020 11:48:35 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1B5BD1EE6 for ; Mon, 9 Nov 2020 16:48:35 +0000 (UTC) X-FDA: 77465463390.01.vase74_5017845272ee Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id E999C10045EE0 for ; Mon, 9 Nov 2020 16:48:34 +0000 (UTC) X-HE-Tag: vase74_5017845272ee X-Filterd-Recvd-Size: 3414 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Nov 2020 16:48:34 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 066FEAB95; Mon, 9 Nov 2020 16:48:33 +0000 (UTC) Date: Mon, 9 Nov 2020 17:48:29 +0100 From: Oscar Salvador To: Muchun Song Cc: corbet@lwn.net, mike.kravetz@oracle.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, rdunlap@infradead.org, oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, almasrymina@google.com, rientjes@google.com, willy@infradead.org, mhocko@suse.com, duanxiongchun@bytedance.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v3 04/21] mm/hugetlb: Introduce nr_free_vmemmap_pages in the struct hstate Message-ID: <20201109164825.GA17356@linux> References: <20201108141113.65450-1-songmuchun@bytedance.com> <20201108141113.65450-5-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201108141113.65450-5-songmuchun@bytedance.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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 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? > + * 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? > + * 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. 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. -- Oscar Salvador SUSE L3