Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1806504rwd; Thu, 15 Jun 2023 16:20:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6LXEwfmWwoZmwzsWiB2MMWU7rsSMd2eZXEpeOvZm1KQYhmxRa2I98lbmhYuDLGFfVDjMLT X-Received: by 2002:a17:902:e847:b0:1af:a2a4:837f with SMTP id t7-20020a170902e84700b001afa2a4837fmr433594plg.26.1686871233936; Thu, 15 Jun 2023 16:20:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686871233; cv=none; d=google.com; s=arc-20160816; b=l7ganqZYT/6EjjMK3ghHHnBxaWhXbRNoTIseQ4WaQhX4TU48dkEJtNiRJdnX6qeIp5 HBU5ssVtQ79GQU8thwzzzfET4I2SQF0u4GgYxxS2Aq99ANEsxj7mXRDZvKogsgxIrqxD fzTP062Xm79jXFQy3AnV6/LSP2hjK38Sg6dg6FE/W9FEkM2/B+9N9bCavSMbjoobEXzQ SvAwNQQWdhUQ4i5urXV7ekxLjzoeQ+mhn37ApycQTqSxxKY1rRjG8i9CdY5O46qrwH1o UdWGMUe/jGFkBWUU0Mmssn5FOutwTItX/hlCrl8Pnah4fD0aTX3+PxYD7OZxQlhnn7Dq Iasg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=rocsqxxn2Z+cT1JHYvXfzCdKlHTpr3EP6mTFGVcBZg0=; b=nBkvHP3+VnUXbirAIi1R2q4QQFtyFU578z9Ijwcd1p2rS4YTJN4KDfMtIwxxFOu3wU b434ajkdDzXk1MPAFU7ubS1V+LkdjeJXSv3Qo4YcKxqeU+AsABjorP49iOtQUesktPj0 IBcOC90r1E6XAUsjfSFnmvj0XvAXZf+uZDB7Zp/ik62x5OzD76e89iwL3cJqjx52el/g 3QqS9ayNDn+x4mEMGEMUy/VkYrPOr586WD1oaeTvaWQ2daWN7UXqeG/KG0nL6eOpuQas /xRkEyxd2Xzcoya35ckewMWzXDi7CPNh/aMJd18Av9IjPdDUkGqEG6FzCTudtC7HDhgN umxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=MJTZvP19; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a17090301c700b001b1cdef2654si10332094plh.645.2023.06.15.16.20.18; Thu, 15 Jun 2023 16:20:33 -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; dkim=pass header.i=@google.com header.s=20221208 header.b=MJTZvP19; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230090AbjFOXDB (ORCPT + 99 others); Thu, 15 Jun 2023 19:03:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbjFOXC6 (ORCPT ); Thu, 15 Jun 2023 19:02:58 -0400 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7947C294D for ; Thu, 15 Jun 2023 16:02:55 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-bd20beffda6so36232276.1 for ; Thu, 15 Jun 2023 16:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686870174; x=1689462174; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=rocsqxxn2Z+cT1JHYvXfzCdKlHTpr3EP6mTFGVcBZg0=; b=MJTZvP19w7L3mwEdMeExhSCW1AUDkDcDZIGA09b4Lsgr6AlQ/Jre5s3pQVCVJJ7rQb 5+EQMNtJaTaY+aRJKrCSqlImib7KZddKIew66TbvLd683FL9AyfE66fgz1T7BtZHDMm8 2jNBCticE3VbvZxgnHDLhllKeMXxMDja6NYMekmWJVMnL0qXYLEhZcbBya6ztZKzets8 eOxxHJ/YfIwfRnvaqFcbsGZUKRVZaOyJdqvanJIQ7D74NV/Gvoq+dfmVK1oXzh1JvH5P 0RtdON+E/jvZHQ2QI/6IDa9W4KDnatFP6KwfH05hk8Ymf0ujYFguYsacUpxAce6WF76M r8mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686870174; x=1689462174; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rocsqxxn2Z+cT1JHYvXfzCdKlHTpr3EP6mTFGVcBZg0=; b=OopcDHP9kbSMEe+zEtNgkJgJAlo0NZzCqAk0LxvYX01e7Bptk/zr2EoR6zZcOKqxM7 D8Pi64KvYlRKKnnfHvUYTkLY8x2GK1ZbPj35Hz7IRdBo68iT1YuDfokRFbpSDEBtf10D utSbzKq1W3ok9fIB77mKAYxaSD6iMTPn2WBMYFbj5arZ9WkTtcfjom7Q7Kloh3IWa1iK KvFc2dY3ZzOVqyOeh3++yNztH3Fu3APsHqH/yXEmAAspHh/WJkqo6tCtuPtu6PlyzKdj sMdeHVj3+BFMCNOcdFG7SVEjbMqOE1hpIr77Y45JQ2ZZci4kclgONg90/v71UBEgesvb Se/A== X-Gm-Message-State: AC+VfDxcfmW+sRqlY1cR5Pcd2j9V3CufWJHDEgAFDvENtvaDVlqhcI1+ GZ2YTDXe2ePorRQFLHyVRwR81g== X-Received: by 2002:a81:7bd5:0:b0:56d:2dd6:c5b3 with SMTP id w204-20020a817bd5000000b0056d2dd6c5b3mr138534ywc.31.1686870174477; Thu, 15 Jun 2023 16:02:54 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id w6-20020a0ded06000000b0056d2a19ad91sm2857020ywe.103.2023.06.15.16.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 16:02:54 -0700 (PDT) Date: Thu, 15 Jun 2023 16:02:43 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Nathan Chancellor , Hugh Dickins , Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , Yu Zhao , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 07/23 replacement] mips: add pte_unmap() to balance pte_offset_map() In-Reply-To: <76b41825-30fa-b9e8-d043-2affcba24317@google.com> Message-ID: References: <178970b0-1539-8aac-76fd-972c6c46ec17@google.com> <20230614231758.GA1503611@dev-arch.thelio-3990X> <344a4da-3890-45fd-607e-b5f85ca6ad48@google.com> <20230615155059.GB3665766@dev-arch.thelio-3990X> <76b41825-30fa-b9e8-d043-2affcba24317@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 To keep balance in future, __update_tlb() remember to pte_unmap() after pte_offset_map(). This is an odd case, since the caller has already done pte_offset_map_lock(), then mips forgets the address and recalculates it; but my two naive attempts to clean that up did more harm than good. Tested-by: Nathan Chancellor Signed-off-by: Hugh Dickins --- Andrew, please replace my mips patch, and its build warning fix patch, in mm-unstable by this less ambitious but working replacement - thanks. arch/mips/mm/tlb-r4k.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index 1b939abbe4ca..93c2d695588a 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -297,7 +297,7 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) p4d_t *p4dp; pud_t *pudp; pmd_t *pmdp; - pte_t *ptep; + pte_t *ptep, *ptemap = NULL; int idx, pid; /* @@ -344,7 +344,12 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) } else #endif { - ptep = pte_offset_map(pmdp, address); + ptemap = ptep = pte_offset_map(pmdp, address); + /* + * update_mmu_cache() is called between pte_offset_map_lock() + * and pte_unmap_unlock(), so we can assume that ptep is not + * NULL here: and what should be done below if it were NULL? + */ #if defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32) #ifdef CONFIG_XPA @@ -373,6 +378,9 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) tlbw_use_hazard(); htw_start(); flush_micro_tlb_vm(vma); + + if (ptemap) + pte_unmap(ptemap); local_irq_restore(flags); } -- 2.35.3