From patchwork Tue Aug 28 11:20:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 962862 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4205yb52Tmz9rvt for ; Tue, 28 Aug 2018 21:25:11 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BZHp6QbN"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4205yb36QqzDrM8 for ; Tue, 28 Aug 2018 21:25:11 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BZHp6QbN"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::443; helo=mail-pf1-x443.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BZHp6QbN"; dkim-atps=neutral Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4205sb2xphzDrRN for ; Tue, 28 Aug 2018 21:20:51 +1000 (AEST) Received: by mail-pf1-x443.google.com with SMTP id h79-v6so561351pfk.8 for ; Tue, 28 Aug 2018 04:20:51 -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=PqIy7bFKrUvh3N2mZhaZbdyHPW+hgwvBa4i30Nw8Ybc=; b=BZHp6QbN59dTJzQoscwjj/i43FAP0Gjci3ePWXPKsGC8C1C6frC6pwM7ZO9Og1acP6 kalOnMjZXknjI8Nx28NzpbS+Bf3PiNWazSfTSbEb5Tfl+239vryJxYCtq1UZm1KWzn0H LErHEmA5WLAWDKAGAxnCjAXNSt84PWxsr1fyECPVZJQ/WqwNnCqAHpj1BOcu3dssf1Xt ri+KTIc8FfxXuQLLx0wAF3iLM12t2IOTD2KNAaa3tt6ARchgJ8OtW2orWdvTnAmDuRT0 34rrzhoTIK0LlmWUaEsu/2lFprRk1Z7eQ/jprd4BLoyNtsG+l4id/94KNevuGHZiRKdN ojKA== 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=PqIy7bFKrUvh3N2mZhaZbdyHPW+hgwvBa4i30Nw8Ybc=; b=ElbH0mTiKjsp3xkbysOBUHTatqY8Q0arjGKk9O24vYoludGaAAXRELdccD9GVc42Ev XKR4bBD70gIJzvLKI4NvlBluIOkSKYbz+7VmAmj2izfCNN9PcKdRLHSEH9u1j6e6nVMi WUoZZ0xZZzSkoryp+ytLqTn4q8RuppI8eJpEdwENMBi0HjHMt/J6vfukgj67r2S3RpbJ nvh1tFhhlSCsStnNfis07mNlxIitsHk6f69GszUU9pQ5D8y3FMjKvJQtDsOvBYgbVoPe hUPMFu7q0rH79F3BV3XRIS82de2jbYmgqnKIFcnonLDP1OuJ72kEIH3UhTPB5qsi1njU 4vwQ== X-Gm-Message-State: APzg51A2SA+2e9rumRnJ96XotsTT2XF4TpriXS/fr23GO6DXuCdJ5B6L Awl74xbRvvwWr7qFAwSs6g8= X-Google-Smtp-Source: ANB0Vda1rxfWQ20CAFltZX59amKlHwbHH1qDC49g8kZHwadojwF7gpVndoanEo69eLkZduJDG3UbpQ== X-Received: by 2002:a63:5751:: with SMTP id h17-v6mr1085425pgm.423.1535455249468; Tue, 28 Aug 2018 04:20:49 -0700 (PDT) Received: from roar.au.ibm.com (59-102-81-67.tpgi.com.au. [59.102.81.67]) by smtp.gmail.com with ESMTPSA id s3-v6sm3287917pgj.84.2018.08.28.04.20.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Aug 2018 04:20:48 -0700 (PDT) From: Nicholas Piggin To: linux-mm@kvack.org Subject: [PATCH 1/3] mm/cow: don't bother write protectig already write-protected huge pages Date: Tue, 28 Aug 2018 21:20:32 +1000 Message-Id: <20180828112034.30875-2-npiggin@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180828112034.30875-1-npiggin@gmail.com> References: <20180828112034.30875-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Nicholas Piggin , Andrew Morton , Linus Torvalds Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This is the THP equivalent for 1b2de5d039c8 ("mm/cow: don't bother write protecting already write-protected pages"). Explicit hugetlb pages don't get the same treatment because they don't appear to have the right accessor functions. Signed-off-by: Nicholas Piggin --- mm/huge_memory.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 9592cbd8530a..d9bae12978ef 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -973,8 +973,11 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, mm_inc_nr_ptes(dst_mm); pgtable_trans_huge_deposit(dst_mm, dst_pmd, pgtable); - pmdp_set_wrprotect(src_mm, addr, src_pmd); - pmd = pmd_mkold(pmd_wrprotect(pmd)); + if (pmd_write(pmd)) { + pmdp_set_wrprotect(src_mm, addr, src_pmd); + pmd = pmd_wrprotect(pmd); + } + pmd = pmd_mkold(pmd); set_pmd_at(dst_mm, addr, dst_pmd, pmd); ret = 0; @@ -1064,8 +1067,11 @@ int copy_huge_pud(struct mm_struct *dst_mm, struct mm_struct *src_mm, /* No huge zero pud yet */ } - pudp_set_wrprotect(src_mm, addr, src_pud); - pud = pud_mkold(pud_wrprotect(pud)); + if (pud_write(pud)) { + pudp_set_wrprotect(src_mm, addr, src_pud); + pud = pud_wrprotect(pud); + } + pud = pud_mkold(pud); set_pud_at(dst_mm, addr, dst_pud, pud); ret = 0;