Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1096531iog; Wed, 15 Jun 2022 21:16:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sN6QMaHyPtwUYeNG5xptF2pn1XYUvPT1rnWVLTJx58oEQo9kaVooA69pafUVvMd9U4qlka X-Received: by 2002:a62:6410:0:b0:4f3:9654:266d with SMTP id y16-20020a626410000000b004f39654266dmr2910591pfb.59.1655352984118; Wed, 15 Jun 2022 21:16:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655352984; cv=none; d=google.com; s=arc-20160816; b=SkCpfSby5jArKmQG9Pdo201s8dxWwXWHHbxywey9mgnKo4Zlv4BLYMv6tmJ4UsN3jQ us8rgNrAUvhItxc8gdqcNwasPQ5UyvjDMtzPpOC7KpNfXl1CF/Mf/Trf2/SGH4FU2iqz N0mWyawixEGDw+YdU5OnzPyoMQQjcOnbbKClx3WZ6ESJiLPxaFrCHD3dfIGrpjaGkdF5 moOei71pqhl2PdK7Gke73LIRK8x16GUIt2O9hoYf6vwWOVBPPzPGDFK5GHyO/6lBescc M9uGkrTttEY2Ibwl1ez4r6FTl/mvTGKnZ4g84DaCcHZETU+tCxbB5DDrepj5Xzcce5ak zFCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=pt76fFoglzWVv+xjPkaKbP7+eXqOx55pI7qy+ptPWTU=; b=knjpvxkUtQTouJ0WZU+4z29ORtis7IYxmTGHvVFuX82W9Z/sk47xBH/xCzWvzywQYr TwUVc99Yo1sfmpl4qi34rdT5DKJ6iSvz90Q+CKffr3Y3GYjIyezqdbjMY7oEjE1ZD2Ld Kx9Z7jM137mUUeJciC6zmpRsbGotr6OIgA5wWnxUj8yFEO90vSMnetanYjLQgn+ShHD/ tPgdwKCQV35qCcjzQrkepDqO3COWcHcwY50BNy4DAjpJBAhTaIbN/VqDtzNp4TlL9r/w gH/jWWg5MpGEg3kMO+a7EgG7nlM7TvQ3hITK2ifp0QE8C7Nf7Ys6MDlV6HkoNuG9qci3 2UUA== 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 f30-20020a63511e000000b003db48a0c6ecsi1039314pgb.792.2022.06.15.21.16.11; Wed, 15 Jun 2022 21:16:24 -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 S1358430AbiFPDs5 (ORCPT + 99 others); Wed, 15 Jun 2022 23:48:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346612AbiFPDsz (ORCPT ); Wed, 15 Jun 2022 23:48:55 -0400 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E129045059 for ; Wed, 15 Jun 2022 20:48:53 -0700 (PDT) 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 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,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 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/