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=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 2E9B4C388F9 for ; Thu, 19 Nov 2020 23:37:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7763C22227 for ; Thu, 19 Nov 2020 23:37:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="KbfS9xyo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7763C22227 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7EBD36B0036; Thu, 19 Nov 2020 18:37:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 776D66B005C; Thu, 19 Nov 2020 18:37:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 616306B005D; Thu, 19 Nov 2020 18:37:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id 24EBC6B0036 for ; Thu, 19 Nov 2020 18:37:48 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9A7ED181AEF09 for ; Thu, 19 Nov 2020 23:37:47 +0000 (UTC) X-FDA: 77502782574.22.spade86_571001e27346 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 7BFCA1803B051 for ; Thu, 19 Nov 2020 23:37:47 +0000 (UTC) X-HE-Tag: spade86_571001e27346 X-Filterd-Recvd-Size: 5915 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Thu, 19 Nov 2020 23:37:46 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AJNYp1V138161; Thu, 19 Nov 2020 23:37:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=MszqefOJcdbabdMne6HpW6zW0+wj9g5wPcoppzWfBRw=; b=KbfS9xyoLYd9f+1tXyKP2N9pPIg5wIv5h1lEyTOCL9Zt0uZIPY/9ifXv92/ct+6eDVjV wHfLnCwUxx9Q1YOPRUsv+/lvjU7vKJo1iZ/jnXcfB8Y+BfGIeeUhSxbnpehYWlxSJLd+ Q7hygayEZy8mt+KJsQHshVxJOT9ZQ1qklH7XDFpV6jpznoJp6VwMAXI/JQ7Z+ePVzXRD cvvlkISXBgM/kgJoL5P3cZh8TURAQrb4wx7Szl/3HjrNWJzr2TNd3iyPIJKuz4PnxPwv ImThZf+gpItUVMV441kI05KshfgnaF9Ul8bYtiCy3iZq36mzR1j8xppN7mYP07oxInQy Ng== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 34t7vng7ru-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 19 Nov 2020 23:37:31 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AJNZbnW195048; Thu, 19 Nov 2020 23:37:31 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 34ts0ufh77-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Nov 2020 23:37:31 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0AJNbRN5010801; Thu, 19 Nov 2020 23:37:28 GMT Received: from [192.168.2.112] (/50.38.35.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 19 Nov 2020 15:37:27 -0800 Subject: Re: [PATCH v4 05/21] mm/hugetlb: Introduce pgtable allocation/freeing helpers To: Muchun Song , corbet@lwn.net, 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, osalvador@suse.de, mhocko@suse.com Cc: duanxiongchun@bytedance.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org References: <20201113105952.11638-1-songmuchun@bytedance.com> <20201113105952.11638-6-songmuchun@bytedance.com> From: Mike Kravetz Message-ID: Date: Thu, 19 Nov 2020 15:37:25 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20201113105952.11638-6-songmuchun@bytedance.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9810 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 bulkscore=0 suspectscore=2 spamscore=0 malwarescore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011190162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9810 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=2 malwarescore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 mlxscore=0 priorityscore=1501 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011190162 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 11/13/20 2:59 AM, Muchun Song wrote: > On x86_64, vmemmap is always PMD mapped if the machine has hugepages > support and if we have 2MB contiguos pages and PMD aligned. If we want contiguous alignment > to free the unused vmemmap pages, we have to split the huge pmd firstly. > So we should pre-allocate pgtable to split PMD to PTE. > > Signed-off-by: Muchun Song > --- > mm/hugetlb_vmemmap.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > mm/hugetlb_vmemmap.h | 12 +++++++++ > 2 files changed, 85 insertions(+) Thanks for the cleanup. Oscar made some other comments. I only have one additional minor comment below. With those minor cleanups, Acked-by: Mike Kravetz > diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c ... > +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 */ Let's expland the above comment to something like this: /* * Use the huge page lru list to temporarily store the preallocated * pages. The preallocated pages are used and the list is emptied * before the huge page is put into use. When the huge page is put * into use by prep_new_huge_page() the list will be reinitialized. */ > + 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); > + } > + > + return 0; > +out: > + vmemmap_pgtable_free(page); > + return -ENOMEM; > +} -- Mike Kravetz