From patchwork Wed Jul 25 15:52:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10544247 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 579889093 for ; Wed, 25 Jul 2018 15:53:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 455A52930B for ; Wed, 25 Jul 2018 15:53:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 397F92A5AF; Wed, 25 Jul 2018 15:53:07 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 D33882930B for ; Wed, 25 Jul 2018 15:53:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64E666B0291; Wed, 25 Jul 2018 11:53:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5D95D6B0292; Wed, 25 Jul 2018 11:53:05 -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 458A66B0295; Wed, 25 Jul 2018 11:53:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id E5B4B6B0291 for ; Wed, 25 Jul 2018 11:53:04 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id w18-v6so5675412plp.3 for ; Wed, 25 Jul 2018 08:53:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=mHYcANdv1ziuRcHNi26L8UfTXr0LxJ2t3caZEIGgtE0=; b=uhXRpNIa31sIEQ98fk4/OggLLCqD5RYWnAdT+jJOiKJ//54UPsX5jBsgcHT9der1Rt 7hVrCH1+QOjSsDGKMWYgnP5tCEtg+GxakYoVUWRA5RPVoJ/Smtg0OtxdbsBPAAC9q0hx EspcK75/Tp7qgBvJA1GpEC8gU1NFo3csHP1rKetd++EUN3TMFaOOaCWqFGlBZBbsbVQj YPMOZwhDz3DhcXy6ttef3mZB6NI/cVU44leYYtRhPdlmgn0rhdMue1ijvNWV0BvnG4j6 namUiVqIehJtcWdrXFPowU63KbcTVSgym9LIUExx9yAp8sLoRe5/TUDG+i7hxqcTwoUI IJSw== X-Gm-Message-State: AOUpUlEl5K3m5+W7gNvJ/DPLJ41KuXpqmNAd+5fEtS13sY1uZ7/zMDpj 8GOrCq8F7+H/so0JVmcEZr1i7KQL4tQV7mDzs14UWohRYv+HVjGi7Hgc1fU6i9FMn9XXUMue89U y3c1l6PGvnE0cizdncijdLeXvOtqjrYQleYzYV8tP6NW7+uCnbs0fGq01NZb2UwaUhOuhED49K0 91Y7KkbfN/S6hvIRuOF8y7JgTFe5KtKVgu2RvQ0dP8wAQq5jVfEqnbrWkTRobLkeUEdAicuLuCj GHdWPS30VIGTQFR4GyvOEICFZhhBqWmgmSxvM9K4dDJqrT3a4ioSuwohJ6dJ5jwcS8A7wHO/+LF MDHKZyMpnWaTLvzAtDHUuYMKMPFvr7wAgvdi4eelwYtKdgE1XQADbcSta9E9LZaQ/gF8mZPbQAU r X-Received: by 2002:a17:902:8e81:: with SMTP id bg1-v6mr21490401plb.129.1532533984629; Wed, 25 Jul 2018 08:53:04 -0700 (PDT) X-Received: by 2002:a17:902:8e81:: with SMTP id bg1-v6mr21490371plb.129.1532533984007; Wed, 25 Jul 2018 08:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532533983; cv=none; d=google.com; s=arc-20160816; b=IhrVKOOHjRpJ13J8WMj7Lg2+1ZM4PfDPDE0Jn5+x4iHicwvc7rUt1B4GJ1ZlYgkTn8 /udYdmGmwg+POMemNMw8XuMmOiLbspeGO/uYnDf3Auro09iJSCM0he3kSI96LCjnjtMM DZSxe7Cw9Y38vECfc9oIPVivRR5NC4Pf/G1XFRXD8fcY9ExzK07U0TpbKRzlzJF8gR9r Q1xjBzyWr91RJZ8O5gSIBOIV+IGgCujaglSIaHKR615ydi5UFbUbFc7pIsl4Q9YWibU8 6kqA3sFu4KAky10rPe/SGIlcHia5Hr0eGWZT3AJiRZs7FL15m/2cf4GEXgQ9lduPoEpr nYhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=mHYcANdv1ziuRcHNi26L8UfTXr0LxJ2t3caZEIGgtE0=; b=H4tEGLb7L6bmicGAj/p8KL9de22k/bk4Ozy9t9/T9kgvvQuGojVooJyvqFeJ1rRY+Q qhBH0GjrARoSDdahGwd7mfQoCvd8dYpSSKHTr2SqCiMamz1R46NjrhjLlRftZW5u8oG3 +T+fWGq/H5NczmE03g76V1ACBYbzZN1IiM66J+T/ONDKSCa8dFpblFi8tAUx1Pd27MzW KI+yRr2RWztgF4PPEhzqdTDO2kPa6ekMULdTp5BazZUciqp4h7/MlZxSxnT/Wu8MXkgW a9B1H4nrS7GP3Ri62DoDeWYy1x7GXJma7/XJ8aLGrFQ8h6vvMkpzcw3d/0qIwTauDBVd 44lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nok2v7d0; spf=pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id t5-v6sor4879475plr.67.2018.07.25.08.53.03 for (Google Transport Security); Wed, 25 Jul 2018 08:53:03 -0700 (PDT) Received-SPF: pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nok2v7d0; spf=pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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=mHYcANdv1ziuRcHNi26L8UfTXr0LxJ2t3caZEIGgtE0=; b=nok2v7d0fAP74uh787q3CuiuLXrypeSVLpy/NfSnhOySsVeS2hWOyX/qYUPlx9m5mZ 7kEW3feqvbiHQ1nXKfCapViJ3EiSDWj6i+nhNS0qp7EVVnGR9I+f2H6OzzKD5ACWHc9r v62Ddpz7Yb5B1pVjf37Rp9O3fRxeQJLqN0ri4KAWhll9XhpxC1IVW9JRCitR+987wi1P To2FkAL2BcD0jadrRR05srhoM6mJ6ASQhc3RJ+4LwpMfIO/9ssEdbt9wO2DoJ9u0fDrI SYTVOLAhGjUq4Kysgf7k9DnAYrk+/paw5tb0jET/ImyEgBUtP7iZKEfI3XlZByQ576jH +tLw== X-Google-Smtp-Source: AAOMgpcXSEuiq3wvBnnZlwnrdeXmCaHsgXgmpAUdxpDRwsg5Bh40RkW7jUK6WQZyxdwGWogvTJVoDQ== X-Received: by 2002:a17:902:a5cb:: with SMTP id t11-v6mr21491322plq.71.1532533983615; Wed, 25 Jul 2018 08:53:03 -0700 (PDT) Received: from roar.au.ibm.com ([61.69.188.107]) by smtp.gmail.com with ESMTPSA id j72-v6sm23438315pge.19.2018.07.25.08.53.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 08:53:03 -0700 (PDT) From: Nicholas Piggin To: linux-mm@kvack.org Cc: Nicholas Piggin , linux-arch@vger.kernel.org Subject: [RFC PATCH 3/4] mm: zap_pte_range optimise fullmm handling for dirty shared pages Date: Thu, 26 Jul 2018 01:52:45 +1000 Message-Id: <20180725155246.1085-4-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180725155246.1085-1-npiggin@gmail.com> References: <20180725155246.1085-1-npiggin@gmail.com> 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 Shared dirty pages do not need to be flushed under page table lock for the fullmm case, because there will be no subsequent access through the TLBs. --- mm/memory.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 1161ed3f1d0b..490689909186 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1322,8 +1322,18 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, if (!PageAnon(page)) { if (pte_dirty(ptent)) { - force_flush = 1; - locked_flush = 1; + /* + * Page must be flushed from TLBs + * before releasing PTL to synchronize + * with page_mkclean and avoid another + * thread writing to the page through + * the old TLB after it was marked + * clean. + */ + if (!tlb->fullmm) { + force_flush = 1; + locked_flush = 1; + } set_page_dirty(page); } if (pte_young(ptent) &&