From patchwork Tue Jun 30 20:45:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11634771 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 67C5E739 for ; Tue, 30 Jun 2020 20:45:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2A4F420772 for ; Tue, 30 Jun 2020 20:45:42 +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="LTtCd356" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A4F420772 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 4E6C66B002B; Tue, 30 Jun 2020 16:45:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4BD836B002C; Tue, 30 Jun 2020 16:45:40 -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 3AD066B002D; Tue, 30 Jun 2020 16:45:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0044.hostedemail.com [216.40.44.44]) by kanga.kvack.org (Postfix) with ESMTP id 2699F6B002B for ; Tue, 30 Jun 2020 16:45:40 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E124B180AD806 for ; Tue, 30 Jun 2020 20:45:39 +0000 (UTC) X-FDA: 76987059198.18.boy76_540834a26e7a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id AC07C100ED9E0 for ; Tue, 30 Jun 2020 20:45:39 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,peterx@redhat.com,,RULES_HIT:30012:30051:30054:30090,0,RBL:205.139.110.61:@redhat.com:.lbl8.mailshell.net-62.18.0.100 66.10.201.10;04yr8a6fszhcq79w77njn19uym7p3yprthxih1a6acuhh1dong6af5f9xckn1ye.p3hi5aixhfh3yf9em4fh6xdn5sfr951y3ie8ofo36cme1ohjgtfada83z3t7jm7.k-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: boy76_540834a26e7a X-Filterd-Recvd-Size: 5797 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Tue, 30 Jun 2020 20:45:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593549938; 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; bh=/WN5suCL4vjaI1eJdzhaIBmykla0j2zqu4dhyFqEqPg=; b=LTtCd3560ik9MvggR2i7a/F22Hf27/HsBH7f3qhtdmqeFgDAnymgBvyPsSJdChF1bD+FUC 2mBE6kHg6hCtn3I9znUwLl2DhmcDQ5+tbCuMrGqqpdcR5tyq2b0pqQndMM+as3eTIio99n 33bu/azAr1B/gIGc8viqQmZRasVKV5M= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-64-clypFzcSNkahnzqM7WVa_w-1; Tue, 30 Jun 2020 16:45:36 -0400 X-MC-Unique: clypFzcSNkahnzqM7WVa_w-1 Received: by mail-qk1-f198.google.com with SMTP id k1so12214569qko.14 for ; Tue, 30 Jun 2020 13:45:36 -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:mime-version :content-transfer-encoding; bh=/WN5suCL4vjaI1eJdzhaIBmykla0j2zqu4dhyFqEqPg=; b=tKyittPNRTyLsIUFxqwOs/Z4t2NVqeTcV2m6jeHv1kl4Hp1LDjXaEydG0zKD25d/3L kqoaleYEJopoA7RaDmRnacwBEtmC+7xZF4R3PgKW5Gbvjc93SQxG0wV0oS55ncZhyQYy bxblPisHuULRrrhRwRI/mEIFZkv4rwQeZ9Y2ixxSfKtfJjyOKRYCI3CkyqL2MuxGHJhT /5Uzp2TY+JdBXD0/2A284LwNEKnNob5TqmKiinHWD8g7eLM+jEQFtoSH9OHWoRj1sP6z R+WRg8emrLscbb70TaXSPS8sMyZGLK4jV1wJrGWLXG+czyetHOnT8Hr5pxlRuRdwzBg9 agow== X-Gm-Message-State: AOAM530+Rm9J632x1rA2Jfa+6qmhdkoud/JdAA4npU07s3RhOlNjphzy HAx6h2xLEdAX7i7/TO6T1u8mh9nbxk15TEHHAWvY2hPioXRpLCs8MLQwUyJQZ7StL6AWqgwppCd 0mJbXh82Rerg= X-Received: by 2002:a37:9384:: with SMTP id v126mr21406143qkd.279.1593549936012; Tue, 30 Jun 2020 13:45:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl0r385bL1CCQ43sCi04YewH2j6MjNKst8FXnzcKtfYGfPRrvD9MYri9EdNQZ89OEEZX5aig== X-Received: by 2002:a37:9384:: with SMTP id v126mr21406084qkd.279.1593549935438; Tue, 30 Jun 2020 13:45:35 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id u6sm4405162qtk.9.2020.06.30.13.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 13:45:34 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , peterx@redhat.com, John Hubbard , Michael Ellerman , Gerald Schaefer , Andrea Arcangeli , Linus Torvalds , Will Deacon , Nick Hu , Greentime Hu , Vincent Chen Subject: [PATCH v4 12/26] mm/nds32: Use general page fault accounting Date: Tue, 30 Jun 2020 16:45:33 -0400 Message-Id: <20200630204533.39053-1-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 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: AC07C100ED9E0 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. Fix PERF_COUNT_SW_PAGE_FAULTS perf event manually for page fault retries, by moving it before taking mmap_sem. CC: Nick Hu CC: Greentime Hu CC: Vincent Chen Acked-by: Greentime Hu Signed-off-by: Peter Xu --- arch/nds32/mm/fault.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/arch/nds32/mm/fault.c b/arch/nds32/mm/fault.c index d0ecc8fb5b23..f02524eb6d56 100644 --- a/arch/nds32/mm/fault.c +++ b/arch/nds32/mm/fault.c @@ -121,6 +121,8 @@ void do_page_fault(unsigned long entry, unsigned long addr, if (unlikely(faulthandler_disabled() || !mm)) goto no_context; + perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr); + /* * As per x86, we may deadlock here. However, since the kernel only * validly references user space from well defined areas of the code, @@ -206,7 +208,7 @@ void do_page_fault(unsigned long entry, unsigned long addr, * the fault. */ - fault = handle_mm_fault(vma, addr, flags, NULL); + fault = handle_mm_fault(vma, addr, flags, regs); /* * If we need to retry but a fatal signal is pending, handle the @@ -228,22 +230,7 @@ void do_page_fault(unsigned long entry, unsigned long addr, goto bad_area; } - /* - * Major/minor page fault accounting is only done on the initial - * attempt. If we go through a retry, it is extremely likely that the - * page will be found in page cache at that point. - */ - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr); if (flags & FAULT_FLAG_ALLOW_RETRY) { - if (fault & VM_FAULT_MAJOR) { - tsk->maj_flt++; - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, - 1, regs, addr); - } else { - tsk->min_flt++; - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, - 1, regs, addr); - } if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;