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 0C940C43334 for ; Thu, 16 Jun 2022 12:05:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 717BE6B0073; Thu, 16 Jun 2022 08:05:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C7A56B0074; Thu, 16 Jun 2022 08:05:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 568886B0075; Thu, 16 Jun 2022 08:05:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4592A6B0073 for ; Thu, 16 Jun 2022 08:05:13 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 0BF0280DD6 for ; Thu, 16 Jun 2022 12:05:13 +0000 (UTC) X-FDA: 79583968506.06.E9736BB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 6EBF6800A5 for ; Thu, 16 Jun 2022 12:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655381112; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TICsQghcR62JQXfxCsN53MgwAaUAtpaLR2E5wd3Qxuo=; b=MceYUEA3rGXtZbUKdpQDgBsAG/BM+MsGDnou3C4pTdxOX5AthKjIWtYdm1XUjxINbL8v9e ye2hqB5AKKhF0q1NVzkks2CAM6Ach51ogeG8ObgbdWUURkOjegxIVHNsHGxaIVLKA0pSBl EpDenDRLHpaG8IYocBedgaPAx61WhBE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-339-nZelTl9LNsafj9LSI5mfmQ-1; Thu, 16 Jun 2022 08:05:09 -0400 X-MC-Unique: nZelTl9LNsafj9LSI5mfmQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2DDE110665A4; Thu, 16 Jun 2022 12:05:08 +0000 (UTC) Received: from localhost (ovpn-12-237.pek2.redhat.com [10.72.12.237]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 61FA6404E4C3; Thu, 16 Jun 2022 12:05:07 +0000 (UTC) Date: Thu, 16 Jun 2022 20:05:03 +0800 From: Baoquan He To: Baolin Wang Cc: mike.kravetz@oracle.com, songmuchun@bytedance.com, akpm@linux-foundation.org, catalin.marinas@arm.com, will@kernel.org, anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] arm64/hugetlb: Implement arm64 specific hugetlb_mask_last_hp Message-ID: References: <7256dbe078d7231f45b0f47c2c52a3bd3aa10da7.1655350193.git.baolin.wang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7256dbe078d7231f45b0f47c2c52a3bd3aa10da7.1655350193.git.baolin.wang@linux.alibaba.com> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655381112; a=rsa-sha256; cv=none; b=IXusq7cRihCLL2Y7zOcVPFLNjUBkjNZr3j08X9ay1t0QidmzhvGjmf0bj2MAMjv57v3Fmp DAXQqqfUaIDmtJ+/1QM+wgmAFqpfFU71yMp/jJJHvyuNjry/5DIVlcTzOEQ0EUZtxuaGvH oapWMEHggcJZkteoc+afZ8GR0VlurkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655381112; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TICsQghcR62JQXfxCsN53MgwAaUAtpaLR2E5wd3Qxuo=; b=8Wywr+xP+dEuhi2F0bb5CdNOhA78f08wwmrKZ2H2rJ1xfutpwI1AW7QijLanpEnjOXzxWM o3aLbvJGwMGtjBHkYurq6dRm89kkSM5USnlnjdpZj6RHLM+LHCP9unDTlBfs2EGo45HUN9 2hSYutyvpeNZMde5GApMte42UxLGXps= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MceYUEA3; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf30.hostedemail.com: domain of bhe@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=bhe@redhat.com Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MceYUEA3; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf30.hostedemail.com: domain of bhe@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=bhe@redhat.com X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 6EBF6800A5 X-Stat-Signature: dgthj89ep3ank6i76qx9r6onr71qea1d X-HE-Tag: 1655381112-260591 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 06/16/22 at 11:34am, Baolin Wang wrote: > 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); hp_size may not be a good name, it reminds me of hotplug. I would name it hpage_size even though a little more characters are added. > + > + 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 > >