From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C45AC433DF for ; Mon, 24 Aug 2020 08:56:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E75F6204FD for ; Mon, 24 Aug 2020 08:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598259363; bh=LehtCaV42rdQFo3R1F6wlwdqE9D0Rqqwrku+qzm3Gnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sB1y5TZVqDShrG/32XnUQPBYYQDU88JCqt0ztptcgd8fKUE3fQI+xaItaEFJitlFj 39SMssMCSa5UKHf0J4UrHHckCfgSoLHmi9rqibaF2OJmZuHupYAp/x/F9hi8jpTJbL umjMou6g7/SYVLXub8D+rP8MYNAuXLZmS9rzNRUM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730436AbgHXIz7 (ORCPT ); Mon, 24 Aug 2020 04:55:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:37534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730417AbgHXIz1 (ORCPT ); Mon, 24 Aug 2020 04:55:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CCAD3204FD; Mon, 24 Aug 2020 08:55:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598259327; bh=LehtCaV42rdQFo3R1F6wlwdqE9D0Rqqwrku+qzm3Gnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EgLFu0qlzv/2bbLhlK98J54rISIAPYcbdSzXK7sg9hopUJt+0+tL0hU+AuzJeHF4/ LoHMlK+f9awrnzDlAc75TtwgDQ7PmNvkr7mbwwDY15IsRobCVaF7j35CSmsi+FUG5o SSpF9gUzuvYtSEVPNq1jELk4+f6GkJF/K9nDkxEk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Torvalds , Xu Yu , Johannes Weiner , Catalin Marinas , Will Deacon , Yang Shi Subject: [PATCH 4.19 17/71] mm/memory.c: skip spurious TLB flush for retried page fault Date: Mon, 24 Aug 2020 10:31:08 +0200 Message-Id: <20200824082356.758044582@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200824082355.848475917@linuxfoundation.org> References: <20200824082355.848475917@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Shi commit b7333b58f358f38d90d78e00c1ee5dec82df10ad upstream. Recently we found regression when running will_it_scale/page_fault3 test on ARM64. Over 70% down for the multi processes cases and over 20% down for the multi threads cases. It turns out the regression is caused by commit 89b15332af7c ("mm: drop mmap_sem before calling balance_dirty_pages() in write fault"). The test mmaps a memory size file then write to the mapping, this would make all memory dirty and trigger dirty pages throttle, that upstream commit would release mmap_sem then retry the page fault. The retried page fault would see correct PTEs installed then just fall through to spurious TLB flush. The regression is caused by the excessive spurious TLB flush. It is fine on x86 since x86's spurious TLB flush is no-op. We could just skip the spurious TLB flush to mitigate the regression. Suggested-by: Linus Torvalds Reported-by: Xu Yu Debugged-by: Xu Yu Tested-by: Xu Yu Cc: Johannes Weiner Cc: Catalin Marinas Cc: Will Deacon Cc: Signed-off-by: Yang Shi Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/memory.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/memory.c +++ b/mm/memory.c @@ -4062,6 +4062,9 @@ static vm_fault_t handle_pte_fault(struc vmf->flags & FAULT_FLAG_WRITE)) { update_mmu_cache(vmf->vma, vmf->address, vmf->pte); } else { + /* Skip spurious TLB flush for retried page fault */ + if (vmf->flags & FAULT_FLAG_TRIED) + goto unlock; /* * This is needed only for protection faults but the arch code * is not yet telling us if this is a protection fault or not.