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 186B3C433EF for ; Mon, 4 Apr 2022 06:07:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5107F6B0072; Mon, 4 Apr 2022 02:07:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C0EE6B0073; Mon, 4 Apr 2022 02:07:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D66F6B0074; Mon, 4 Apr 2022 02:07:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 2FC906B0072 for ; Mon, 4 Apr 2022 02:07:28 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E6C03219F5 for ; Mon, 4 Apr 2022 06:07:17 +0000 (UTC) X-FDA: 79318164156.04.E57591E Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf27.hostedemail.com (Postfix) with ESMTP id 39F2640002 for ; Mon, 4 Apr 2022 06:07:17 +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 41C611FB; Sun, 3 Apr 2022 23:07:16 -0700 (PDT) Received: from [10.163.36.163] (unknown [10.163.36.163]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 308183F5A1; Sun, 3 Apr 2022 23:07:13 -0700 (PDT) Message-ID: <327008f1-bcd2-9c3b-46a0-523054f757d7@arm.com> Date: Mon, 4 Apr 2022 11:37:41 +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: rspam06 X-Rspamd-Queue-Id: 39F2640002 X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf27.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com X-Stat-Signature: b14tukwh38i4y4irfqi65ea4ikr89yqa X-HE-Tag: 1649052437-649248 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 Reviewed-by: Anshuman Khandual > > --- > > 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? > > 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) >