From patchwork Fri Jul 6 17:10:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rik van Riel X-Patchwork-Id: 10512157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2534A60325 for ; Fri, 6 Jul 2018 17:10:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AD15286BD for ; Fri, 6 Jul 2018 17:10:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F325B28720; Fri, 6 Jul 2018 17:10:28 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92F48286BD for ; Fri, 6 Jul 2018 17:10:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 753CF6B0003; Fri, 6 Jul 2018 13:10:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 703A26B0008; Fri, 6 Jul 2018 13:10:27 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61BEA6B000A; Fri, 6 Jul 2018 13:10:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f197.google.com (mail-qt0-f197.google.com [209.85.216.197]) by kanga.kvack.org (Postfix) with ESMTP id 3815C6B0003 for ; Fri, 6 Jul 2018 13:10:27 -0400 (EDT) Received: by mail-qt0-f197.google.com with SMTP id d25-v6so11522513qtp.10 for ; Fri, 06 Jul 2018 10:10:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:date:from:to :cc:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding:sender; bh=1ctxwKTnStNbNNEftWXzzDZa6BcVo7ZDHn73PzkSBcs=; b=k9iPZpBRLLxjmbx97vXmbkc8DoKuIaRs+W4YvAY9i1EnWfZ3yvM1SJaM3IxCFECYhM 9i0i45CqGRv3RG7hWiJfivwsAlQYw2y5xGUsTqlW2e1S4CepxAY3F86BlRXQ4jHZ6osa SrcWN+LgySrSs1jV7AC3hjDuu0iejjPKG2COb5L6+Elogffcckrao5unc/+1AwrxbzaX 51VoNRRX+TK0TqlvvauYyXaSZFvsFeroZDTGVwXGCfZdI8jjtiNctAbSreLyHuVvBypH x1Ykx0EfWsCbbkzyk7bGaG9fuuXrsxJ8f+UDfbk8HoiHRpcF1KceFDXA1whSP6u7aFIJ Zv6g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of riel@shelob.surriel.com designates 96.67.55.147 as permitted sender) smtp.mailfrom=riel@shelob.surriel.com X-Gm-Message-State: APt69E28eSeOGvTQt4YkVIrVKOHgj+wey1s9WP8C7GWDwujxif36kkd8 /G9K6tuc2rXSlPkMvbs4k503sUUo9I4ktiASQo2LcVUgJN6ENI+ddi7TZboZXiOBwg2nJp96ZG/ 0TVDrP+1kym1qXJD+aAAn8oAI3z05ub9OYS913aBr8YiOcBqqAHTBPxKS+NvWn3CkXA== X-Received: by 2002:ac8:b05:: with SMTP id e5-v6mr9628746qti.16.1530897026927; Fri, 06 Jul 2018 10:10:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfaGcyyEZnJex4+Dh9HEp67iFdQjnJPKSkbOG8BkwCJTLP/gDWNivAjHE6VzXDfSl90h2Xo X-Received: by 2002:ac8:b05:: with SMTP id e5-v6mr9628706qti.16.1530897026291; Fri, 06 Jul 2018 10:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530897026; cv=none; d=google.com; s=arc-20160816; b=SzkRmdvIUsz2gT+MMh4ZR4JFNBlVLelCdCbPLi2gS2ijkTVUYK0GD2XTmPsU0Qa0O4 cpAK3UJFFf65BSh+pSj01876Da3TiUKKXCX8TIW+uhqm0BY9lO1zI4SohUvQgv5udxIG ANTjy8UvR6NZR4RqvwpsDJuH6wbj2aFvetSFV2K0suK7jnk0Yons35jFuS8Hwf7FYvEm 1BuF0m+mvipf8CQCgEizFRdix9JnPgP7cQXGeaG4z4dOMQ7ctkdUcjJ0G4BHGKqUtbWi JThk3YBHvRzZCkGoNM8UDxq6VZ6YF6Iwd9udKqAUpA2pbx+aqEnuvXzTB5ihZZwWzRtB RXFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:content-transfer-encoding:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=1ctxwKTnStNbNNEftWXzzDZa6BcVo7ZDHn73PzkSBcs=; b=oKLvmZ8Ue6LlQe9M1hhHdh5QF0wcMIGflO5wOn+7u1ozzrsW6lGUAAEnniDdOHcXrM n9LfUf6B5c0eFFCdWbVv/ksJQwIxWTV914GEsGxiL5ArJov8kpWQwGGP8M2lgo6yAXLE R9sywwLb4c5qc78vJx2AjbDouPMJ8zv+fb+n4Z1hXRwJlxEZxDkKVDhBtYZK8AapOb6i pu7t+NZnvVKZf3kxDy9bRGfKQ28gavjBvhqsuSeXLeaPJ5WCiIzIADvvkUT03+uXje51 PeEV1hkPbXpJLJRYvQbNxZkqvUnxcSSJQDMMZgkDysPXmmJmprpu/jDf4bGVTnEITkdX QPnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of riel@shelob.surriel.com designates 96.67.55.147 as permitted sender) smtp.mailfrom=riel@shelob.surriel.com Received: from shelob.surriel.com (shelob.surriel.com. [96.67.55.147]) by mx.google.com with ESMTPS id n79-v6si7248371qkh.309.2018.07.06.10.10.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 10:10:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of riel@shelob.surriel.com designates 96.67.55.147 as permitted sender) client-ip=96.67.55.147; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of riel@shelob.surriel.com designates 96.67.55.147 as permitted sender) smtp.mailfrom=riel@shelob.surriel.com Received: from [2603:3005:d05:2b00:6e0b:84ff:fee2:98bb] (helo=imladris.surriel.com) by shelob.surriel.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fbUFR-0007TK-Mu; Fri, 06 Jul 2018 13:10:21 -0400 Date: Fri, 6 Jul 2018 13:10:19 -0400 From: Rik van Riel To: "linux-kernel@vger.kernel.org" Cc: "linux-mm@kvack.org" , Andrew Morton , Michal Hocko , "kirill.shutemov" , Minchan Kim , Mel Gorman , kernel-team Subject: [PATCH] Revert "mm: always flush VMA ranges affected by zap_page_range" Message-ID: <20180706131019.51e3a5f0@imladris.surriel.com> In-Reply-To: <1530896635.5350.25.camel@surriel.com> References: <1530896635.5350.25.camel@surriel.com> X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP There was a bug in Linux that could cause madvise (and mprotect?) system calls to return to userspace without the TLB having been flushed for all the pages involved. This could happen when multiple threads of a process made simultaneous madvise and/or mprotect calls. This was noticed in the summer of 2017, at which time two solutions were created: 56236a59556c ("mm: refactor TLB gathering API") 99baac21e458 ("mm: fix MADV_[FREE|DONTNEED] TLB flush miss problem") and 4647706ebeee ("mm: always flush VMA ranges affected by zap_page_range") We need only one of these solutions, and the former appears to be a little more efficient than the latter, so revert that one. This reverts commit 4647706ebeee6e50f7b9f922b095f4ec94d581c3. --- mm/memory.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 7206a634270b..9d472e00fc2d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1603,20 +1603,8 @@ void zap_page_range(struct vm_area_struct *vma, unsigned long start, tlb_gather_mmu(&tlb, mm, start, end); update_hiwater_rss(mm); mmu_notifier_invalidate_range_start(mm, start, end); - for ( ; vma && vma->vm_start < end; vma = vma->vm_next) { + for ( ; vma && vma->vm_start < end; vma = vma->vm_next) unmap_single_vma(&tlb, vma, start, end, NULL); - - /* - * zap_page_range does not specify whether mmap_sem should be - * held for read or write. That allows parallel zap_page_range - * operations to unmap a PTE and defer a flush meaning that - * this call observes pte_none and fails to flush the TLB. - * Rather than adding a complex API, ensure that no stale - * TLB entries exist when this call returns. - */ - flush_tlb_range(vma, start, end); - } - mmu_notifier_invalidate_range_end(mm, start, end); tlb_finish_mmu(&tlb, start, end); }