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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74E4EC433EF for ; Thu, 16 Jun 2022 03:48:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2B176B0072; Wed, 15 Jun 2022 23:48:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BDA4B6B0073; Wed, 15 Jun 2022 23:48:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA1816B0074; Wed, 15 Jun 2022 23:48:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9B2AF6B0072 for ; Wed, 15 Jun 2022 23:48:55 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 75C48600CC for ; Thu, 16 Jun 2022 03:48:55 +0000 (UTC) X-FDA: 79582717830.26.1F26915 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by imf05.hostedemail.com (Postfix) with ESMTP id 046B6100078 for ; Thu, 16 Jun 2022 03:48:53 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0VGVio0B_1655351328; Received: from 30.97.48.140(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VGVio0B_1655351328) by smtp.aliyun-inc.com; Thu, 16 Jun 2022 11:48:49 +0800 Message-ID: <255ccf96-2c12-9ca0-9f8b-8a8461253952@linux.alibaba.com> Date: Thu, 16 Jun 2022 11:48:56 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [RFC PATCH 1/3] hugetlb: skip to end of PT page mapping when pte not present To: Mike Kravetz Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Muchun Song , Michal Hocko , Peter Xu , Naoya Horiguchi , James Houghton , Mina Almasry , "Aneesh Kumar K . V" , Anshuman Khandual , Paul Walmsley , Christian Borntraeger , Andrew Morton References: <20220527225849.284839-1-mike.kravetz@oracle.com> <20220527225849.284839-2-mike.kravetz@oracle.com> <437e45c5-c46a-46f4-f9cf-d8c2397c988d@linux.alibaba.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655351335; a=rsa-sha256; cv=none; b=Gqs7IuYTzyCpmYpVS4ixscFUaC56qCF9HjMNbbi4tPzyXVvqKjkXSyFnNF89PyMs3Fimkd Chx3i7vLEkZ6CzfR/HUyCt16JCD1u/h8DqtjMPhwszaV1tCz+zXgLA4IGVJMawr9UhQIzC AaPQqcXeuYuI1P142jBmvCNcz9LMNls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655351335; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pt76fFoglzWVv+xjPkaKbP7+eXqOx55pI7qy+ptPWTU=; b=L37dF8HIieO9W9bSf/6zi5Jsx9mE3RgXLvhjmDOrwaZ2zYBt/tUlM8xH1Q5PoRhlplV1E0 yklD+qwqggBIi4BJOTWL+ggRNz5kxtEjx/qA3vEei3nxS0SyfRdWYa1E42v/cSWeGxvQC+ YGRNJD+XLYMnCDouxcrQxvKh9E7WpPo= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf05.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.45 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf05.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.45 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 046B6100078 X-Stat-Signature: uibc659zdcigmx67y44884cjrzxts73i X-HE-Tag: 1655351333-559603 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 6/16/2022 5:22 AM, Mike Kravetz wrote: > On 05/30/22 18:10, Baolin Wang wrote: >> >> >> On 5/28/2022 6:58 AM, Mike Kravetz wrote: >>> HugeTLB address ranges are linearly scanned during fork, unmap and >>> remap operations. If a non-present entry is encountered, the code >>> currently continues to the next huge page aligned address. However, >>> a non-present entry implies that the page table page for that entry >>> is not present. Therefore, the linear scan can skip to the end of >>> range mapped by the page table page. This can speed operations on >>> large sparsely populated hugetlb mappings. >>> >>> Create a new routine hugetlb_mask_last_hp() that will return an >>> address mask. When the mask is ORed with an address, the result >>> will be the address of the last huge page mapped by the associated >>> page table page. Use this mask to update addresses in routines which >>> linearly scan hugetlb address ranges when a non-present pte is >>> encountered. >>> >>> hugetlb_mask_last_hp is related to the implementation of huge_pte_offset >>> as hugetlb_mask_last_hp is called when huge_pte_offset returns NULL. >>> This patch only provides a complete hugetlb_mask_last_hp implementation >>> when CONFIG_ARCH_WANT_GENERAL_HUGETLB is defined. Architectures which >>> provide their own versions of huge_pte_offset can also provide their own >>> version of hugetlb_mask_last_hp. >> >> I tested on my ARM64 machine with implementing arm64 specific >> hugetlb_mask_last_hp() as below, and it works well. >> >> Just a few nits inline, otherwise looks good to me. >> Tested-by: Baolin Wang >> Reviewed-by: Baolin Wang >> >> diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c >> index d93ba128a2b0..e04a097ffcc4 100644 >> --- a/arch/arm64/mm/hugetlbpage.c >> +++ b/arch/arm64/mm/hugetlbpage.c >> @@ -376,6 +376,28 @@ pte_t *huge_pte_offset(struct mm_struct *mm, >> return NULL; >> } >> >> +unsigned long hugetlb_mask_last_hp(struct hstate *h) >> +{ >> + unsigned long hp_size = huge_page_size(h); >> + >> + switch (hp_size) { >> + case P4D_SIZE: >> + return PGDIR_SIZE - P4D_SIZE; >> + case PUD_SIZE: >> + return P4D_SIZE - PUD_SIZE; >> + case CONT_PMD_SIZE: >> + return PUD_SIZE - CONT_PMD_SIZE; >> + case PMD_SIZE: >> + return PUD_SIZE - PMD_SIZE; >> + case CONT_PTE_SIZE: >> + return PMD_SIZE - CONT_PTE_SIZE; >> + default: >> + break; >> + } >> + >> + return ~(0UL); >> +} > > Hello Baolin, > > Would you mind sending this as a proper patch with commit message and > 'Signed-off-by:'? I would like to include it in the upcoming patch series. Sure. I've sent it out [1], and please fold it into your series. Thanks. [1] https://lore.kernel.org/all/7256dbe078d7231f45b0f47c2c52a3bd3aa10da7.1655350193.git.baolin.wang@linux.alibaba.com/