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 8CCCCC433E6 for ; Tue, 30 Jun 2020 20:45:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 41C90207FB for ; Tue, 30 Jun 2020 20:45:38 +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="DA/zp1Gw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41C90207FB 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 841A36B002A; Tue, 30 Jun 2020 16:45:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F28F6B002B; Tue, 30 Jun 2020 16:45:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 694056B002C; Tue, 30 Jun 2020 16:45:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0196.hostedemail.com [216.40.44.196]) by kanga.kvack.org (Postfix) with ESMTP id 549D86B002A for ; Tue, 30 Jun 2020 16:45:37 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 13A791EE6 for ; Tue, 30 Jun 2020 20:45:37 +0000 (UTC) X-FDA: 76987059114.15.soup66_2f030c126e7a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 9813C1814B0C8 for ; Tue, 30 Jun 2020 20:45:36 +0000 (UTC) X-HE-Tag: soup66_2f030c126e7a X-Filterd-Recvd-Size: 5634 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Tue, 30 Jun 2020 20:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593549935; 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=DEmzww7H5zywGqZA9zT7LUnhxIyJ8MI0ZWzVs6Wigj0=; b=DA/zp1GwmEkNzo8wm7P6iM4zBxyQwj+KthkoWBgvSDeIuYOnHcJba9gWWa5rqUW8wpUbI7 hXbFPCzvyTh3/X536edg1B7oQyBIBK9TqgSXKhed7K9SSg5zlWpF+R4oJA57LMP4UV+KzO GdNk5f37wgbf1vmptrPhq0Zv/YsHzTk= 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-188-y71Og_m8PY29KSVXuyC3cQ-1; Tue, 30 Jun 2020 16:45:34 -0400 X-MC-Unique: y71Og_m8PY29KSVXuyC3cQ-1 Received: by mail-qt1-f197.google.com with SMTP id c22so15314398qtp.9 for ; Tue, 30 Jun 2020 13:45:33 -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=DEmzww7H5zywGqZA9zT7LUnhxIyJ8MI0ZWzVs6Wigj0=; b=Jv/1wKbmSTrKGSi1sdxaWfXoQorzC7/Dtq+uekPs49eqK9C+/mLm5Xmb+tzVnWp3Iw qdwSjPCRsDtHPM4PBKKG18QcZ+U5Gg8GBjCXR2jvyV3ij4so/Xv5Ikr+e0lFILUC7itd 0AlSSA+D5FcBwjVNHD1/WHOGtoI21EEQFwmMtii01jCrI7PVhNObfEAY9YjjpeZfc7q8 peCsNLzbaCHSA5UMamCflcfHtPMOADeB9c9Y8um/sNDVPJ0vmqb0tAbvlqOrzk3XwozQ j9I7ttnN9xX0HEZlmZ/ouu67I3vlDf6+QMpFzM2k4Q+uWFvq9vEJfQsIRtQUb2CM3xPe eRjQ== X-Gm-Message-State: AOAM531N1oAVjyqw33+xde4vsxvQoSsUPjKQwaaf8mphK6MUqVxWGZ04 O6CV+t81EK0Fik6jcqiq1wHQ0LHktP62UqYf2kqhKW4nNMiueQxtSLWETZito7nEtax7GF0O8rW 7Q2cNZYjgIy0= X-Received: by 2002:a0c:f385:: with SMTP id i5mr22470545qvk.4.1593549933145; Tue, 30 Jun 2020 13:45:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlcR9sS9E2sPm9khBe36+osfWhMWvjfpILkpvioRaSYPtX3w5/pAVkcwQLHo7Ww9mgcZBAyg== X-Received: by 2002:a0c:f385:: with SMTP id i5mr22470520qvk.4.1593549932874; Tue, 30 Jun 2020 13:45:32 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id b186sm3862220qkd.28.2020.06.30.13.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 13:45:32 -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 , Thomas Bogendoerfer , linux-mips@vger.kernel.org Subject: [PATCH v4 11/26] mm/mips: Use general page fault accounting Date: Tue, 30 Jun 2020 16:45:30 -0400 Message-Id: <20200630204530.39003-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: 9813C1814B0C8 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. Fix PERF_COUNT_SW_PAGE_FAULTS perf event manually for page fault retries,= by moving it before taking mmap_sem. CC: Thomas Bogendoerfer CC: linux-mips@vger.kernel.org Acked-by: Thomas Bogendoerfer Signed-off-by: Peter Xu --- arch/mips/mm/fault.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c index b1db39784db9..7c871b14e74a 100644 --- a/arch/mips/mm/fault.c +++ b/arch/mips/mm/fault.c @@ -96,6 +96,8 @@ static void __kprobes __do_page_fault(struct pt_regs *r= egs, unsigned long write, =20 if (user_mode(regs)) flags |=3D FAULT_FLAG_USER; + + perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); retry: mmap_read_lock(mm); vma =3D find_vma(mm, address); @@ -152,12 +154,11 @@ static void __kprobes __do_page_fault(struct pt_reg= s *regs, unsigned long write, * make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =3D handle_mm_fault(vma, address, flags, NULL); + fault =3D handle_mm_fault(vma, address, flags, regs); =20 if (fault_signal_pending(fault, regs)) return; =20 - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); if (unlikely(fault & VM_FAULT_ERROR)) { if (fault & VM_FAULT_OOM) goto out_of_memory; @@ -168,15 +169,6 @@ static void __kprobes __do_page_fault(struct pt_regs= *regs, unsigned long write, BUG(); } if (flags & FAULT_FLAG_ALLOW_RETRY) { - if (fault & VM_FAULT_MAJOR) { - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, - regs, address); - tsk->maj_flt++; - } else { - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, - regs, address); - tsk->min_flt++; - } if (fault & VM_FAULT_RETRY) { flags |=3D FAULT_FLAG_TRIED; =20 --=20 2.26.2