Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2673268ybt; Tue, 16 Jun 2020 11:58:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQsA3NSQdIJMg0ZR/ze9pvcc/2DlG7uzRKu8q7kGSxF/Qr/PFcaEOq+/jc+2GC9lP9cgAq X-Received: by 2002:a17:906:7f05:: with SMTP id d5mr4052338ejr.70.1592333883497; Tue, 16 Jun 2020 11:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592333883; cv=none; d=google.com; s=arc-20160816; b=IPi6OJZyrVFeBYMSch8TkQ3uEtESFUCaegbIlCe1VQn74JPncOryM01NSnxLONltmH xRK3d7BGp7iM0s0TfbFOo1HipaJIuUzIcLGACW0VpA323DfD2H2/jQ6Ne9eSpcpw9oLp V60/PSVJvZ5+rxU0XbFE86AqGlCP0gDMe1KC8kCNkxIkHJNowYDMFr2edBY+jpPrF9YV 8gI1vxSF9LXe/khrqx5+lnRQxoXA2ljTDqVKaIjR8bDdr+St5Ygxap6kP4pAdKC+cnVt pHVHis3hLYnqPGF7SF0mTlu6L2Vcadtg+sWxPIv6yipX9IWXaCMGnQsS3jURUr+63lgO 5rYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Q0q8gubf8krgZV8oGCJJ77Manwa2gcrwHgDVVcoIMF4=; b=Ggjp9W3at09fVPHIiRTwmqgqOaj4d55m25LaMIT3IE0Mz2dHHSI00jTtoW7AYLiCRi kiA7EcqAzQ0LvTYTpAeqVCawYj8cqsJwlvZ+oAoSZk7CA5CW7uxAJfsUSX6FteQb7Gvs 2hMbYVp3JyMCb9D+AGKB+yy7hq4dfpiFLr5uJZSG6r/KQoYb04pCAPBZKDBCT3QUUakD swNH2/RGBAYg8x1391qN1jHvrYd8buvVH00Tfhjd2A2WiXT88Kvd2OYJj85oSFyMucyX ifgpsHcU5bWLWXPTZE5jxe/8/G6qzNlSL5IsVv24bWF+c8P8VrLqHg3AicbiZj45xxjI mVGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Za9iu2cs; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s3si10782268ejq.532.2020.06.16.11.57.40; Tue, 16 Jun 2020 11:58:03 -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=@linux-foundation.org header.s=google header.b=Za9iu2cs; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730080AbgFPSzi (ORCPT + 99 others); Tue, 16 Jun 2020 14:55:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbgFPSzh (ORCPT ); Tue, 16 Jun 2020 14:55:37 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81C6EC061573 for ; Tue, 16 Jun 2020 11:55:37 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id d7so12392314lfi.12 for ; Tue, 16 Jun 2020 11:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q0q8gubf8krgZV8oGCJJ77Manwa2gcrwHgDVVcoIMF4=; b=Za9iu2csZgttP35aE+aT08tNb3V6uxoyuIhn76uFapZGtiQBoNJQlm46x1X88modKX 56L73dqUCWnkD91z+9cqMwv5Y5xo/wgnVPwKoQqgiOz23E0vmPXaA37iu5082TSSxz11 OBgSNYHUnDL9NHnY2O/1eCVT5xkEIS6vHlrTo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q0q8gubf8krgZV8oGCJJ77Manwa2gcrwHgDVVcoIMF4=; b=k4m0tQ++FHNaVWGwgQ7w2Ddf08HF9Mt6IBH9QfquH/2r5jJyj3sYQiXSxbelrgTOb+ Z1nV1n5YwWtZTnCfhMcGYBWeTTSUwkhuJjZSKNEw4dtSGX7LuDKwqPJA+XUwSQImbi7B hSH8stHRO3eta4FoaL9ozQFAVHBq/N0J2Nl4fuT9L6xnyYhsi/r1QLto/sqUxfvfuxEC LthZsbhIBwa/i2+4UfnhuMa+3Tgh/bMT9MUiDun22rSN/lf0xuxlt5XneI3+YLvhFwzj mdOApobLlcR4hYQPOZ46sEYrlhr8lnK8kDzkYKbDnPB1ZZdPvJS1pPzd98ZQqp6S7kBF /JAQ== X-Gm-Message-State: AOAM533xNamfCVwiwjWN0eUSnm2/DTKfwxyfCvSYlIwYzGZmGG5M7qmc CYHj6gosi550ZtEk5u0om0weRxabTdw= X-Received: by 2002:ac2:48a6:: with SMTP id u6mr2404776lfg.49.1592333735576; Tue, 16 Jun 2020 11:55:35 -0700 (PDT) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com. [209.85.208.180]) by smtp.gmail.com with ESMTPSA id y3sm4547970ljk.39.2020.06.16.11.55.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jun 2020 11:55:34 -0700 (PDT) Received: by mail-lj1-f180.google.com with SMTP id q19so24896772lji.2 for ; Tue, 16 Jun 2020 11:55:34 -0700 (PDT) X-Received: by 2002:a2e:97c3:: with SMTP id m3mr2263094ljj.312.1592333733916; Tue, 16 Jun 2020 11:55:33 -0700 (PDT) MIME-Version: 1.0 References: <20200615221607.7764-1-peterx@redhat.com> In-Reply-To: <20200615221607.7764-1-peterx@redhat.com> From: Linus Torvalds Date: Tue, 16 Jun 2020 11:55:17 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 00/25] mm: Page fault accounting cleanups To: Peter Xu Cc: Linux Kernel Mailing List , Gerald Schaefer , Andrew Morton , Andrea Arcangeli , openrisc@lists.librecores.org, linux-arch , Alexander Gordeev , linux-s390 , Will Deacon , Catalin Marinas , Linux ARM Content-Type: multipart/mixed; boundary="00000000000093703c05a8381612" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --00000000000093703c05a8381612 Content-Type: text/plain; charset="UTF-8" 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_. Here's a straw-man patch to the generic code - the idea is mostly laid out in the comment that I'm just quoting here directly too: /* * Do accounting in the common code, to avoid unnecessary * architecture differences or duplicated code. * * We arbitrarily make the rules be: * * - faults that never even got here (because the address * wasn't valid). That includes arch_vma_access_permitted() * failing above. * * So this is expressly not a "this many hardware page * faults" counter. Use the hw profiling for that. * * - incomplete faults (ie RETRY) do not count (see above). * They will only count once completed. * * - the fault counts as a "major" fault when the final * successful fault is VM_FAULT_MAJOR, or if it was a * retry (which implies that we couldn't handle it * immediately previously). * * - if the fault is done for GUP, regs wil be NULL and * no accounting will be done (but you _could_ pass in * your own regs and it would be accounted to the thread * doing the fault, not to the target!) */ the code itself in the patch is (a) pretty trivial and self-evident (b) INCOMPLETE that (b) is worth noting: this patch won't compile on its own. It intentionally leaves all the users without the new 'regs' argument, because you obviously simply need to remove all the code that currently tries to do any accounting. Comments? This is a bigger change, but I think it might be worth it to _really_ consolidate the major/minor logic. 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. I'm not convinced it's useful to have three SW events that are defined to be A=B+C. But this does *not* do that part. It' sreally just an RFC patch. Linus --00000000000093703c05a8381612 Content-Type: application/octet-stream; name=patch Content-Disposition: attachment; filename=patch Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kbiacfcm0 IGluY2x1ZGUvbGludXgvbW0uaCB8ICAzICsrLQogbW0vbWVtb3J5LmMgICAgICAgIHwgNDYgKysr KysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrLQogMiBmaWxlcyBjaGFu Z2VkLCA0NyBpbnNlcnRpb25zKCspLCAyIGRlbGV0aW9ucygtKQoKZGlmZiAtLWdpdCBhL2luY2x1 ZGUvbGludXgvbW0uaCBiL2luY2x1ZGUvbGludXgvbW0uaAppbmRleCBkYzdiODczMTBjMTAuLmU4 MmE2MDQzMzljMCAxMDA2NDQKLS0tIGEvaW5jbHVkZS9saW51eC9tbS5oCisrKyBiL2luY2x1ZGUv bGludXgvbW0uaApAQCAtMTY0OCw3ICsxNjQ4LDggQEAgaW50IGludmFsaWRhdGVfaW5vZGVfcGFn ZShzdHJ1Y3QgcGFnZSAqcGFnZSk7CiAKICNpZmRlZiBDT05GSUdfTU1VCiBleHRlcm4gdm1fZmF1 bHRfdCBoYW5kbGVfbW1fZmF1bHQoc3RydWN0IHZtX2FyZWFfc3RydWN0ICp2bWEsCi0JCQl1bnNp Z25lZCBsb25nIGFkZHJlc3MsIHVuc2lnbmVkIGludCBmbGFncyk7CisJCQl1bnNp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