From patchwork Wed Jul 25 14:06:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10544073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 529A3180E for ; Wed, 25 Jul 2018 14:07:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 412B32022C for ; Wed, 25 Jul 2018 14:07:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34EEE206E2; Wed, 25 Jul 2018 14:07:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.4 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,SUSPICIOUS_RECIPS autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E88CD2022C for ; Wed, 25 Jul 2018 14:07:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=TzD6lumWC210nINDxXSJzo/ZdqP2GyTka0QdK1LnKsU=; b=dW3bb4CtSNmLDtVz5ofTq6vDxl eBMdcY48Xj+N+lETAn2yacqlZ4PLfw0EhPu0mCAVkIaSfjOpvknIgzsFWPXPp659yhUE1cp2G2ptZ Yjok32fjzt+CPC5tGLrGSYjIf6k5mzgMcZdSZN59+F31jDVd0n30tMt6uBt3pjqaLW/7C097tkrmF lcZi2wi0bfKosyq0lsE2NrlsRpKmA4lMB4+f4CeG4Yq06TnmI6ju5rAbF6lU9ywizKiJoZdAxgZrb q61vKGw77YY0i2yCPyA5i6xmz0KX0rZLJpV4NfVaI+UPCuBGnawopjrScZ5q9X3AdVG/P0I5H4NFM k/iyUMzA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fiKRt-0004AH-JC; Wed, 25 Jul 2018 14:07:29 +0000 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fiKRZ-0003ps-8a for linux-arm-kernel@lists.infradead.org; Wed, 25 Jul 2018 14:07:27 +0000 Received: by mail-pl0-x244.google.com with SMTP id m1-v6so3340862plt.6 for ; Wed, 25 Jul 2018 07:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7UxphlsljR+NlBYsTH8Esis+vxdkqmrjRFhGi68hhJU=; b=XYwUKztUXh78GoFkh5YY9kJxt1SDxMMuG1PsEcnsnNXBRKhePtsbFe3AnAfT9CnG3F 76/aXAEa+jKfRKzD3EGLQyJIfLNGmBxyLEU0g26pqCCN/WXJp6Lujfr1lcShyyN7SPG0 qjVS9IbZDC422uQn8tJgc3XkOhmB2XNE/iJPkLuBI8+/Rt/gEfGPYhVpzTYms+vjMJ9s QYzif4mG6CltSruM3MlDSCP5mE/r+BLYQGDtpyb/sflG1t/JHyat7zeoRQ/rC8gaq3cg onN8GAHAJnDbEckhAAw0JxwVqJKWGpbISgM0TewXOwIdXnNuIJkzCEMnnPSzUa7SNFd0 G6LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7UxphlsljR+NlBYsTH8Esis+vxdkqmrjRFhGi68hhJU=; b=i615YfszzZKyUNE9ba4huhKkJaZ+c2riKqahoX8ckdComs43bJko91aN4dAf+uiwzP odoz7YXdN0ZLXl5ZVg+f4yV/9RmWvum6fgaJNBbIPcBHdoub5YwN0/k4rjJIWY/GtObI mNd90se4t/2kh8XLiyNYdpFToT4fSQmDgy2uXz6xoU3Fbd2JF9gDyBTdE0StWYNZH/xY Xyt5gwAMTZ07pkq0dOuGv/XodKdNamHi8JNfYjLIfP3WjeWgzb5BcDjd+GwA8xmVfU9K 4PAH6FSArffh8ZdBV168ZbDxGetgPUwEXWj+wv9tw1a+usGuhf2YWryb29FFZKQIwnce lt/A== X-Gm-Message-State: AOUpUlEi3UpCxizdEKrOfD+KJoKDYaPsmnssmwE6x9gggpz8EKM0diIr V81Ph+ZCX+CZ/UEVRP77m8A= X-Google-Smtp-Source: AAOMgpdCqh7xbrmOwc7Mb7NkJWlmmf0rHmvB7dgvBNPoBO+OeJs5vUqKg07Ng8VHsiopNqqLXn0+RA== X-Received: by 2002:a17:902:2f43:: with SMTP id s61-v6mr20949070plb.274.1532527618840; Wed, 25 Jul 2018 07:06:58 -0700 (PDT) Received: from roar.au.ibm.com ([61.69.188.107]) by smtp.gmail.com with ESMTPSA id d132-v6sm20923421pga.10.2018.07.25.07.06.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 07:06:57 -0700 (PDT) From: Nicholas Piggin To: linux-mm@kvack.org Subject: [RFC PATCH 2/4] mm: mmu_notifier fix for tlb_end_vma Date: Thu, 26 Jul 2018 00:06:39 +1000 Message-Id: <20180725140641.30372-3-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180725140641.30372-1-npiggin@gmail.com> References: <20180725140641.30372-1-npiggin@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180725_070709_599196_6B0198A4 X-CRM114-Status: GOOD ( 13.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, Nicholas Piggin MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The generic tlb_end_vma does not call invalidate_range mmu notifier, and it resets resets the mmu_gather range, which means the notifier won't be called on part of the range in case of an unmap that spans multiple vmas. ARM64 seems to be the only arch I could see that has notifiers and uses the generic tlb_end_vma. I have not actually tested it. --- include/asm-generic/tlb.h | 17 +++++++++++++---- mm/memory.c | 10 ---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 3063125197ad..b3353e21f3b3 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -15,6 +15,7 @@ #ifndef _ASM_GENERIC__TLB_H #define _ASM_GENERIC__TLB_H +#include #include #include #include @@ -138,6 +139,16 @@ static inline void __tlb_reset_range(struct mmu_gather *tlb) } } +static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb) +{ + if (!tlb->end) + return; + + tlb_flush(tlb); + mmu_notifier_invalidate_range(tlb->mm, tlb->start, tlb->end); + __tlb_reset_range(tlb); +} + static inline void tlb_remove_page_size(struct mmu_gather *tlb, struct page *page, int page_size) { @@ -186,10 +197,8 @@ static inline void tlb_remove_check_page_size_change(struct mmu_gather *tlb, #define __tlb_end_vma(tlb, vma) \ do { \ - if (!tlb->fullmm && tlb->end) { \ - tlb_flush(tlb); \ - __tlb_reset_range(tlb); \ - } \ + if (!tlb->fullmm) \ + tlb_flush_mmu_tlbonly(tlb); \ } while (0) #ifndef tlb_end_vma diff --git a/mm/memory.c b/mm/memory.c index bc053d5e9d41..135d18b31e44 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -238,16 +238,6 @@ void arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, __tlb_reset_range(tlb); } -static void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb) -{ - if (!tlb->end) - return; - - tlb_flush(tlb); - mmu_notifier_invalidate_range(tlb->mm, tlb->start, tlb->end); - __tlb_reset_range(tlb); -} - static void tlb_flush_mmu_free(struct mmu_gather *tlb) { struct mmu_gather_batch *batch;