From patchwork Tue Oct 16 13:13:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10643539 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 12BDA13AD for ; Tue, 16 Oct 2018 13:14:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F00E528C31 for ; Tue, 16 Oct 2018 13:14:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3BA129654; Tue, 16 Oct 2018 13:14:19 +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 7A1EA28C31 for ; Tue, 16 Oct 2018 13:14:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1224C6B000E; Tue, 16 Oct 2018 09:14:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0D2776B0010; Tue, 16 Oct 2018 09:14:18 -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 F2A326B0266; Tue, 16 Oct 2018 09:14:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id B36D46B000E for ; Tue, 16 Oct 2018 09:14:17 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id r16-v6so16927666pgv.17 for ; Tue, 16 Oct 2018 06:14:17 -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=Uwz2MhBiZj2/RLBte8wwxNWfHSbBq1uBQUZRjpspgrw=; b=VB7ZdcT5iOjsyQVCkTmcAJnr4ZP2jICz5jr2JuRjvZelj4chNFt6e5+OBgs19cH1zj 6/6sx1EUURliZOj45Ev6fPJZvftHJWKuvBT6oweuOaXzNd2XCBCITDz1Se1wHMCRCk2o 9PHXtIooPu+XKjlAWXU6Aww1Jd9IjCQ2w/TUY5Tfgr/b+e2lIDnm60Wu3LS9rrfANFyu Ggj9A27rAcMV/R7kqNWa+pHfKJEtl9BHl2v31CzxKLYTsCDrCxJhCdxW9d7ZeWXcoARA 87xyJ9sPJtrWk4Bxv7FoKkrf/F5F45kVRAfYiJE31HEJHsqd0wvQ4O4rkIBpIT6Luz1k skyQ== X-Gm-Message-State: ABuFfohazoVa62EhTBIF7iwXzYnWzfuFnMevSGnmcrur0Dm5Y9nVfg3D OVLgEMGZ44rnTPwqAmNQem8fc/iXnKOpNxxTOFz6FrMsSA5GaBwepFM9XGpqsGyALhF2Z2U/UD8 XdgBadJCP+ERjZTbglb5Q/DpVklsk5pToZrXmKhVnEtHxbWjuUYG4PFbv4obEAIVBMKn98B1PyJ sw7ZtrAQs0bfQT4m0WjjT2aNmZs0k+/Agsu83aJrxKo3JSllXPOyxFvx+JPCDZDIUHcLIsQbA8M X3h4ehViK7XLWTlHUaaWi/hO6rQsc3gpJ32SM18rbMAwhH38XvR5YZGV8xmiWUZp3//rkAR7j8w 4TG0wYZPiXyneGLa1VU2EnZSHlLJ6lNB/Fk8oGCr5fY2t5J0NAxu9xwRh9lKO1/7J1IV9l7rxba 6 X-Received: by 2002:a63:1302:: with SMTP id i2-v6mr20580604pgl.380.1539695657410; Tue, 16 Oct 2018 06:14:17 -0700 (PDT) X-Received: by 2002:a63:1302:: with SMTP id i2-v6mr20580565pgl.380.1539695656736; Tue, 16 Oct 2018 06:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539695656; cv=none; d=google.com; s=arc-20160816; b=PP7dxMq6JEcFpv8rjH7KU0RaaX8VexsFeXF79qOEpp9soyVKVWROgI8iiNv4MBfhx2 Jpsrf/9yY065vPQ2JsbMHkIjEMapdcQK7AzlMFQlCcZ4i4e9HHeCA5GjP0apJTbx4wE/ jq9OApf/8ez+/QlgJ62kWlDCjdxXFP/CTsqQdLT9/dix8bYSIWsLL5FvNrKDJUZjZev7 g4otjxrcP/NP+fowAwVJNDOoNhl41csFduWY7OZzD9N5j08pdTVAAGttMeWuqIinEdbw oUcA/nSPd/OIu3QQKd6EqATpw5Yx2qC4EdFWgK0AcCF8+eOn2KBgfoauNhMbFfuvhYgh J5ew== 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; bh=Uwz2MhBiZj2/RLBte8wwxNWfHSbBq1uBQUZRjpspgrw=; b=gACZf+vGa35yZopFrlkUZXeAVDz3QaSBf8lPnv3aybHlyIOUS444JZO3557jTkAneT wQ6GSxka1mevLaciuTRBGUPGE3XsOf82Zj8NX4u5JtWYLD4IrVD/Ew0nqVGDyGBHbnB8 txbGaK/RFTLnOgt0Q+ImYqLy/Li8nkfaVHZKIR80HI0l+ofSqX2oXyuCZlABCPw4bDpq 9uLa5V654PaO9h3r/6LcEME9GLs+KMfE2mJqFaont3zkRvhqq4hEI1xx4heN1gU03FSS xNBiyDE6MuvUYSjnb4ykaAQ4PRYyTwU4SVYxRfmZdQH+2zvNi0XZAmrJ+1GJlLiY6PQA w+oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e11cs6jE; 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 j33-v6sor4465352pld.51.2018.10.16.06.14.16 for (Google Transport Security); Tue, 16 Oct 2018 06:14:16 -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=e11cs6jE; 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=Uwz2MhBiZj2/RLBte8wwxNWfHSbBq1uBQUZRjpspgrw=; b=e11cs6jEoeMmwoBTYdNdNJksH7qI2wwNhzL8dHOfMYBv61ZXmE7ZyV/m0HuwprSE8P LFyAsDmOM0lbAcgAwqRMqM/kSCDNmRysuTjQBcOTsE+FYIuV6YatjeYM9khiyj/R3/AY QCOLgFdpTNNuFTtQ/BUGeOh8mtqwWkMaj1cDEQfLz/cYm4GL6lZaJ74Hjstyi58GeYBt wOKkZeW4oBUFptEPdrDwkxiVepZCC+JvI0CR0+o9yZckDgcyrP91npD4G3d5GNYQsbQN Zhnb8I+DxMlfZAf2J/KOOMUmZ9HMuxpolqtPk2C9td0SKgrYsShSDKNx8nkIWCHWN94Z 0Q0A== X-Google-Smtp-Source: ACcGV62O4GEomn4Rji7i3zI4ZPz6+o/83UivhZoWG06/NphsLTdj3gWE9y8+Ptx4lChGWFwrT5esfA== X-Received: by 2002:a17:902:34a:: with SMTP id 68-v6mr21440986pld.39.1539695656502; Tue, 16 Oct 2018 06:14:16 -0700 (PDT) Received: from roar.local0.net ([60.240.252.156]) by smtp.gmail.com with ESMTPSA id j62-v6sm16043423pgd.40.2018.10.16.06.14.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 06:14:16 -0700 (PDT) From: Nicholas Piggin To: Andrew Morton Cc: Nicholas Piggin , Linus Torvalds , linux-mm , linux-arch , Linux Kernel Mailing List , ppc-dev , Ley Foon Tan Subject: [PATCH v2 4/5] mm/cow: optimise pte dirty bit handling in fork Date: Tue, 16 Oct 2018 23:13:42 +1000 Message-Id: <20181016131343.20556-5-npiggin@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181016131343.20556-1-npiggin@gmail.com> References: <20181016131343.20556-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 fork clears dirty/accessed bits from new ptes in the child. This logic has existed since mapped page reclaim was done by scanning ptes when it may have been quite important. Today with physical based pte scanning, there is less reason to clear these bits, so this patch avoids clearing the dirty bit in the child. Dirty bits are all tested and cleared together, and any dirty bit is the same as many dirty bits, so from a correctness and writeback bandwidth point-of-view it does not matter if the child gets a dirty bit. Dirty ptes are more costly to unmap because they require flushing under the page table lock, but it is pretty rare to have a shared dirty mapping that is copied on fork, so just simplify the code and avoid this dirty clearing logic. Signed-off-by: Nicholas Piggin --- mm/memory.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 0387ee1e3582..9e314339a0bd 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1028,11 +1028,12 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, } /* - * If it's a shared mapping, mark it clean in - * the child + * Child inherits dirty and young bits from parent. There is no + * point clearing them because any cleaning or aging has to walk + * all ptes anyway, and it will notice the bits set in the parent. + * Leaving them set avoids stalls and even page faults on CPUs that + * handle these bits in software. */ - if (vm_flags & VM_SHARED) - pte = pte_mkclean(pte); page = vm_normal_page(vma, addr, pte); if (page) {