From patchwork Tue Jul 7 22:50:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11650429 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 CD4C713B6 for ; Tue, 7 Jul 2020 22:51:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 907DC2075B for ; Tue, 7 Jul 2020 22:51:22 +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="UQql8WqA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 907DC2075B 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 362C56B00D0; Tue, 7 Jul 2020 18:51:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2A2946B00D1; Tue, 7 Jul 2020 18:51:06 -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 EF6BC6B00D2; Tue, 7 Jul 2020 18:51:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0154.hostedemail.com [216.40.44.154]) by kanga.kvack.org (Postfix) with ESMTP id D65286B00D0 for ; Tue, 7 Jul 2020 18:51:05 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9C5422C78 for ; Tue, 7 Jul 2020 22:51:05 +0000 (UTC) X-FDA: 77012776890.27.eggs27_29074d526eb8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 65F8C3D668 for ; Tue, 7 Jul 2020 22:51:05 +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-62.18.0.100 66.10.201.10;04yrf4rf99t3c9c7ihzb3ff48woyqycuw4r8ssdrnfet9io47aqr6ojkpmcjt8c.pstwhyxy58u74qaf9gqjmc88mmn4cm1gc7zsu1ahxr4zst758kmykrrbwk19mbu.e-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:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: eggs27_29074d526eb8 X-Filterd-Recvd-Size: 6025 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 22:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594162264; 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=1WDfseXJG+YEknLKo7gGTNIu+jjXQaKHoiJwElOOM90=; b=UQql8WqAFmBirdiDTpZSpbhUjcgOCVisoNkuds430pJjCYKofjvLcFhu7UNP75lPARQC3A V4cJr3yPdczaCTxrE9YI7yLy0bqRb8EBeJkJeymiXR0Iio5TWV9jloRbOgNvSg7DYOZZb3 zOL3fgcqJWB8e4EUlPusZdrKN1g0lko= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-339-7sWZu5eNPMmjqF2IzDcxdA-1; Tue, 07 Jul 2020 18:51:03 -0400 X-MC-Unique: 7sWZu5eNPMmjqF2IzDcxdA-1 Received: by mail-qk1-f197.google.com with SMTP id l19so17285982qke.6 for ; Tue, 07 Jul 2020 15:51:03 -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=1WDfseXJG+YEknLKo7gGTNIu+jjXQaKHoiJwElOOM90=; b=HXVdE/SBD2LGnQqeyBOxmHblIInJ1thyeRAx44Dsb1+KfVKfJ03SSnv2pjRAwouxfO lS3iOqh9I/ECqtUbLcgWWQ2RZkQ1tNHCBFI0J4UIDgkhTk/LO6fbzNVCr4cM00nF1nct iXoplVQsq9l+i9iE8G0dn/qDFcf/giSSVr7Re+c11frBibcRMeBJh2Ib1JqNWjb+Zydp ubAfyZTKIfKjCk6CBXh/GSUtsPNuCYy9SdbltsaE2xUwacTQgycKes4kRLtSADtjEU0K Z0jgPYx1F5OyrBnBtmtFLKkg7TfFgBI/AjOKhhhjbBtvdPr+3zqR7UjZrs4fmaex7Pxn 75dw== X-Gm-Message-State: AOAM530O5R9cGsZtcMuhJ511rTayNtxxzg+enz3ck18Bpr70Ulkn+oac MovDfhZMQi2b7tM9RdkrfaR5TSd6WxIg4F2jdRe0MW2NvGpt13q2uaTuZgJUdEZwQddIxGeIT2Q ZGFSe1/Fx/Bs= X-Received: by 2002:ac8:1972:: with SMTP id g47mr57090711qtk.180.1594162262628; Tue, 07 Jul 2020 15:51:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGFS+kyEs2De/yDG4/t5VdS5tufXXCkrB6G/JQRILDl9qFzVJ4Jz7OgpD+7mvusv7YHy15LQ== X-Received: by 2002:ac8:1972:: with SMTP id g47mr57090687qtk.180.1594162262390; Tue, 07 Jul 2020 15:51:02 -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.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 15:51:01 -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 , Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org Subject: [PATCH v5 23/25] mm/xtensa: Use general page fault accounting Date: Tue, 7 Jul 2020 18:50:19 -0400 Message-Id: <20200707225021.200906-24-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: 65F8C3D668 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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. Remove the PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN] perf events because it's now also done in handle_mm_fault(). Move the PERF_COUNT_SW_PAGE_FAULTS event higher before taking mmap_sem for the fault, then it'll match with the rest of the archs. CC: Chris Zankel CC: Max Filippov CC: linux-xtensa@linux-xtensa.org Acked-by: Max Filippov Signed-off-by: Peter Xu --- arch/xtensa/mm/fault.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/arch/xtensa/mm/fault.c b/arch/xtensa/mm/fault.c index e72c8c1359a6..7666408ce12a 100644 --- a/arch/xtensa/mm/fault.c +++ b/arch/xtensa/mm/fault.c @@ -72,6 +72,9 @@ void do_page_fault(struct pt_regs *regs) if (user_mode(regs)) flags |= FAULT_FLAG_USER; + + perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); + retry: mmap_read_lock(mm); vma = find_vma(mm, address); @@ -107,7 +110,7 @@ void do_page_fault(struct pt_regs *regs) * make sure we exit gracefully rather than endlessly redo * the fault. */ - fault = handle_mm_fault(vma, address, flags, NULL); + fault = handle_mm_fault(vma, address, flags, regs); if (fault_signal_pending(fault, regs)) return; @@ -122,10 +125,6 @@ void do_page_fault(struct pt_regs *regs) BUG(); } if (flags & FAULT_FLAG_ALLOW_RETRY) { - if (fault & VM_FAULT_MAJOR) - current->maj_flt++; - else - current->min_flt++; if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED; @@ -139,12 +138,6 @@ void do_page_fault(struct pt_regs *regs) } mmap_read_unlock(mm); - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); - if (flags & VM_FAULT_MAJOR) - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); - else - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); - return; /* Something tried to access memory that isn't in our memory map..