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 89E0DC433F5 for ; Wed, 30 Mar 2022 14:04:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6EBC8D0002; Wed, 30 Mar 2022 10:04:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E1E4A8D0001; Wed, 30 Mar 2022 10:04:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0D548D0002; Wed, 30 Mar 2022 10:04:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id C2A618D0001 for ; Wed, 30 Mar 2022 10:04:01 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 988A2801DE for ; Wed, 30 Mar 2022 14:04:01 +0000 (UTC) X-FDA: 79301221482.10.DC74A07 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 7DD34180006 for ; Wed, 30 Mar 2022 14:03:59 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 78A2423A; Wed, 30 Mar 2022 07:03:58 -0700 (PDT) Received: from [192.168.225.237] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D1B783F73B; Wed, 30 Mar 2022 07:03:55 -0700 (PDT) Message-ID: Date: Wed, 30 Mar 2022 19:34:16 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2] tlb: hugetlb: Add more sizes to tlb_remove_huge_tlb_entry Content-Language: en-US To: Steve Capper , linux-mm@kvack.org Cc: David Hildenbrand , Peter Zijlstra , Catalin Marinas , Will Deacon References: <8d5f53c2-2e67-66e4-6453-946a62d5ee98@arm.com> <20220330112543.863-1-steve.capper@arm.com> From: Anshuman Khandual In-Reply-To: <20220330112543.863-1-steve.capper@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7DD34180006 X-Stat-Signature: w9mf195jkf3y1jkxh4fzqgh83unz31yk Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com X-Rspam-User: X-HE-Tag: 1648649039-461456 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 3/30/22 16:55, Steve Capper wrote: > tlb_remove_huge_tlb_entry only considers PMD_SIZE and PUD_SIZE when > updating the mmu_gather structure. > > Unfortunately on arm64 there are two additional huge page sizes that > need to be covered: CONT_PTE_SIZE and CONT_PMD_SIZE. Where an end-user > attempts to employ contiguous huge pages, a VM_BUG_ON can be experienced > due to the fact that the tlb structure hasn't been correctly updated by > the relevant tlb_flush_p.._range() call from tlb_remove_huge_tlb_entry. > > This patch adds inequality logic to the generic implementation of > tlb_remove_huge_tlb_entry s.t. CONT_PTE_SIZE and CONT_PMD_SIZE are > effectively covered on arm64. Also, as well as ptes, pmds and puds; > p4ds are now considered too. > > Reported-by: David Hildenbrand > Suggested-by: Peter Zijlstra (Intel) > Cc: Anshuman Khandual > Cc: Catalin Marinas > Cc: Will Deacon > Link: https://lore.kernel.org/linux-mm/811c5c8e-b3a2-85d2-049c-717f17c3a03a@redhat.com/ > Signed-off-by: Steve Capper > > --- > > Changed in V2: instead of doing the per-arch implementation of > tlb_remove_huge_tlb_entry we add to the generic implmentation, as > suggested by PeterZ. > > This works well on arm64 with contiguous PTEs/PMDs. Does this look > reasonable to the ppc folk? I am wondering whether this should take care of gigantic PGDIR_SIZE based HugeTLB pages as well ? Although, it will require another new helper tlb_flush_pgd_range(). Any thoughts ? > > Cheers, > -- > Steve > --- > include/asm-generic/tlb.h | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h > index 2c68a545ffa7..71942a1c642d 100644 > --- a/include/asm-generic/tlb.h > +++ b/include/asm-generic/tlb.h > @@ -565,10 +565,14 @@ static inline void tlb_flush_p4d_range(struct mmu_gather *tlb, > #define tlb_remove_huge_tlb_entry(h, tlb, ptep, address) \ > do { \ > unsigned long _sz = huge_page_size(h); \ > - if (_sz == PMD_SIZE) \ > - tlb_flush_pmd_range(tlb, address, _sz); \ > - else if (_sz == PUD_SIZE) \ > + if (_sz >= P4D_SIZE) \ > + tlb_flush_p4d_range(tlb, address, _sz); \ > + else if (_sz >= PUD_SIZE) \ > tlb_flush_pud_range(tlb, address, _sz); \ > + else if (_sz >= PMD_SIZE) \ > + tlb_flush_pmd_range(tlb, address, _sz); \ > + else \ > + tlb_flush_pte_range(tlb, address, _sz); \ > __tlb_remove_tlb_entry(tlb, ptep, address); \ > } while (0) >