Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2000311ybt; Mon, 15 Jun 2020 15:25:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD/ROLEi8bb/Np7QA2pmAUw7scaX8Z65FBn8oqlHP0hjDxb6N5jEGSlFm8JEnzmeMk+pLf X-Received: by 2002:a17:906:198d:: with SMTP id g13mr14879961ejd.281.1592259928316; Mon, 15 Jun 2020 15:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592259928; cv=none; d=google.com; s=arc-20160816; b=oXbXVZmwXs+fMKhG+CvE63IOX38yB1DSjktKi4XhjUgl9VgPu0IR8W2guqYe0lipTP 5ePe9WyTC8KZZbpfzX6rvBXyv+SL2wSABTtW54Y98PL/+Cpszx9S+GaAk4V5AKYG8Y6f rPtU2d7NsfZWvfThDYlOCxDPz7aDXdLLVlfwxpOaHKeYz9hNWUdgX05HmUsl2LMUcSoZ 0okYoHB3FN3F9rwtYoXL/1JbJchHsMY5PTyw/Q77iShgbt7hs+vJN7IcC/PFNaK9cbUW CkCiZCFLnAAeRNaaQ51IcH91xJE/K2uATPb924clHuodXG54IDNcGP8Bs97VlWtX3LIq jb0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hWAHEvELG7PCXiHldR7PdlXbQKIkg3HJngutFs9FQdI=; b=FT3Kq+K36uBbKvHCljZcmpEtEYN6TKYIswuYW3duieJo3Fz68O7Sz8ualh3IDY6B/l NKhZKPfoqdmeRXTnX7vM9ZhnrMTVU6FtBIcWfekQBcyJjpQumK+TNZ+2ZLb1caA3pa5c KqtY1+ySIlanyDE/DEYus4d7i3p2gCNr54rVEOQn1DkKJSi4HeL8t1eEyzGxzWdwtwx3 knrM3ClYanLpaI/C+pHro/EbFQAZuRbAfPBigIVKjEtnn7XzijYBGtYjfWfXbrxCMkFi P2fG4zYIwzDjsn7S+kOwEpC3atgS9gkLQ7OAcR6EiRsXapBtH7RLn/mPq6w7ZvAkxCk3 brPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LiuL+G5P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id si25si10246462ejb.43.2020.06.15.15.25.06; Mon, 15 Jun 2020 15:25:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LiuL+G5P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726526AbgFOWXN (ORCPT + 99 others); Mon, 15 Jun 2020 18:23:13 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:43335 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726314AbgFOWXM (ORCPT ); Mon, 15 Jun 2020 18:23:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592259791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hWAHEvELG7PCXiHldR7PdlXbQKIkg3HJngutFs9FQdI=; b=LiuL+G5PRpvHXqyEnZHBShVsSfHxZ+C9ExOAtt8DgJHK8bvimxEns1tnodOjCPpaOqy3Vl Dp70aIH5RubYG4QntPYpLY50Slek689rXzw91zvmAEitjrvmyxsTrVsyhS/0e9BCOt0XX/ JwAhsBvc2kCiuV9LsmlQxhQXMn6HSc8= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-30-gWqiYIhtO6O2UTi8_SSFUg-1; Mon, 15 Jun 2020 18:23:09 -0400 X-MC-Unique: gWqiYIhtO6O2UTi8_SSFUg-1 Received: by mail-qv1-f72.google.com with SMTP id t20so14080448qvy.16 for ; Mon, 15 Jun 2020 15:23:09 -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=hWAHEvELG7PCXiHldR7PdlXbQKIkg3HJngutFs9FQdI=; b=Kxa6ge80l3dJb78vrkAtlQREjJySZTTig8ZXleUYnxsqzDbmAGJeQIo11/W1Ryg6WV RynMQVoIolmmf0IPwnFc42871M+hv+VRn5wcxpBfmlZ8mMbTemaTGDJgaLtgwGwcMva+ FtsBtaE+i3wJt0eFADiD58CchgxR2uvDvJ0jlwgBfnBEQ8UYV+Q9vQTO8YkapEG9RYkb ewJWBljS979SLKaXdimF3mS6RBgW5JLteMBWX3pLypAWNY/9bJVWjW+DxKNrRjih67RG P9bGNqxrWxcE8qKqa4r1wuNIFCw0f74hU6rJRILq4esaI923xKMWluHmMC7FSyoh9LA+ ozlQ== X-Gm-Message-State: AOAM533KDyya3wDlSZ8ASO8XrCsYCzi7OKvw+gMW49FI+Ja6Jql4Ze5w mojvhCL/wRumopCvZmd9axh7QlvWiWnbret/A+b4J3xC6JtNB8stE1/6bsX9vOthrTdOcq+Wvyf sfoaNLLHFZ/5Yt7lwlAtIoUk1 X-Received: by 2002:a0c:f84c:: with SMTP id g12mr26695599qvo.31.1592259788750; Mon, 15 Jun 2020 15:23:08 -0700 (PDT) X-Received: by 2002:a0c:f84c:: with SMTP id g12mr26695582qvo.31.1592259788510; Mon, 15 Jun 2020 15:23:08 -0700 (PDT) Received: from xz-x1.hitronhub.home ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id q38sm14019321qtb.74.2020.06.15.15.23.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 15:23:07 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org Cc: Peter Xu , Gerald Schaefer , Andrew Morton , Linus Torvalds , Andrea Arcangeli , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH 20/25] mm/sh: Use mm_fault_accounting() Date: Mon, 15 Jun 2020 18:23:06 -0400 Message-Id: <20200615222306.8502-1-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200615221607.7764-1-peterx@redhat.com> References: <20200615221607.7764-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the new mm_fault_accounting() helper for page fault accounting. Avoid doing page fault accounting multiple times if the page fault is retried. CC: Yoshinori Sato CC: Rich Felker CC: linux-sh@vger.kernel.org Signed-off-by: Peter Xu --- arch/sh/mm/fault.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c index 5f23d7907597..06b232973488 100644 --- a/arch/sh/mm/fault.c +++ b/arch/sh/mm/fault.c @@ -379,7 +379,7 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, struct task_struct *tsk; struct mm_struct *mm; struct vm_area_struct * vma; - vm_fault_t fault; + vm_fault_t fault, major = 0; unsigned int flags = FAULT_FLAG_DEFAULT; tsk = current; @@ -412,8 +412,6 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, if ((regs->sr & SR_IMASK) != SR_IMASK) local_irq_enable(); - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); - /* * If we're in an interrupt, have no user context or are running * with pagefaults disabled then we must not take the fault: @@ -465,21 +463,13 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, * the fault. */ fault = handle_mm_fault(vma, address, flags); + major |= fault & VM_FAULT_MAJOR; if (unlikely(fault & (VM_FAULT_RETRY | VM_FAULT_ERROR))) if (mm_fault_error(regs, error_code, address, fault)) return; if (flags & FAULT_FLAG_ALLOW_RETRY) { - if (fault & VM_FAULT_MAJOR) { - tsk->maj_flt++; - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, - regs, address); - } else { - tsk->min_flt++; - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, - regs, address); - } if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED; @@ -493,4 +483,5 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, } up_read(&mm->mmap_sem); + mm_fault_accounting(tsk, regs, address, major); } -- 2.26.2