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.5 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 30889C433DF for ; Fri, 19 Jun 2020 16:14:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E6089217A0 for ; Fri, 19 Jun 2020 16:13:59 +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="Eo0LwMD0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6089217A0 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 8F4A98D00C3; Fri, 19 Jun 2020 12:13:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 87D968D00AD; Fri, 19 Jun 2020 12:13:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76CA08D00C3; Fri, 19 Jun 2020 12:13:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id 5B3E58D00AD for ; Fri, 19 Jun 2020 12:13:59 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 220B2180ADD0E for ; Fri, 19 Jun 2020 16:13:59 +0000 (UTC) X-FDA: 76946457798.05.plane39_0c1365626e1a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id A1B8318028204 for ; Fri, 19 Jun 2020 16:13:57 +0000 (UTC) X-HE-Tag: plane39_0c1365626e1a X-Filterd-Recvd-Size: 6379 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Fri, 19 Jun 2020 16:13:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592583236; 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=Eo0LwMD0s9ySr3NzXZ9MyvFhOu9ZJl8bvnzJsCYLPjlGcIAZreCdtv+XhgLQUIW61D9SF5 0jp2q9w1OS7o6T2Pr7HXmPNOUyhsY/expJrKMIXfOD2X/I5I2oIXxQTeNhbVXC5yg0USVW G2x0sATbWwmuKdrHFTw8mO9zDCxM8t4= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-249-GSQ-zA9_NtuhICEpVMahmw-1; Fri, 19 Jun 2020 12:13:54 -0400 X-MC-Unique: GSQ-zA9_NtuhICEpVMahmw-1 Received: by mail-qt1-f197.google.com with SMTP id q21so7446443qtn.20 for ; Fri, 19 Jun 2020 09:13:54 -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=WbvWc4I2uly70H+0ed4j9F8nBna6wCv6iHyCr+OnV/TLt8v0bEmPr/ntov+GPnn7Hw VzB7uXv0BFBjcJ+hPSKGDpddZUT8hyZnJSm+0gbqq+giEgwexMOsEJt5/JfgvaOF0oeK a5l4fU9wGDEIevDByHEo/S4GnnBLRAS2anI4NbsTqbcgpgSdK/ppTFxvfb+Z6jDj+J5E Zha/GbUHGw4aTNDko4HpBW8PZKy2mCxfg6gqfR0IQkeMM+MKuaIdAhKG9c2I2F+I2AkD ZRoWhU9Xu2NnGL4e+yyFQFLJqxnQEoClS80N0HpSNuQbQZdNLZKDaz8Lpf2rXPpj1gn0 ygJw== X-Gm-Message-State: AOAM532ZwoGTIn3WhskX2JIY4EaxBMpOkuAcmV4UqTrgcGjX1tY1PRuT U561CcTIeDGBTxXZhITPXiaTCom9zx1ZnyqmtH7g/FX+0iagJ/0sytB5cNSfAbplooLnIGngcXd MjM1ZTKj8+Eg= X-Received: by 2002:a05:620a:538:: with SMTP id h24mr3790587qkh.13.1592583233880; Fri, 19 Jun 2020 09:13:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoIDne3D6Lyc/+ePjNzlFOb4ZPCNYmFPc0mxtEwDaPmhR5/H3npMIraUQuPAc8rRqyj8GbKA== X-Received: by 2002:a05:620a:538:: with SMTP id h24mr3790569qkh.13.1592583233626; Fri, 19 Jun 2020 09:13:53 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id z46sm6066253qtb.57.2020.06.19.09.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 09:13:52 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Peter Xu , Gerald Schaefer , Andrew Morton , Andrea Arcangeli , Will Deacon , Michael Ellerman , Linus Torvalds , Guan Xuetao Subject: [PATCH 22/26] mm/unicore32: Use general page fault accounting Date: Fri, 19 Jun 2020 12:13:51 -0400 Message-Id: <20200619161351.9859-1-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200619160538.8641-1-peterx@redhat.com> References: <20200619160538.8641-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: A1B8318028204 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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