From patchwork Tue Oct 16 13:13: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: 10643533 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 6405D13B0 for ; Tue, 16 Oct 2018 13:14:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5120F28C31 for ; Tue, 16 Oct 2018 13:14:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4524929654; Tue, 16 Oct 2018 13:14:04 +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 CA62B28C31 for ; Tue, 16 Oct 2018 13:14:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84E6C6B0006; Tue, 16 Oct 2018 09:14:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7FF596B0007; Tue, 16 Oct 2018 09:14:02 -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 6EDD96B0008; Tue, 16 Oct 2018 09:14:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 30A9C6B0006 for ; Tue, 16 Oct 2018 09:14:02 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id g6-v6so18199436plo.0 for ; Tue, 16 Oct 2018 06:14:02 -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=og3nps762l1wehgPrVvLZ4tOt6tgHDhsP/lk8/fPWl8=; b=PRfKbDD7BmJuMWtTbCeIiW7mp9S8KEBv1AybCPNJPSb+DGWAMh52R14Zz91j4pqsTv b6gxKgsE4Pkdv9pWJGzdXV0NclQ62XqR7VxDuMaWisegDJTAfG960tnqi8o6PsLcnG/J C8m98eU7fE1I+ItPaTNRuJFLUSaYcqZ2AOTZClVJrshtuwxSRiFgrQAmHB7hT5uo2if0 8rp8lLkSEqqlUGEzIUjNqcEStAZITJLJBjgNhz+BUk/lVK3+XFinUIpbAYqSvYvT1/qr ojeSh7nNkDlVmAny6oaPS0IQnhoSg8y43CJjCoKgpcH3jqiYXi80zs+GA3UaJy7Rs4hO Rndg== X-Gm-Message-State: ABuFfojsHbXLdUxC6qutEr1bEV1FuiGq/RqFis6Vi8//l3lGYd8Z7TIj qmpoOOOoD09V2utO/SxM+thh8whWD1gfcfkpVjw/YzS6y+cdeSuCWCWakQfMteK1oNTrSqs6/wg cFZ65N6UzvFZIq4kRI1PifALgNhmXY6NUFrdXdkVW6jwjeNgXvPawsVSt/lQZdpRkFSzstkdHBR 6sjuf5RTuILXahpAWRG6sX8wuPtiwhL9Rs+EY30o5fXpp8ApxiAfkvcOSEuXXsHbtyk/jYITNni kUF8Mhhi/GPQaA2h7umaUsFb2qvUkjx3JB8BkDE35BHm8QH+jZ5j6Yx+Leb5B5dQ8m86i/knOim XVaKIP4BnniIxUJ3eAHcNn+JeUpNCReESmybybE2fuymd6yjQsaH1xUKwWPwiccgIPpbn8k8GvB d X-Received: by 2002:a62:507:: with SMTP id 7-v6mr22093262pff.80.1539695641873; Tue, 16 Oct 2018 06:14:01 -0700 (PDT) X-Received: by 2002:a62:507:: with SMTP id 7-v6mr22093212pff.80.1539695641037; Tue, 16 Oct 2018 06:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539695641; cv=none; d=google.com; s=arc-20160816; b=W3bM4nc2ROMGIfZ5Oeeaglk2iSXOpnq31p1tfXvK7xH/vWPByGgyZ9nidHUqLfVnn2 S07kdrIN3BocJ3PMjsIS5vEh8Kdm+p9XSp4RIyOOl+vneqEquigKW7nz/kqKhHI2vZGA TDpBeaLnd+B4+BaFGtVOBeKACFAZ7VoT5Qf5oZbcmcg4lbh5lH6Re3Z2kvDrFWSQ06mS DAdCu5ONvhglmE5Vz21Srsuh3ZXgoEygILhKAs/Lm8w7DTbM5/T0KRRz2A2zveWYcLc9 l4P8cF13ZI44b81/LOLDA4gcZ7rYX4nG5wWleo9lIIbP8hLuk190nL2piu3zBck/Ke7i rJZA== 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=og3nps762l1wehgPrVvLZ4tOt6tgHDhsP/lk8/fPWl8=; b=k21w1OqoZ4pPnRFIMjlUXNcnMMvsX0wprl6UgWK72n+SSZjZVPivWjfXrV4SxVS/gK GHivFvRkN/6hyzD7L9DCpxtuLw7CBhU3TcJcbWOeB04t9LzW9QCQysSa5lMmsdUOv4Rv 8GaH4oh2FzH5HOosjdPGlWQdw+P+sQhd0f60lO+D2I/1oglJql4JHU5hfd1Dgf7mzlXl qURzei6a5zniDlfn91VLyQGttiZYNMSvyAdQxxFTr3rk4WB+XTvbTfimDL53GrWPKO/7 u+pj5Bqn2i83WAz7D5IEHFn59GynWdBIbQmD2N78+mRbCVfrOaes4Z1CrhRgZmaOKkD2 uKNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Nm0YzlJB; 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 i69-v6sor4614927pge.17.2018.10.16.06.14.00 for (Google Transport Security); Tue, 16 Oct 2018 06:14:01 -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=Nm0YzlJB; 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=og3nps762l1wehgPrVvLZ4tOt6tgHDhsP/lk8/fPWl8=; b=Nm0YzlJBr/tFpHAsamNBQRtcflUZ1a3Fhs7jRJoXnpFPig4gbEgKXSD8GJg5pTuCzZ flZP8osFYXA9rcYPLY1PyxKzJemBVuQjRz30z6FwFB4TaoUDz2o5xuG/CMsPKZ2UFyqs RZ+GE2BV0OhCu0HksSYWPZDL+bdF8YLGRJ14FGakPYH/sq2hk0gVDXssBQ1yLJUjEr7Q Xs9PwkS8+UAIHo28AreMJSU7LdlhogWZ2UT0D0x7OwKMjaCFxzh/mt7sv551VBgwuR39 L/QfwPOstPLfmSkiEpLRxyhfsrZnq5zTvdQQsfeW8zv5Cuo1DGQSTzvpgO2MSayvrNPU O72Q== X-Google-Smtp-Source: ACcGV633qW2OBNPwm3Of34MQ0PiCfw8SZWKbv1d8VPnZh7InlVEXQra/DC+Bn4ZaPxLg1AladyddzA== X-Received: by 2002:a63:4f20:: with SMTP id d32-v6mr18957422pgb.231.1539695640808; Tue, 16 Oct 2018 06:14:00 -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.13.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 06:14:00 -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 1/5] nios2: update_mmu_cache clear the old entry from the TLB Date: Tue, 16 Oct 2018 23:13:39 +1000 Message-Id: <20181016131343.20556-2-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 Fault paths like do_read_fault will install a Linux pte with the young bit clear. The CPU will fault again because the TLB has not been updated, this time a valid pte exists so handle_pte_fault will just set the young bit with ptep_set_access_flags, which flushes the TLB. The TLB is flushed so the next attempt will go to the fast TLB handler which loads the TLB with the new Linux pte. The access then proceeds. This design is fragile to depend on the young bit being clear after the initial Linux fault. A proposed core mm change to immediately set the young bit upon such a fault, results in ptep_set_access_flags not flushing the TLB because it finds no change to the pte. The spurious fault fix path only flushes the TLB if the access was a store. If it was a load, then this results in an infinite loop of page faults. This change adds a TLB flush in update_mmu_cache, which removes that TLB entry upon the first fault. This will cause the fast TLB handler to load the new pte and avoid the Linux page fault entirely. Reviewed-by: Ley Foon Tan Signed-off-by: Nicholas Piggin --- arch/nios2/mm/cacheflush.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/nios2/mm/cacheflush.c b/arch/nios2/mm/cacheflush.c index 506f6e1c86d5..d58e7e80dc0d 100644 --- a/arch/nios2/mm/cacheflush.c +++ b/arch/nios2/mm/cacheflush.c @@ -204,6 +204,8 @@ void update_mmu_cache(struct vm_area_struct *vma, struct page *page; struct address_space *mapping; + flush_tlb_page(vma, address); + if (!pfn_valid(pfn)) return;