From patchwork Sat Aug 15 04:30:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 11719191 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20894618 for ; Mon, 17 Aug 2020 21:04:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DCB832072D for ; Mon, 17 Aug 2020 21:04:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CDvdzwQq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCB832072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9CA716B0005; Mon, 17 Aug 2020 17:04:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 97A776B0006; Mon, 17 Aug 2020 17:04:45 -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 891716B0007; Mon, 17 Aug 2020 17:04:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id 725B96B0005 for ; Mon, 17 Aug 2020 17:04:45 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2FE88824556B for ; Mon, 17 Aug 2020 21:04:45 +0000 (UTC) X-FDA: 77161289730.23.quiet68_180547d27019 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 0A66F37608 for ; Mon, 17 Aug 2020 21:04:45 +0000 (UTC) X-Spam-Summary: 1,0,0,ae729329a004f322,d41d8cd98f00b204,shy828301@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1202:1260:1311:1314:1345:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2693:2897:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:3872:3874:4250:4321:5007:6119:6120:6261:6653:7514:7901:7903:8603:9413:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12895:12986:13069:13161:13221:13229:13311:13357:13894:14096:14181:14384:14687:14721:21060:21080:21444:21451:21627:21666:21987:30003:30012:30054:30070,0,RBL:209.85.210.196:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yrfidbpf6pceyrrsyagd3k4f1gyycfx71oznfrt9f79aq6mqx5cqtony6add8.4wbmjbw3y4xtwq5ikuj5ieo9dp6bkkf9nn6nc7ygaw1odb3urd5gn4xk9kyhaas.r-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: quiet68_180547d27019 X-Filterd-Recvd-Size: 4889 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Mon, 17 Aug 2020 21:04:44 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id k18so8832104pfp.7 for ; Mon, 17 Aug 2020 14:04:44 -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:mime-version :content-transfer-encoding; bh=s0xsxFxhXZa1EWxR0qccoZxf/DJY4RuXfsMuyEx8Fs4=; b=CDvdzwQqRovVxOhgT2RUbZ6X4YCbt6xiALqbZ0yshN7CEr/yMtl3nb+sjcNWGjPNhk os0GGifoSws07ZWM8dyLJEIq6VlNGM4XlCgQ3qY5roljLEwpwoZTuZ8VgfHIaNSjElMd bUcpeO3Q0iv/M5AVEPXWeZ5/NX71UCbzxp+V056ixoc7XPEtOG6MhHOR/gihRv9CnkIq w1O0VVwKamy338MJwQUTvKvMUdzBjJwpyxXAY/pLNdNXFTZQt5A3NvE43dfD7Tj82CBr cYbR1UCm41MVbmzp1TediUzG6NwOwPnbYS8XDhsvLLKOadbFimvTwxb3m0g1BdLksBQT jvIg== 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:mime-version :content-transfer-encoding; bh=s0xsxFxhXZa1EWxR0qccoZxf/DJY4RuXfsMuyEx8Fs4=; b=t7h64XQUOkxJuNb/l8Y7xNbwtyi1YHZYRsn3QVsRcfEIEl2vbCxAW8ctPIs4h7YaUx jmFPccjtuIKHlN0ej2QGBWJBJuxTWLWMMsymnKShlfzhfVBjtF3YSBj3oAVKzTsLBmcd CsQLsGu9T/wS8IGRu6WjSBc+bOSbmEbUNQsmicXFmakLKMt0yPp7qfZt/VtVs6MKA1fR VGQfkffOWH2v94AQD/9iJg6TaqNdUoEMIijEOPZRgoQl1D1CLMbkwcZ+62kK8Pp1asqs BS/UXaxVmurhRIO2KNy94PzZiNFRUW5u+GnqSXkbrZS3GCmWTO8Jqo/svU2zztuSOLjj vJ9w== X-Gm-Message-State: AOAM530r8D0ss+rMJLZMDeyitMnOwGBJZHmYx4JLo5EThVMRNewDN6dE hIN6TcxGy9Xjt4T/UQGQVf8= X-Google-Smtp-Source: ABdhPJwUhkGlRkmO5t4lKAcNEqs80JBjk72J7fFvxm96RSENW/ROGKXpfL/92x0BUVl8KIua6QBW0g== X-Received: by 2002:a63:7e42:: with SMTP id o2mr7541262pgn.260.1597698283629; Mon, 17 Aug 2020 14:04:43 -0700 (PDT) Received: from localhost.localdomain (c-107-3-138-210.hsd1.ca.comcast.net. [107.3.138.210]) by smtp.gmail.com with ESMTPSA id u62sm21092504pfb.4.2020.08.17.14.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2020 14:04:42 -0700 (PDT) From: Yang Shi To: xuyu@linux.alibaba.com, hannes@cmpxchg.org, catalin.marinas@arm.com, will.deacon@arm.com, torvalds@linux-foundation.org, akpm@linux-foundation.org Cc: shy828301@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [v3 PATCH] mm/memory.c: skip spurious TLB flush for retried page fault Date: Fri, 14 Aug 2020 21:30:41 -0700 Message-Id: <20200815043041.132195-1-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 0A66F37608 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: 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 89b15332af7c0312a41e50846819ca6613b58b4c ("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 --- v3: Incorporated Linus's suggestion v2: Incorporated Will Deacon's suggestion mm/memory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index 3a7779d9891d..602f4283122f 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4247,6 +4247,9 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf) 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.