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 1FCD1C433E0 for ; Fri, 19 Jun 2020 16:08:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D5BA221532 for ; Fri, 19 Jun 2020 16:08:37 +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="GIYUss6F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5BA221532 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 8599F8D00BC; Fri, 19 Jun 2020 12:08:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 80BAC8D00AD; Fri, 19 Jun 2020 12:08:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F93C8D00BC; Fri, 19 Jun 2020 12:08:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0083.hostedemail.com [216.40.44.83]) by kanga.kvack.org (Postfix) with ESMTP id 55C378D00AD for ; Fri, 19 Jun 2020 12:08:37 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 19A1C180ACC8C for ; Fri, 19 Jun 2020 16:08:37 +0000 (UTC) X-FDA: 76946444274.06.comb78_19141e326e1a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 840DC1012C2C0 for ; Fri, 19 Jun 2020 16:06:06 +0000 (UTC) X-HE-Tag: comb78_19141e326e1a X-Filterd-Recvd-Size: 5609 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Fri, 19 Jun 2020 16:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592582765; 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=fdwEEPmGbF+7vaa9v+aN1XHbOlUdwOKUfmYW6uYEoCM=; b=GIYUss6FFYzfXk6a5xb24arkQPD7tud/C9TGFOu17wcr7F3K96haMT2UFaz5JJsXnxem7K hWNVZj1/7h++tnQnkY2IBpFawPh9QLklrBuIAiP8m37kz02WnGRqa9KZaoR2mYQMe7Uw7E GlS1ytFdXqUnIHATSqYcrcfONCrwgso= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-445-PVT8LVJfPIy1GZQcTCbkMA-1; Fri, 19 Jun 2020 12:06:01 -0400 X-MC-Unique: PVT8LVJfPIy1GZQcTCbkMA-1 Received: by mail-qv1-f70.google.com with SMTP id j4so7030508qvt.20 for ; Fri, 19 Jun 2020 09:06:01 -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=fdwEEPmGbF+7vaa9v+aN1XHbOlUdwOKUfmYW6uYEoCM=; b=szBJvsXindJ5pHG82esZJ3+MAP6nfvN+NVdGo7j8+7Jv5Yeb1GUd54CzEHsIGOZ5to AEH+iuOqHdV4ONMj6noC5fIBNMlyQdnuMeE77EXT5qTLxCsZAnPoq2p9snH884AG6nFV gTPZzHfpkIMx79csKjFgQDnyaxxJmK7Cyt7fvVmsDWifEKeCYoMcsgs4C8S09fl0EQY0 URN5mr58hDVwMoYGl48X7lzNypJjv+Rx47Dc/oEdzzkc5XwCYW9zB4W8LwSMrZq1jF5e fjNQaVe3nWWSRqrlEgxX05xQw4H13zDuPnIuZ100h9PGPTNAKOoeJjJ/UeK42kaP3WK4 TFRw== X-Gm-Message-State: AOAM533fK1Q+0KXCHQeJzn0GQ184XFA7sMpA+bI/IWktf5ZAe+gg2z+9 S6P6VuM+V2TMUKLT0wuGwD4y2WSFpH6Qsix52D4A5XuQSqDsPI3280sDvlI2B3vbygoUB9Le2FE cSrB9hd236cM= X-Received: by 2002:ac8:fec:: with SMTP id f41mr1437130qtk.212.1592582761023; Fri, 19 Jun 2020 09:06:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8wG2GTQ9R1eiAtzaifkaB+aa3jdUijFfrRdNWsFEhdltAKDggKtTyb2MbmKOZqrM66lR9pA== X-Received: by 2002:ac8:fec:: with SMTP id f41mr1437088qtk.212.1592582760619; Fri, 19 Jun 2020 09:06:00 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id g11sm6412604qkk.123.2020.06.19.09.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 09:05:59 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Gerald Schaefer , peterx@redhat.com, Andrew Morton , Andrea Arcangeli , Will Deacon , Michael Ellerman , Linus Torvalds , Thomas Bogendoerfer , linux-mips@vger.kernel.org Subject: [PATCH 11/26] mm/mips: Use general page fault accounting Date: Fri, 19 Jun 2020 12:05:23 -0400 Message-Id: <20200619160538.8641-12-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: 840DC1012C2C0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 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