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=-3.9 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 CC157C433E0 for ; Tue, 7 Jul 2020 22:50:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 62A8820738 for ; Tue, 7 Jul 2020 22:50:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="c/0EVr3/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62A8820738 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 915476B00A2; Tue, 7 Jul 2020 18:50:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86AA46B009A; Tue, 7 Jul 2020 18:50:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72E476B00A2; Tue, 7 Jul 2020 18:50:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 571876B009A for ; Tue, 7 Jul 2020 18:50:31 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id F0407181AEF09 for ; Tue, 7 Jul 2020 22:50:30 +0000 (UTC) X-FDA: 77012775420.10.park65_5c00a3526eb8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id C999816A046 for ; Tue, 7 Jul 2020 22:50:30 +0000 (UTC) X-HE-Tag: park65_5c00a3526eb8 X-Filterd-Recvd-Size: 10476 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 22:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594162229; 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=56qt9oPBpqL9LiN1Hr4iQZWaJfP2z/YOBP/75zi70rY=; b=c/0EVr3/DteNJdNsqj50QV1AQl9YPEaouZmpcWeupMHx0LRM7di+TODMAKbmWd5lYB1twy 5XBzFshSbjS0fUNNPiwN2gOrTIWGOb0c6YtmPjlBR5hZktaYZD/At0krQZgqA++dap2MYL 8j94ytfaPTMTZI63+KQqyPKixYaE8e0= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-316-OSnocxOdMIS78iyWwN3wYA-1; Tue, 07 Jul 2020 18:50:25 -0400 X-MC-Unique: OSnocxOdMIS78iyWwN3wYA-1 Received: by mail-qt1-f197.google.com with SMTP id t36so13852246qtc.16 for ; Tue, 07 Jul 2020 15:50:25 -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=XG8JZ/RcRcZU8pPzQBjdYxuL7JMX3O7leErJJK2lhj0=; b=SXX/k4bQt0REVBHCIwD3M1Z+Fu9LpYyz9JAygp8cR40TtQ4ZDLptmCU6zHsKQ8Nnqb MdU3P8ErW0spgt7tS0cP/Wyafl288UESC2K5WwDx/n04myp/vHqIVwFNUr5b3BlPXH0g CbNFMq4LYWzumjugRkebveFU1ck953Y+JUzTuLpElv6+3c/SaYeCsIBtiCSc7RZO35wy bZkEl4lunsgPX7Kv73qquNOdl/eWNgLxaaSPo1tN62CV2RiR/aEfqELbJybGWnw3txve +/d0RTGyB8FUeCnMHAKc89gzUU3Hrqov1PHUA6gUUTfxOXW/UxA4L/FIdMWMoBAi+dTw BBXw== X-Gm-Message-State: AOAM530G3w5slnlLZh6RTtQ50eQooHT03X6H2oC40Y/H/5AyjfSN1ILU G1MdsyALrZJSYBCaaD4N6VRiPqU8zzB6+RyJHTxT40gTRyVvfKW9h50xQoEhza8tvy/rm6Vg3bi oxAhGZtzXjaU= X-Received: by 2002:a05:620a:b1a:: with SMTP id t26mr55131581qkg.473.1594162224769; Tue, 07 Jul 2020 15:50:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgOu7xvthwEx0G099Jt4vnoO0GKQxi2Pl8cOAO4vYSFWN34rylzrPPHMzPoI3RRpnIY1w+pQ== X-Received: by 2002:a05:620a:b1a:: with SMTP id t26mr55131552qkg.473.1594162224414; Tue, 07 Jul 2020 15:50:24 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id j16sm26267642qtp.92.2020.07.07.15.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 15:50:23 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Gerald Schaefer , Linus Torvalds , peterx@redhat.com, Andrew Morton , Will Deacon , Andrea Arcangeli , David Rientjes , John Hubbard , Michael Ellerman Subject: [PATCH v5 00/25] mm: Page fault accounting cleanups Date: Tue, 7 Jul 2020 18:49:56 -0400 Message-Id: <20200707225021.200906-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: C999816A046 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: v5:=0D - rebase to linux-next/akpm, add r-bs=0D - patch 1: pass vm_fault_t into mm_account_fault() [DavidR]=0D - patch 25: fix comment in get_user_pages() to remove the ref to task [John= ]=0D - dropped the unicore32 patch because the arch was thrown away=0D =0D This is v5 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 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-23: Enable the new accounting for arch #PF handlers one by one.=0D Patch 24: Enable the new accounting for the rest outliers (gup, iommu, e= tc.)=0D Patch 25: 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 (25):=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/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/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 | 118 ++++++++------------=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 46 files changed, 219 insertions(+), 360 deletions(-)=0D =0D --=20=0D 2.26.2=0D =0D