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 3EFFAC433E2 for ; Fri, 26 Jun 2020 22:32:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EDCCD20FC3 for ; Fri, 26 Jun 2020 22:32:01 +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="H0D/yrQx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDCCD20FC3 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 961606B0026; Fri, 26 Jun 2020 18:31:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EBE36B0027; Fri, 26 Jun 2020 18:31:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69EA26B0028; Fri, 26 Jun 2020 18:31:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0098.hostedemail.com [216.40.44.98]) by kanga.kvack.org (Postfix) with ESMTP id 4A1C66B0026 for ; Fri, 26 Jun 2020 18:31:54 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0DE82180AD806 for ; Fri, 26 Jun 2020 22:31:54 +0000 (UTC) X-FDA: 76972811748.12.beef49_170dcee26e59 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id CCDE518011938 for ; Fri, 26 Jun 2020 22:31:53 +0000 (UTC) X-HE-Tag: beef49_170dcee26e59 X-Filterd-Recvd-Size: 5681 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Fri, 26 Jun 2020 22:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593210712; 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=u5CO9Ioy3aEI+rpepvYK9awRSU/1xBbKoMWw19CoOCA=; b=H0D/yrQxmDNTxx7UWppno1c7i66X0IcZmzN0hP2MjrerVgZzAIg4MaAeQoHgeqJXi5KAIb Xtum8V//K8MW7DNA9xTti1KHJqNN+n+CuN75BqkuKOgAI4GL+I/neEHhjI3mewBXmO1T+7 lhOnUtrw4Mzpn6qYpoFgBmNalm16E88= 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-447-dwSmT3XBOMGGlGiH0IsZNA-1; Fri, 26 Jun 2020 18:31:51 -0400 X-MC-Unique: dwSmT3XBOMGGlGiH0IsZNA-1 Received: by mail-qt1-f197.google.com with SMTP id l26so7535241qtr.14 for ; Fri, 26 Jun 2020 15:31:51 -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=u5CO9Ioy3aEI+rpepvYK9awRSU/1xBbKoMWw19CoOCA=; b=ueUIX7aVi5i4KUKZR0w13DjAILyTdoXU3PhTrKrRndebY9og0L2hLzlLahbwIusvo8 k5FQaSlMMdlL9u/WyVUGFAOV+t3pFnXfassh2Br7XXJOPpF+nthGDCdxsLDwmTN90E/i XPoCJeDijHwlfxkNw4i2pEWMivVWqJ5gT/hjhQanAHVkcmz2k7NxkkL0EqKGGKPxuk9T pLH8IEM/RCmwYWhW7E3WPzadGRvWo2ZT1AtygKdS18e5JXD9fBuslTm4O9p443ckBzdm sRqAO5isbFEWTieF5/lBsyYMv4oyNXIWFVI8fI7ivU2Q6NGUnh3qGPQy5B6jJ+DLd+/I 08ZA== X-Gm-Message-State: AOAM532nTQoasJD9andLzjoDaqDsjuthnpvr8+3uhHirpA4RptwD22HM XuDj2hd0QjTaEmH6niKqE9LCm9Y7+p6OqMwG8StME7yyQaXyHpca3qOV3CPLiMJq/2TBR9dpLir A+f+k3UK5/2w= X-Received: by 2002:ac8:1bad:: with SMTP id z42mr5330175qtj.110.1593210710384; Fri, 26 Jun 2020 15:31:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx55mkHv5JA7KsCjLa9A+G8OruKBcVHC68/qR9rih5tmrLSf1Prppo2YVIg8T1r9n5+R3Awzw== X-Received: by 2002:ac8:1bad:: with SMTP id z42mr5330160qtj.110.1593210710153; Fri, 26 Jun 2020 15:31:50 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id f203sm9903311qke.135.2020.06.26.15.31.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 15:31:49 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , Linus Torvalds , Gerald Schaefer , Andrea Arcangeli , Will Deacon , peterx@redhat.com, Michael Ellerman , Thomas Bogendoerfer , linux-mips@vger.kernel.org Subject: [PATCH 11/26] mm/mips: Use general page fault accounting Date: Fri, 26 Jun 2020 18:31:15 -0400 Message-Id: <20200626223130.199227-12-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: CCDE518011938 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 31c2afb8f8a5..750a4978a12b 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: down_read(&mm->mmap_sem); 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