Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1109974iog; Wed, 15 Jun 2022 21:49:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1umfPSARAmzUF61JKNyGAxWicom6Lyt6R85JiE6yFELeuMMyuYUpdYS6pmHGG9D9ZaxOvht X-Received: by 2002:a17:906:2dd:b0:712:1293:3dd8 with SMTP id 29-20020a17090602dd00b0071212933dd8mr2909995ejk.448.1655354939824; Wed, 15 Jun 2022 21:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655354939; cv=none; d=google.com; s=arc-20160816; b=wf4TxJ/yPJE7DS/sql/wG3/CCjixMizJu6jqc5Ix07gmv5zjWCg3OlS/ys3TLCPvoe 8N8si53zpUrK+ec+3Sz/EjLfZZxI4E+XJt1y9q1qbCYs+xEG9MZypJC+U/d03LY7eOh0 O8UvsvG/2HRrxS8ckESs5lsk4uMXnA9E2lNcblPwalw3SGyIFp41pT+OmnSL3pNXUyuh dEdpRCzV2XNRxHj1+tRQICzViUb8To59ZwsS6HPxeS93VdoYS7iMFy0uUwwXE6LFA+3e cz7lo/vxC1/9X6WNrWJMo0wxDyg+HFHAg0eodMgCKEzJWSZltUUGmsUT6vi7qdEJdyZG P0kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=rhDsRADDozE0niD1YpvDAsefpLPuQqyvPUzxhA1noZY=; b=xSyxsxHpl+jThoM0rC7pgFYuZa9fwd8Kk+r8OpU/XzTNC3WR95wgJGvk0lbaWviHGE T5MWaDC16qIgV6jFA4TjioCiVNaIlbv12e9qSEcXb5Ob6JjZv1QltudZOMcFrgD0rzH8 sTcZpqy9SMJVTAGEpk4dkWqIruYMBJOVlpNcsfJA0TKU7+hatA15RhlXCo1xJuWAdTFp xAwdJ6lH9nyFHClMAlwtUhmb4m1AyDxtY3HmPIv+db28vzTILSqNV2fe4GIVMhVzvFMe miypXr8VKni9Lu/bChtrK94kr22QaA4Yq6b013N/0EtNDHK0fqjZTZgJ7HTwK9BL5ofd 8IVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 9-20020a17090602c900b006fedebfbfdcsi640815ejk.239.2022.06.15.21.48.29; Wed, 15 Jun 2022 21:48:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347238AbiFPDfX (ORCPT + 99 others); Wed, 15 Jun 2022 23:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346612AbiFPDfU (ORCPT ); Wed, 15 Jun 2022 23:35:20 -0400 Received: from out30-56.freemail.mail.aliyun.com (out30-56.freemail.mail.aliyun.com [115.124.30.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E191742493 for ; Wed, 15 Jun 2022 20:35:18 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0VGVdsvf_1655350515; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VGVdsvf_1655350515) by smtp.aliyun-inc.com; Thu, 16 Jun 2022 11:35:16 +0800 From: Baolin Wang To: mike.kravetz@oracle.com Cc: songmuchun@bytedance.com, akpm@linux-foundation.org, catalin.marinas@arm.com, will@kernel.org, anshuman.khandual@arm.com, baolin.wang@linux.alibaba.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] arm64/hugetlb: Implement arm64 specific hugetlb_mask_last_hp Date: Thu, 16 Jun 2022 11:34:58 +0800 Message-Id: <7256dbe078d7231f45b0f47c2c52a3bd3aa10da7.1655350193.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The HugeTLB address ranges are linearly scanned during fork, unmap and remap operations, and the linear scan can skip to the end of range mapped by the page table page if hitting a non-present entry, which can help to speed linear scanning of the HugeTLB address ranges. So hugetlb_mask_last_hp() is introduced to help to update the address in the loop of HugeTLB linear scanning with getting the last huge page mapped by the associated page table page[1], when a non-present entry is encountered. Considering ARM64 specific cont-pte/pmd size HugeTLB, this patch implemented an ARM64 specific hugetlb_mask_last_hp() to help this case. [1] https://lore.kernel.org/linux-mm/20220527225849.284839-1-mike.kravetz@oracle.com/ Signed-off-by: Baolin Wang --- Note: this patch is based on the series: "hugetlb: speed up linear address scanning" from Mike. Mike, please fold it into your series. Thanks. --- arch/arm64/mm/hugetlbpage.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index e2a5ec9..958935c 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -368,6 +368,26 @@ 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 PUD_SIZE: + return PGDIR_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; +} + pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags) { size_t pagesize = 1UL << shift; -- 1.8.3.1