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 C4CC7C433E6 for ; Tue, 7 Jul 2020 22:50:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8653520738 for ; Tue, 7 Jul 2020 22:50: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="jPkhgB8S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8653520738 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 18E916B00BB; Tue, 7 Jul 2020 18:50:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F06E6B00BD; Tue, 7 Jul 2020 18:50:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF95C6B00BE; Tue, 7 Jul 2020 18:50:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id D594A6B00BB for ; Tue, 7 Jul 2020 18:50:50 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9E2F6181AEF09 for ; Tue, 7 Jul 2020 22:50:50 +0000 (UTC) X-FDA: 77012776260.25.rings20_081292826eb8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 6FBC51804E3A8 for ; Tue, 7 Jul 2020 22:50:50 +0000 (UTC) X-HE-Tag: rings20_081292826eb8 X-Filterd-Recvd-Size: 5897 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 22:50:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594162249; 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=/OgQ3igxRFmWHn0+Y9XrBgGWT5Mzg0+fUW3Zyepd27I=; b=jPkhgB8SaZF6hNFB6XVd0R4oIY+lLEdxz+mCctAitdsND2xyZS7FDDi1pkz5wKrcwjB8uD VuIzVNlVq1ujtxETAlriwLuji4YGtLL4vKSY0ZQ9LsVmvbQis5t774DOBsdrbDY8lK4p1M nySH73l78c+cmPnMxY8QtFWDGDPAlsU= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-173-RT3rApaSPqqrKV4AARKsQg-1; Tue, 07 Jul 2020 18:50:46 -0400 X-MC-Unique: RT3rApaSPqqrKV4AARKsQg-1 Received: by mail-qk1-f199.google.com with SMTP id u186so29689447qka.4 for ; Tue, 07 Jul 2020 15:50:45 -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=/OgQ3igxRFmWHn0+Y9XrBgGWT5Mzg0+fUW3Zyepd27I=; b=Hsxo4Kugh4mlKZbrHvqQOsAnIUpixmqawnzOzTdtCbkgCJYJVn6/hQ7zYCpSxJFnYw 8yPe3qkAXUlegatEi+tea2UUKJPoxnqSWln1otzqr0ug4POrIzDIGJoH+MgvcjGdPvbe fWCOhXFX0p4roSB1VXg6Fnlt6SRgiyaB977jeEClFWz5tSzywZX8BCEkf7/23D4So9xz g+E3bw7GqTVJyY7OKypqxBhb2q0QAf2/P/GXFFKo9Ben1qjGwKAS1436xn672RhkNny3 tKFHoZAGMpNiBHuvTpMMLsmrZfTH6SMQWY59dwAxtQLsoapKiVZxp0xv6vaYuaF8lh34 3Ctg== X-Gm-Message-State: AOAM530/ha5aOOGbsvItgMNHDFn11l4KaqaVnoZUZKkdLzqxJB44hAr+ lBfOIOo5W8jK15XgxMpd2lMP+JlUptt3As1L4E0GFKS/9BVTEkoQ3euxnKVoS0B9G9qW5+dqxCL F8ted9G7oJR0= X-Received: by 2002:ad4:5483:: with SMTP id q3mr51466116qvy.99.1594162245543; Tue, 07 Jul 2020 15:50:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlFdKalFtzU5Fvl/PrOhZ5qVXzLaWruqJEUEJUgHwOhQFZp7/OQ1u5JWMVDkzqi6qvwk/FLQ== X-Received: by 2002:ad4:5483:: with SMTP id q3mr51466092qvy.99.1594162245273; Tue, 07 Jul 2020 15:50:45 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id j16sm26267642qtp.92.2020.07.07.15.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 15:50:44 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Gerald Schaefer , Linus Torvalds , peterx@redhat.com, Andrew Morton , Will Deacon , Andrea Arcangeli , David Rientjes , John Hubbard , Michael Ellerman , Ley Foon Tan Subject: [PATCH v5 13/25] mm/nios2: Use general page fault accounting Date: Tue, 7 Jul 2020 18:50:09 -0400 Message-Id: <20200707225021.200906-14-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200707225021.200906-1-peterx@redhat.com> References: <20200707225021.200906-1-peterx@redhat.com> 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: 6FBC51804E3A8 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: 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 86beb9a2698e..9476feecf512 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 (!mmap_read_trylock(mm)) { 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