Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp305095ybt; Wed, 17 Jun 2020 01:08:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziZvKbbBKzvz0EVEtYJwzSmf0rDNM/4M3nRuBDw0b3BlT8iv5jj5VcP3XWj0Q/ZYr3aDpJ X-Received: by 2002:a17:906:2b92:: with SMTP id m18mr6974486ejg.218.1592381301656; Wed, 17 Jun 2020 01:08:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592381301; cv=none; d=google.com; s=arc-20160816; b=ID27du8h/WoxLDbRZsnEc5EKHqj3UKvKUTQ+JYc5H0qUW5DVz8dB3usCDz/nYSrzU0 oLlX2Rv2/3elDqI01R0PQ3FHWbiIn/zOVjt4cao05hrliocEIIgTcU0br+el/4AGYD7E qVRQKGBXuHqT4VtHc5/u5xyw9oWZXJpD14ScFHn/0ri4Os+P6a/TCJMM3Dwij7JCYAwf vmaOK/rnlKoLofED4ZQCIEmDD7p4igIeaeQzXmOYaeIgw3axZfVuKB6BzrAAkrV7YZMN McTPnMExFfr/tTtHiz9IPcLnhMLcykvKelYtqo2VyGw62sEJX8lG/bG/G9VnHZ/MVZVb PU/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ZtEHdizxwr7ZJl4uGYGdpn2jIEtreFfrznHPrwNCZBg=; b=oQHIsn5+MLxy+VnJKRbycACZwP+aEfIB4xIFvywolXnUS/K2lElJ8kNnlUgFsB0QXR DlNFuq8eX6zWbsZOpBeY2KZiUr3Q2es3iQg5lL7OzdNTBOgleoMZGLgcfLDffsEhHEZP rbrRaOuYTJhJFNSucTSdZfIy55Dk9/+zyoGksnT2L8S4m3DPumg5gzeehEVI6PU7y5uj 552GFSYe9+lunCQarRVx3EdR180SSGNJFtkvgnUCZ3lIkqfSyduTDtP/RVAz5cSuFsHk UB2u2AhSIOUHauw/WqGx4LySi6PnBruh4ecC7YdeTnZmJVorknDviaW3pq7onkDX6hqs 4xZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JTiufBj0; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si15506572ejo.473.2020.06.17.01.07.59; Wed, 17 Jun 2020 01:08:21 -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=@kernel.org header.s=default header.b=JTiufBj0; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726355AbgFQIEM (ORCPT + 99 others); Wed, 17 Jun 2020 04:04:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:39364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbgFQIEM (ORCPT ); Wed, 17 Jun 2020 04:04:12 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 91CE021475; Wed, 17 Jun 2020 08:04:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592381051; bh=MjCLvKpmywtlENNu3L8WcjVAZUYXfsV93TDu3ReXKuQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JTiufBj0BMszSpkVUzi+gNk/qprMzw2wYVoJRieWtNmkrCUlTJiL+eUPkxjEPJZ7D Pl+CdboZUILER+bWki4NgM0L7KE262coRqRGnhsGEroSN9Uf1CdlIdoIHJwTchzbUV 5UjKXESI9ZrCTGdCfmJKt9pER0l8tsQDgS//NF2k= Date: Wed, 17 Jun 2020 09:04:06 +0100 From: Will Deacon To: Michael Ellerman Cc: Linus Torvalds , Peter Xu , Linux Kernel Mailing List , Gerald Schaefer , Andrew Morton , Andrea Arcangeli , openrisc@lists.librecores.org, linux-arch , Alexander Gordeev , linux-s390 , Catalin Marinas , Linux ARM Subject: Re: [PATCH 00/25] mm: Page fault accounting cleanups Message-ID: <20200617080405.GA3208@willie-the-truck> References: <20200615221607.7764-1-peterx@redhat.com> <87imfqecjx.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87imfqecjx.fsf@mpe.ellerman.id.au> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 17, 2020 at 10:55:14AM +1000, Michael Ellerman wrote: > Linus Torvalds writes: > > On Mon, Jun 15, 2020 at 3:16 PM Peter Xu wrote: > >> This series tries to address all of them by introducing mm_fault_accounting() > >> first, so that we move all the page fault accounting into the common code base, > >> then call it properly from arch pf handlers just like handle_mm_fault(). > > > > Hmm. > > > > So having looked at this a bit more, I'd actually like to go even > > further, and just get rid of the per-architecture code _entirely_. > > > > > One detail worth noting: I do wonder if we should put the > > > > perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr); > > > > just in the arch code at the top of the fault handling, and consider > > it entirely unrelated to the major/minor fault handling. The > > major/minor faults fundamnetally are about successes. But the plain > > PERF_COUNT_SW_PAGE_FAULTS could be about things that fail, including > > things that never even get to this point at all. > > Yeah I think we should keep it in the arch code at roughly the top. I agree. It's a nice idea to consolidate the code, but I don't see that it's really possible for PERF_COUNT_SW_PAGE_FAULTS without significantly changing the semantics (and a potentially less useful way. Of course, moving more of do_page_fault() out of the arch code would be great, but that's a much bigger effort. > If it's moved to the end you could have a process spinning taking bad > page faults (and fixing them up), and see no sign of it from the perf > page fault counters. The current arm64 behaviour is that we record PERF_COUNT_SW_PAGE_FAULTS if _all_ of the following are true: 1. The fault isn't handled by kprobes 2. The pagefault handler is enabled 3. We have an mm (current->mm) 4. The fault isn't an unexpected kernel fault on a user address (we oops and kill the task in this case) Which loosely corresponds to "we took a fault on a user address that it looks like we can handle". That said, I'm happy to tweak this if it brings us into line with other architectures. Will