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 DE6BCC433E0 for ; Fri, 26 Jun 2020 22:36:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9C4EF2089D for ; Fri, 26 Jun 2020 22:36:21 +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="SdnZ79Pd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C4EF2089D 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 319826B0007; Fri, 26 Jun 2020 18:36:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C9696B0008; Fri, 26 Jun 2020 18:36:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B8586B000A; Fri, 26 Jun 2020 18:36:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id 03F576B0007 for ; Fri, 26 Jun 2020 18:36:20 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9C587824556B for ; Fri, 26 Jun 2020 22:36:20 +0000 (UTC) X-FDA: 76972822920.13.eye27_2c0fa2226e59 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 71C0118140B67 for ; Fri, 26 Jun 2020 22:36:20 +0000 (UTC) X-HE-Tag: eye27_2c0fa2226e59 X-Filterd-Recvd-Size: 5727 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Fri, 26 Jun 2020 22:36:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593210979; 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=ewTqBfexdBAI6q+mW9BG6/0EyFw+GuUSZgL1KkcFzfA=; b=SdnZ79PdevbOYxUX6fcUxSrQeIG3yB5PxJNVhXU7g152kCSOhHGhLvxVO+H/Dfg67puIsV phOc/1Kp1ilwzg1hMcJRRQ+Lw9OAkfeZ8XAX8wTzeqzZQTtaJsdMid6nTbJsSrRWRwSGl0 f+/qnl7fpjobYhVU6yb0XVBSHpXiQZA= 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-304-C_cuPavOPoSNbsmzZDLqzg-1; Fri, 26 Jun 2020 18:36:18 -0400 X-MC-Unique: C_cuPavOPoSNbsmzZDLqzg-1 Received: by mail-qt1-f198.google.com with SMTP id e4so7542049qtd.13 for ; Fri, 26 Jun 2020 15:36:17 -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=ewTqBfexdBAI6q+mW9BG6/0EyFw+GuUSZgL1KkcFzfA=; b=VBS9gVa93aoRbNIT4z49grUeTYeQmq60vZHFfcZwz6UwuH0peHzitQ8YX+3Q4uumCa GgdgU7xhJMXcxsFqoKQtCfztLNfNXVHtSRtOPgcKfKJ0VO+pc3DytnYCUPRowIxVg249 fd5LoPPaIjXSn/XU1vdihztUgRpoEo/mzEYI1JAwqf0EE9T8Ca6shP6M0lkM1d9oPw7H h+CTD/E7J7laVHSQVd/DehavWwCJgCYpKrH7MF9P4ULt/TQp/gJJShQvRwAAa7o0Q3o/ YB3dMSVKjdvKW+UJ0Rz19kGs6955YiGcoWLda+tSCBIOPY+ZG5EE9TwZaI8lE+ul1oca qUFg== X-Gm-Message-State: AOAM5336EBft6Va+FUg7kXfK/OCfzRyqaMOqJV13tjvb/1mtPAc2uzyn RVvuFb2hZe1sdl4A58Lw9GUjQmSmYkBxdC5OAvD9hgnjs0+bEKHzziGv8lqAZ8i8/YSk7j2CdIf 4RLA1k0d1w04= X-Received: by 2002:ac8:23cf:: with SMTP id r15mr1638352qtr.376.1593210977239; Fri, 26 Jun 2020 15:36:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaSmJeTV2K13FAE2UnfH2As0jiqUsCCqIcWadpHoDShGeuM00aHx1b6eKrm7R2RzZrrjAmwA== X-Received: by 2002:ac8:23cf:: with SMTP id r15mr1638331qtr.376.1593210976950; Fri, 26 Jun 2020 15:36:16 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id g41sm11092161qtb.37.2020.06.26.15.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 15:36:16 -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 , Ley Foon Tan Subject: [PATCH 13/26] mm/nios2: Use general page fault accounting Date: Fri, 26 Jun 2020 18:36:14 -0400 Message-Id: <20200626223614.199620-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: 71C0118140B67 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: Ley Foon Tan Signed-off-by: Peter Xu --- arch/nios2/mm/fault.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/arch/nios2/mm/fault.c b/arch/nios2/mm/fault.c index 88abf297c759..823e7d0a9e97 100644 --- a/arch/nios2/mm/fault.c +++ b/arch/nios2/mm/fault.c @@ -24,6 +24,7 @@ #include #include #include +#include =20 #include #include @@ -83,6 +84,8 @@ asmlinkage void do_page_fault(struct pt_regs *regs, uns= igned long cause, if (user_mode(regs)) flags |=3D FAULT_FLAG_USER; =20 + perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); + if (!down_read_trylock(&mm->mmap_sem)) { if (!user_mode(regs) && !search_exception_tables(regs->ea)) goto bad_area_nosemaphore; @@ -131,7 +134,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, u= nsigned long cause, * 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; @@ -146,16 +149,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, = unsigned long cause, BUG(); } =20 - /* - * 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. - */ if (flags & FAULT_FLAG_ALLOW_RETRY) { - if (fault & VM_FAULT_MAJOR) - current->maj_flt++; - else - current->min_flt++; if (fault & VM_FAULT_RETRY) { flags |=3D FAULT_FLAG_TRIED; =20 --=20 2.26.2