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=-4.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no 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 39B7FC433E0 for ; Tue, 30 Jun 2020 20:45:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DC89C206B6 for ; Tue, 30 Jun 2020 20:45:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="V1DvkoND" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC89C206B6 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 4E4176B0006; Tue, 30 Jun 2020 16:45:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4950E6B0008; Tue, 30 Jun 2020 16:45:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35D466B000C; Tue, 30 Jun 2020 16:45:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id 1F89A6B0006 for ; Tue, 30 Jun 2020 16:45:09 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 97F49181AC9CC for ; Tue, 30 Jun 2020 20:45:08 +0000 (UTC) X-FDA: 76987057896.11.rain49_380001026e7a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 70C12180F8B81 for ; Tue, 30 Jun 2020 20:45:08 +0000 (UTC) X-HE-Tag: rain49_380001026e7a X-Filterd-Recvd-Size: 11351 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Tue, 30 Jun 2020 20:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593549907; 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; bh=+DHpxXRld1JWheLF0+9iYU4JraLCRfcW4tJHBkCauUA=; b=V1DvkoNDfkoc6pzv04AYFkmUFDejNdk9veEu6SeSIpe0T5VTk58NvirMEZaNVZj9egip0r JgJONsgRricGwmxhiucbH+qUNFjh6x8iS8GeZfCgQcmuBkUEOuO/6afvlDN6sy2QHENhf0 9sQB5PAqNzwixZVOUF62wxAZzSgXj0I= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-40-H0Jr0uwSOH6uXJbiQ3ecOw-1; Tue, 30 Jun 2020 16:45:05 -0400 X-MC-Unique: H0Jr0uwSOH6uXJbiQ3ecOw-1 Received: by mail-qv1-f71.google.com with SMTP id g17so12884647qvw.0 for ; Tue, 30 Jun 2020 13:45:05 -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:mime-version :content-transfer-encoding; bh=XecCxqNuikt/ufBD1g6ZnLJJZQJ5oET93VAWNtvus80=; b=Kf8cGrpVuq8JXRvPlp1dbdSfbjfU3kk3xI7P+daciu2v2pBEGjcDmMPT8lbkKl6kix ArrkPVW0aEaxKmHSxKkTDAtWfUvNa/NC9akh9sv2WNE9m0zzqO3iAcc8A1rtB0djs5xm p1zfzQ7Hb0/gc4CRmL8e8f7jrtUz0m2RT/YaZ/406KM92G4PDxUy4z81Pwt8lJkYExUG J//LbaGNt4AgmtTc6xC1/c6hPtuBAZLYamU+YCQx+AUDmXUyueRmC9h8I/W4+60CdjZ4 D69/xpskuLw0FAo8qGsWyaNZj2NLOE2t1DDrIQB0Gf2lCMmvVbflNF7nzf5sDENPS4np o6dg== X-Gm-Message-State: AOAM533gzIQjP+f9Bgv0fF5bQ2gcRTtBQCEWn+3I+Xx8DrCXyw/D561Q gNcEdACU343GkUQTaxF1MNXOTE/t9YETRNsrM1zcVQ1fUrKBMhbhYomEMtT5TtnhN+oeiIqkiW+ 6uPmAv9YyZz8= X-Received: by 2002:ac8:4f13:: with SMTP id b19mr12344909qte.146.1593549903930; Tue, 30 Jun 2020 13:45:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnjeNgGb3VgyiWRazZJnXpk1WXkLvNRxZ6+DixPQ/oofTuS8GpnF0F4qDUmW3N1xOBIVbE8A== X-Received: by 2002:ac8:4f13:: with SMTP id b19mr12344886qte.146.1593549903608; Tue, 30 Jun 2020 13:45:03 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id p63sm4105395qkc.80.2020.06.30.13.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 13:45:02 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , peterx@redhat.com, John Hubbard , Michael Ellerman , Gerald Schaefer , Andrea Arcangeli , Linus Torvalds , Will Deacon Subject: [PATCH v4 00/26] mm: Page fault accounting cleanups Date: Tue, 30 Jun 2020 16:45:01 -0400 Message-Id: <20200630204501.38468-1-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 70C12180F8B81 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: v4:=0D - rebase to linux-next/akpm=0D - picked one more r-b=0D =0D v3:=0D - comment fixes [Gerald]=0D - check VM_FAULT_ERROR too [Gerald]=0D - collect r-b=0D =0D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D cover letter f= or v2 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=0D =0D This is v2 of the pf accounting cleanup series. It originates from Gerald= =0D Schaefer's report on an issue a week ago regarding to incorrect page fault= =0D accountings for retried page fault after commit 4064b9827063 ("mm: allow=0D VM_FAULT_RETRY for multiple times"):=0D =0D https://lore.kernel.org/lkml/20200610174811.44b94525@thinkpad/=0D =0D This version used a better approach suggested by Linus so that we do accoun= ting=0D directly in handle_mm_fault(). Moreover, we'll cover some special accounti= ng=0D too like gup or IOMMU fault requests on process page tables. The outcome o= f=0D this series is to keep all the pf accountings in handle_mm_fault() (besides= =0D PERF_COUNT_SW_PAGE_FAULTS, which is still done in per-arch #pf handlers).= =0D =0D Since v2 changed quite a lot from v1, changelog is omitted, and I also didn= 't=0D have a chance to pick up any r-b in previous version. I really appreciate= =0D anyone who has looked at v1. V1 for reference:=0D =0D https://lore.kernel.org/lkml/20200615221607.7764-1-peterx@redhat.com/=0D =0D What this series did:=0D =0D - Correct page fault accounting: we do accounting for a page fault (no ma= tter=0D whether it's from #PF handling, or gup, or anything else) only with the= one=0D that completed the fault. For example, page fault retries should not b= e=0D counted in page fault counters. Same to the perf events.=0D =0D - Unify definition of PERF_COUNT_SW_PAGE_FAULTS: currently this perf even= t is=0D used in an adhoc way across different archs.=0D =0D Case (1): for many archs it's done at the entry of a page fault handler= , so=0D that it will also cover e.g. errornous faults.=0D =0D Case (2): for some other archs, it is only accounted when the page faul= t is=0D resolved successfully.=0D =0D Case (3): there're still quite some archs that have not enabled this pe= rf event.=0D =0D Since this series will touch merely all the archs, we unify this perf e= vent=0D to always follow case (1), which is the one that makes most sense. And= =0D since we moved the accounting into handle_mm_fault, the other two MAJ/M= IN=0D perf events are well taken care of naturally.=0D =0D - Unify definition of "major faults": the definition of "major fault" is= =0D slightly changed when used in accounting (not VM_FAULT_MAJOR). More=0D information in patch 1.=0D =0D - Always account the page fault onto the one that triggered the page faul= t.=0D This does not matter much for #PF handlings, but mostly for gup. More= =0D information on this in patch 25.=0D =0D Patchset layout:=0D =0D Patch 1: Introduced the accounting in handle_mm_fault(), not enabled.= =0D Patch 2-24: Enable the new accounting for arch #PF handlers one by one.=0D Patch 25: Enable the new accounting for the rest outliers (gup, iommu, e= tc.)=0D Patch 26: Cleanup GUP task_struct pointer since it's not needed any more= =0D =0D For each of the patch that fixes a specific arch, I'm CCing the maintainers= and=0D the arch list if there is. Besides, I only lightly tested this series on x= 86.=0D =0D Please have a look, thanks.=0D =0D Peter Xu (26):=0D mm: Do page fault accounting in handle_mm_fault=0D mm/alpha: Use general page fault accounting=0D mm/arc: Use general page fault accounting=0D mm/arm: Use general page fault accounting=0D mm/arm64: Use general page fault accounting=0D mm/csky: Use general page fault accounting=0D mm/hexagon: Use general page fault accounting=0D mm/ia64: Use general page fault accounting=0D mm/m68k: Use general page fault accounting=0D mm/microblaze: Use general page fault accounting=0D mm/mips: Use general page fault accounting=0D mm/nds32: Use general page fault accounting=0D mm/nios2: Use general page fault accounting=0D mm/openrisc: Use general page fault accounting=0D mm/parisc: Use general page fault accounting=0D mm/powerpc: Use general page fault accounting=0D mm/riscv: Use general page fault accounting=0D mm/s390: Use general page fault accounting=0D mm/sh: Use general page fault accounting=0D mm/sparc32: Use general page fault accounting=0D mm/sparc64: Use general page fault accounting=0D mm/unicore32: Use general page fault accounting=0D mm/x86: Use general page fault accounting=0D mm/xtensa: Use general page fault accounting=0D mm: Clean up the last pieces of page fault accountings=0D mm/gup: Remove task_struct pointer for all gup code=0D =0D arch/alpha/mm/fault.c | 8 +-=0D arch/arc/kernel/process.c | 2 +-=0D arch/arc/mm/fault.c | 18 +---=0D arch/arm/mm/fault.c | 25 ++---=0D arch/arm64/mm/fault.c | 29 ++----=0D arch/csky/mm/fault.c | 13 +--=0D arch/hexagon/mm/vm_fault.c | 9 +-=0D arch/ia64/mm/fault.c | 9 +-=0D arch/m68k/mm/fault.c | 14 +--=0D arch/microblaze/mm/fault.c | 9 +-=0D arch/mips/mm/fault.c | 14 +--=0D arch/nds32/mm/fault.c | 19 +---=0D arch/nios2/mm/fault.c | 14 +--=0D arch/openrisc/mm/fault.c | 9 +-=0D arch/parisc/mm/fault.c | 8 +-=0D arch/powerpc/mm/copro_fault.c | 7 +-=0D arch/powerpc/mm/fault.c | 11 +-=0D arch/riscv/mm/fault.c | 16 +--=0D arch/s390/kvm/interrupt.c | 2 +-=0D arch/s390/kvm/kvm-s390.c | 2 +-=0D arch/s390/kvm/priv.c | 8 +-=0D arch/s390/mm/fault.c | 16 +--=0D arch/s390/mm/gmap.c | 4 +-=0D arch/sh/mm/fault.c | 11 +-=0D arch/sparc/mm/fault_32.c | 13 +--=0D arch/sparc/mm/fault_64.c | 11 +-=0D arch/um/kernel/trap.c | 6 +-=0D arch/unicore32/mm/fault.c | 14 +--=0D arch/x86/mm/fault.c | 17 +--=0D arch/xtensa/mm/fault.c | 15 +--=0D drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 2 +-=0D drivers/infiniband/core/umem_odp.c | 2 +-=0D drivers/iommu/amd/iommu_v2.c | 2 +-=0D drivers/iommu/intel/svm.c | 3 +-=0D drivers/vfio/vfio_iommu_type1.c | 4 +-=0D fs/exec.c | 2 +-=0D include/linux/mm.h | 16 +--=0D kernel/events/uprobes.c | 6 +-=0D kernel/futex.c | 2 +-=0D mm/gup.c | 109 +++++++-------------=0D mm/hmm.c | 3 +-=0D mm/ksm.c | 3 +-=0D mm/memory.c | 69 ++++++++++++-=0D mm/process_vm_access.c | 2 +-=0D security/tomoyo/domain.c | 2 +-=0D virt/kvm/async_pf.c | 2 +-=0D virt/kvm/kvm_main.c | 2 +-=0D 47 files changed, 222 insertions(+), 362 deletions(-)=0D =0D --=20=0D 2.26.2=0D =0D