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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 8AF19C433E0 for ; Fri, 26 Jun 2020 22:36:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 48A9D20C09 for ; Fri, 26 Jun 2020 22:36:46 +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="UqDxZYHe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48A9D20C09 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 C92B36B002F; Fri, 26 Jun 2020 18:36:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF3A76B0030; Fri, 26 Jun 2020 18:36:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6B8E6B0031; Fri, 26 Jun 2020 18:36:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id 8ED176B002F for ; Fri, 26 Jun 2020 18:36:45 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 528AC181ABE85 for ; Fri, 26 Jun 2020 22:36:45 +0000 (UTC) X-FDA: 76972823970.08.hat57_6013fbb26e59 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 2D7591819E769 for ; Fri, 26 Jun 2020 22:36:45 +0000 (UTC) X-HE-Tag: hat57_6013fbb26e59 X-Filterd-Recvd-Size: 6377 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Fri, 26 Jun 2020 22:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593211004; 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=djMzqxEX2KOhdS0mA0I6TixiZlYRFWjkTEipCw3bAqk=; b=UqDxZYHelkcjc4KhoS1/ky7iM8+qJ5lN0wszWPwETGQIW4CRlfuaCunmLLXNl0OEFBOB9+ odNbHmgzZTmfgHbPhT7T2PLdN265vLNtaGBHiTgvy0q5hB/yoeJWorRRAvgN0zzNh6Kezk ENUV7IhRvu/oV1EHr8F4M6Op3ueXPAc= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-296-dAZ5Bx5HMze3Y8vIXpGNMA-1; Fri, 26 Jun 2020 18:36:41 -0400 X-MC-Unique: dAZ5Bx5HMze3Y8vIXpGNMA-1 Received: by mail-qt1-f198.google.com with SMTP id c26so7528345qtq.6 for ; Fri, 26 Jun 2020 15:36:41 -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=djMzqxEX2KOhdS0mA0I6TixiZlYRFWjkTEipCw3bAqk=; b=RTxDchzwDsjvxWuWflRkNWSfN2pXob2LA9YiSDrVj1jOnTA0BklDmgrbF5OsYi6Hbe 0MGuqoPjwadMv4eqVNGDsfPxXMvyIwyyY3WkThjxdeu689ZdLDlDmReoUuyjmuC1hIOX Zuzs8K7y5Qa1TKt/2Xl8qdsTKbfI0IUSDECNDaLQ5dHoJSMJ+uUiinXNR3nu73KZTlgY OfrLpTLFiAoGMPPzM0PN7aAaSAPducO/Fsm6+t99IpCLJ3QDXKWq95Z9kX5FyMyZBYT8 Q4k2jl65IUMRH+K/rQDUtmtLNSLj4iur199BEJXKWt4PJLdct4ac0SNnma0zOlHSp8U8 A3ug== X-Gm-Message-State: AOAM5333Ny/sV6hwTI1iieOr3JSPhjDS7KWV+S0Z1h8XWqS3h5fgaWHg Lbj1tWqWRWjlzK4NH97kZ61f7f2s5lfVEB2vj9vKfUSNuN94Y/cvCgbgp2uJaJ4mU6JrVcnGRlE IEj5cLe1ntZA= X-Received: by 2002:a37:4e84:: with SMTP id c126mr5001467qkb.7.1593211000273; Fri, 26 Jun 2020 15:36:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUp1+SFGQDRo0mF95Sau3QQtThG/ZGcjdmMx6Df1C1qf3AIRaxiOeUWjit0m8/ftvHLQqSzg== X-Received: by 2002:a37:4e84:: with SMTP id c126mr5001450qkb.7.1593211000037; Fri, 26 Jun 2020 15:36:40 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id f18sm2019707qtc.28.2020.06.26.15.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 15:36:39 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Peter Xu , Andrew Morton , Linus Torvalds , Gerald Schaefer , Andrea Arcangeli , Will Deacon , Michael Ellerman , Guan Xuetao Subject: [PATCH 22/26] mm/unicore32: Use general page fault accounting Date: Fri, 26 Jun 2020 18:36:37 -0400 Message-Id: <20200626223637.200054-1-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200626223130.199227-1-peterx@redhat.com> References: <20200626223130.199227-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 2D7591819E769 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable 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_faul= t(). It naturally solve the issue of multiple page fault accounting when page = fault retry happened. Add the missing PERF_COUNT_SW_PAGE_FAULTS perf events too. Note, the oth= er two perf events (PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN]) were done in handle_mm_= fault(). CC: Guan Xuetao Signed-off-by: Peter Xu --- arch/unicore32/mm/fault.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c index 847ff24fcc2a..b272a389d977 100644 --- a/arch/unicore32/mm/fault.c +++ b/arch/unicore32/mm/fault.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 #include #include @@ -160,7 +161,8 @@ static inline bool access_error(unsigned int fsr, str= uct vm_area_struct *vma) } =20 static vm_fault_t __do_pf(struct mm_struct *mm, unsigned long addr, - unsigned int fsr, unsigned int flags, struct task_struct *tsk) + unsigned int fsr, unsigned int flags, + struct task_struct *tsk, struct pt_regs *regs) { struct vm_area_struct *vma; vm_fault_t fault; @@ -186,7 +188,7 @@ static vm_fault_t __do_pf(struct mm_struct *mm, unsig= ned long addr, * If for any reason at all we couldn't handle the fault, make * sure we exit gracefully rather than endlessly redo the fault. */ - fault =3D handle_mm_fault(vma, addr & PAGE_MASK, flags, NULL); + fault =3D handle_mm_fault(vma, addr & PAGE_MASK, flags, regs); return fault; =20 check_stack: @@ -219,6 +221,8 @@ static int do_pf(unsigned long addr, unsigned int fsr= , struct pt_regs *regs) if (!(fsr ^ 0x12)) flags |=3D FAULT_FLAG_WRITE; =20 + 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, @@ -244,7 +248,7 @@ static int do_pf(unsigned long addr, unsigned int fsr= , struct pt_regs *regs) #endif } =20 - fault =3D __do_pf(mm, addr, fsr, flags, tsk); + fault =3D __do_pf(mm, addr, fsr, flags, tsk, regs); =20 /* If we need to retry but a fatal signal is pending, handle the * signal first. We do not need to release the mmap_sem because @@ -254,10 +258,6 @@ static int do_pf(unsigned long addr, unsigned int fs= r, struct pt_regs *regs) return 0; =20 if (!(fault & VM_FAULT_ERROR) && (flags & FAULT_FLAG_ALLOW_RETRY)) { - if (fault & VM_FAULT_MAJOR) - tsk->maj_flt++; - else - tsk->min_flt++; if (fault & VM_FAULT_RETRY) { flags |=3D FAULT_FLAG_TRIED; goto retry; --=20 2.26.2