From patchwork Tue Jul 7 22:49:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11650387 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 D8FC4739 for ; Tue, 7 Jul 2020 22:50:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A5CDA20720 for ; Tue, 7 Jul 2020 22:50:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="goe9ljKA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5CDA20720 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8DEDF6B00A5; Tue, 7 Jul 2020 18:50:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 868756B00A6; Tue, 7 Jul 2020 18:50:33 -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 6BC1B6B00A8; Tue, 7 Jul 2020 18:50:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 502756B00A5 for ; Tue, 7 Jul 2020 18:50:33 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 17BBA1EE6 for ; Tue, 7 Jul 2020 22:50:33 +0000 (UTC) X-FDA: 77012775546.28.drink34_561273826eb8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id DD4E06C26 for ; Tue, 7 Jul 2020 22:50:32 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,peterx@redhat.com,,RULES_HIT:30003:30054,0,RBL:207.211.31.81:@redhat.com:.lbl8.mailshell.net-66.10.201.10 62.18.0.100;04y8o11s3p7a4c7xft163f1rb69e4ycnrrp4t7jzpn9finebregyz3fr5mpxjwk.646dfeq1syhkm96y3f4jdrarbb8aw8yzz6be11papif5bmzoumg5e7op6p3w6tp.o-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: drink34_561273826eb8 X-Filterd-Recvd-Size: 5754 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 22:50:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594162231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7D381D/H14FHe4T4c1JYQQxnwU06uKAee3rsUSJokIU=; b=goe9ljKAaVBX5Gyrh8c72NwgsNkWBq7TX8U7anj5xGtnju+0eNPB4DVoVe2ZRGeL+ljUWO SOf7pI/X8ZZWSQDWn3Mt1LO63WscbExp2dWu4scf5sUvLDrz9twucDzsTMg/hSW24i9toN 61ETZyhknQtasRw5SZncfdB7JuMZcy0= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-269-qkcoJzFxPMejEzb6ssUTcw-1; Tue, 07 Jul 2020 18:50:29 -0400 X-MC-Unique: qkcoJzFxPMejEzb6ssUTcw-1 Received: by mail-qv1-f71.google.com with SMTP id u1so14571587qvu.18 for ; Tue, 07 Jul 2020 15:50:29 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=7D381D/H14FHe4T4c1JYQQxnwU06uKAee3rsUSJokIU=; b=a0r64MphMmKP9RHd+H4rXBtOP3EF9Lu0fIwinvVGFXBISubWHZYvpSVi3oOvmQ4/0Q EM77uFSkZ1UTIuCxXtwXwwx7Rs6Hi/JON4udhRGD/G4JW0ZJnZM9rbNjRALPxV+XJoqE sbUA95ZcqvTmG8+HG6bbnCXVZkCG+5MvCTrl/GLPfsY9kngSlBC/NJQfmzpzhsrjlNGD cHurMsa/0v2krXoVm2NGz0GE5lUfjxjsBMKj4+VoNEAyxLODmsvWWf79I6QD6G17+2om ZswHArzuwuxTzAr3C1Rh4Z0q8MiwRTNJd2Dpy34bWBHs9Qy42hzpUU3GtWPJmIn1avDa 8tBQ== X-Gm-Message-State: AOAM531KGz7eco33VcmODc2MtSUKrpz7848bzKkSWzHZh9wcmP830zWV inY93ccHn8t7SeQZAlMVoE+RVigEWAnS23sAv29L/CM+LuqU8JfIgOb4DBEgsiokMAXVLr1/qP/ B9Udg1IV95HI= X-Received: by 2002:a37:957:: with SMTP id 84mr47901155qkj.392.1594162229536; Tue, 07 Jul 2020 15:50:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8Qe2aOe1IpWrTkBCeJI7Q41I9z0vTh86xMOYiLo7vcyohVA6pGslr3yB/GvOVaXZ0OVm2lw== X-Received: by 2002:a37:957:: with SMTP id 84mr47901134qkj.392.1594162229298; Tue, 07 Jul 2020 15:50:29 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id j16sm26267642qtp.92.2020.07.07.15.50.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 15:50:28 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Gerald Schaefer , Linus Torvalds , peterx@redhat.com, Andrew Morton , Will Deacon , Andrea Arcangeli , David Rientjes , John Hubbard , Michael Ellerman , Vineet Gupta , linux-snps-arc@lists.infradead.org Subject: [PATCH v5 03/25] mm/arc: Use general page fault accounting Date: Tue, 7 Jul 2020 18:49:59 -0400 Message-Id: <20200707225021.200906-4-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200707225021.200906-1-peterx@redhat.com> References: <20200707225021.200906-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: DD4E06C26 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened. Fix PERF_COUNT_SW_PAGE_FAULTS perf event manually for page fault retries, by moving it before taking mmap_sem. CC: Vineet Gupta CC: linux-snps-arc@lists.infradead.org Signed-off-by: Peter Xu --- arch/arc/mm/fault.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c index 587dea524e6b..f5657cb68e4f 100644 --- a/arch/arc/mm/fault.c +++ b/arch/arc/mm/fault.c @@ -105,6 +105,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) if (write) flags |= FAULT_FLAG_WRITE; + perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); retry: mmap_read_lock(mm); @@ -130,7 +131,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) goto bad_area; } - fault = handle_mm_fault(vma, address, flags, NULL); + fault = handle_mm_fault(vma, address, flags, regs); /* Quick path to respond to signals */ if (fault_signal_pending(fault, regs)) { @@ -155,22 +156,9 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) * Major/minor page fault accounting * (in case of retry we only land here once) */ - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); - - if (likely(!(fault & VM_FAULT_ERROR))) { - if (fault & VM_FAULT_MAJOR) { - tsk->maj_flt++; - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, - regs, address); - } else { - tsk->min_flt++; - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, - regs, address); - } - + if (likely(!(fault & VM_FAULT_ERROR))) /* Normal return path: fault Handled Gracefully */ return; - } if (!user_mode(regs)) goto no_context;