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,URIBL_BLOCKED,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 DA1F1C433EC for ; Tue, 30 Jun 2020 20:46:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9B87B20772 for ; Tue, 30 Jun 2020 20:46:12 +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="B+eb6OQH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B87B20772 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 3368D6B0073; Tue, 30 Jun 2020 16:46:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 310A26B0075; Tue, 30 Jun 2020 16:46:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 227CE6B0078; Tue, 30 Jun 2020 16:46:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0144.hostedemail.com [216.40.44.144]) by kanga.kvack.org (Postfix) with ESMTP id 0BAA66B0073 for ; Tue, 30 Jun 2020 16:46:12 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C3DD6180AD804 for ; Tue, 30 Jun 2020 20:46:11 +0000 (UTC) X-FDA: 76987060542.28.heart56_4a0586f26e7a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id A0C7D6C17 for ; Tue, 30 Jun 2020 20:46:11 +0000 (UTC) X-HE-Tag: heart56_4a0586f26e7a X-Filterd-Recvd-Size: 6308 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Tue, 30 Jun 2020 20:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593549970; 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=4RAHTSP5z0C7SFvi5Ey3JD7YAbQrWHUIepHjbZsf2aU=; b=B+eb6OQHqdgOiKp70ad2QOYUZsR77k6mhj1aFCvt2OPKSygvxZkf9EtdBohMivm+CXiocC fmvMCmBApJNr+LCYjHn0mbRlOAnO8z2bAYcdvj137wUaQkJi0P9S9E1fcb4fftomuSjhjn 8FeeC0MMFyYwUEbP7IsXcKR/3Ic/qKw= 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-253-D4xWQrkQMWWNZW3_aPDLuQ-1; Tue, 30 Jun 2020 16:46:03 -0400 X-MC-Unique: D4xWQrkQMWWNZW3_aPDLuQ-1 Received: by mail-qv1-f71.google.com with SMTP id w3so14675893qvl.9 for ; Tue, 30 Jun 2020 13:46: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:mime-version :content-transfer-encoding; bh=4RAHTSP5z0C7SFvi5Ey3JD7YAbQrWHUIepHjbZsf2aU=; b=mFxbmb74V75ZW0ztzmdW8a2E6ezm4LYA5w2tvuQfP8uOqCtl3EQ2YZ08IlNoE2zHmT lKLP434hM6H8y4T86U/7Bcw7Vf4pXWfNKF9vD2I+Ovbg36KWMMBXSjVVjcDmD3zAtPhC EiQzpYGw6MI6eQJK401A1pH6/zkjyRwJJyYg2srSeLesQKDYz4MqPA4QfvOufpFxULHC BCJkkp5b1/VFos/N3VODuw1Av6skTxOyJm2B9+lJ+nbxnKrobdLK5tEm5XzZ0PVP5CJ6 bRbEQ7C3VkoGeYVYqL3Qc9tGQpBPmXExicLE37BlDXCmnZyESQgGda8CNG0bWZaf/DOv ymSg== X-Gm-Message-State: AOAM531Ds2GoK00fkdHGtEWi1dujhrhl8LmlpZXqZjIhye2BZld8ImvF ctwE3diOK2PV/qKlgE/ycXlLWYLB8vqGGSCTU0tzbGg73cl6PrEdvnhtTt2nxckaJyOVaRXgVlr ct31L5VVP354= X-Received: by 2002:a37:5b81:: with SMTP id p123mr21686109qkb.150.1593549961533; Tue, 30 Jun 2020 13:46:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZM7dYXcf5y/PjIzLQzsAt1kp+Qf2qriyfk9Ij6NWjLpMdeiq7I8wMzFAUueBBnMbxGIlWpg== X-Received: by 2002:a37:5b81:: with SMTP id p123mr21686090qkb.150.1593549961276; Tue, 30 Jun 2020 13:46:01 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id u124sm3833681qkf.83.2020.06.30.13.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 13:46:00 -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 , Guan Xuetao Subject: [PATCH v4 22/26] mm/unicore32: Use general page fault accounting Date: Tue, 30 Jun 2020 16:45:59 -0400 Message-Id: <20200630204559.39539-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 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: A0C7D6C17 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 9b4539d8d669..69bf99bcd8fd 100644 --- a/arch/unicore32/mm/fault.c +++ b/arch/unicore32/mm/fault.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 #include =20 @@ -159,7 +160,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; @@ -185,7 +187,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: @@ -218,6 +220,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, @@ -243,7 +247,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_lock because @@ -253,10 +257,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