Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1999025ybt; Mon, 15 Jun 2020 15:22:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzY2jbj5SxmjrWHM5D4kOKDVpxehhd31Nm5qr0SBqkycJfjXEHt0aTlpFo88cGl3ib4gqd5 X-Received: by 2002:a17:906:cede:: with SMTP id si30mr28572812ejb.315.1592259757959; Mon, 15 Jun 2020 15:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592259757; cv=none; d=google.com; s=arc-20160816; b=R9xMiwV9pDM0zsAdxtk2/mWkzRfHvnREZVLYzrh/N75canJCFvO7frClHHPRzQQxc+ H7bn//Fng7rfl4MoJroxbhQDFWzsawKNemQBdHNj39JOOgEUNiCMkFQ8BHXGjkM5rRle YnyT2my1TJ6X92Hx/EoXhIR0xOW6uF9xsbKLDn76iRFIMgvrM+u5BKCXbi+0F8ZISNk1 oSRzI1h54jMLPNUsaUXIkrqsxCs/HKF9i86ZUPzdayxSNVT4E8OnMEIgboN9xGL4K4kQ 1Ui0WdvXKlT3Ncy1W07pq8LyMTkUIvkPtqQiI2uvxim8GOlAxTDlEGBIbZ3o99zfxs8u Z3RA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=qVFaTHERIS8zyGm9WNuNIMiOUtUSSq7Mw9RxxyBA+O0=; b=g0QLoDYGwaH8StcBSrNUXbYNNXVP36exGw4BNp+AL/edxYec7+mG8JayimlWPdR+sd C2X5wTGEYhnlF2vBW35f5XAhOLW3ra2S3r7oA4aKaR56Ens/+o5qjcKRhBXwANHFfZwf zyDfl9uGE9jYcD6/IQqpMffF8ig8e+KqiISxFYJEFnmiw7EioHmfmT4WYb57Bo0WURxq aq217uT6D2pDRLLO4n83/wglBrC87Edi/ghLc9ZPeulDBtWZBtBkaSH2iXI+gzLlLZtw MlbOhKMhhCzczj9K4kIQhN9Q6ddVeBpCR6Ur/0YIoM8sVz71i3whn/FURyCioGcxkIsU 8GFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R6YkbzpV; 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 oe24si10043494ejb.598.2020.06.15.15.22.15; Mon, 15 Jun 2020 15:22:37 -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=R6YkbzpV; 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 S1726473AbgFOWQP (ORCPT + 99 others); Mon, 15 Jun 2020 18:16:15 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:40140 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726314AbgFOWQO (ORCPT ); Mon, 15 Jun 2020 18:16:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592259372; 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; bh=qVFaTHERIS8zyGm9WNuNIMiOUtUSSq7Mw9RxxyBA+O0=; b=R6YkbzpVnj4TZo8sJPs9oao/BEOrrmoyGATHzMlipAUZCA5BaVEvdVQjDs9nDFnANpm8q1 naaO9Ry0ampPNEH2s/2uqaYSC98i6vZFioq7VJaMyD8PyeWcp+4gh04X2GEs/x+feLAGJK lBM1pwUJ6Sdi7blz8uxvetf9nRFnFBU= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-318-XN8iuLSWON6rgnEMWNZLiA-1; Mon, 15 Jun 2020 18:16:10 -0400 X-MC-Unique: XN8iuLSWON6rgnEMWNZLiA-1 Received: by mail-qt1-f199.google.com with SMTP id y7so15170273qti.8 for ; Mon, 15 Jun 2020 15:16:10 -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=qVFaTHERIS8zyGm9WNuNIMiOUtUSSq7Mw9RxxyBA+O0=; b=I5Z5d/rc4vBl1b37BjvU0Z1i0sXv0AFsmFvtk4ZnGEZo3c1ZT+E3446sk/ygywpsG3 C/YovhxQ11tixNwLZfsDwh+mAzwZbXGN8Zkzz0WjRnsfEheO0ze46hIBCFsAtwAIdpOt q08N/HJRqB5zOnE4N/fVSh8qF3EAAkmiPrXnLemAnwmE58giGzH8Uz/FmiDJMHpvFRrn cOLhB9LnsO4hjOoMQQE/jKB4zfOV9hUZrQTGa22sIjrVRaKOx9sl7Lkik3H8DjbuEf0o DGMd5qpkOCFRdtVOV+u7rRF1wXT1tT3YAnPZ2yz/vuR+/qtlz3s24FBRA531Yj2L54M/ t+qA== X-Gm-Message-State: AOAM531pjW4kHCgGLrJornIx7jglZl6etozdZUS+PzSPluls2fdxcB5x D9z97pOjs0hZyHiGYCnO84SpQQ0Tb6hO0sqKCEvGK2gNoHwxmd+XvGFfXoZmHmEiL8lAYtuwqro VJEyNgs1qaOraREJ8u+NtlV6k X-Received: by 2002:a37:d89:: with SMTP id 131mr18163757qkn.454.1592259369624; Mon, 15 Jun 2020 15:16:09 -0700 (PDT) X-Received: by 2002:a37:d89:: with SMTP id 131mr18163733qkn.454.1592259369320; Mon, 15 Jun 2020 15:16:09 -0700 (PDT) Received: from xz-x1.hitronhub.home ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id w13sm12351509qkb.91.2020.06.15.15.16.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 15:16:08 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org Cc: Gerald Schaefer , Andrew Morton , peterx@redhat.com, Linus Torvalds , Andrea Arcangeli Subject: [PATCH 00/25] mm: Page fault accounting cleanups Date: Mon, 15 Jun 2020 18:15:42 -0400 Message-Id: <20200615221607.7764-1-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 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 Gerald Schaefer reported an issue a week ago regarding to incorrect page fault accountings for retried page fault after commit 4064b9827063 ("mm: allow VM_FAULT_RETRY for multiple times"): https://lore.kernel.org/lkml/20200610174811.44b94525@thinkpad/ When I was looking at the issue, I actually found some other trivial issues too related to the page fault accounting, namely: - Incorrect accountings - The major issue that was reported by Gerald, that we did multiple accounting when the page fault retried while we should only do it once (for either perf event accounting or per-task accounting). - In many archs, major fault is only accounted when the 1st page fault is a major fault, or the last page fault is a major fault. Ideally we should account the page fault as a major fault as long as any of the page fault retries is a major fault and keep the same behavior across archs. - Missing accountings of perf events (PERF_COUNT_SW_PAGE_FAULTS[_[MAJ|MIN]]). - Doing accounting with mmap_sem: not a big deal, but logically we can move it after releasing the mmap_sem because accounting does not need it. 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(). There are some special cases, e.g., the um arch does not have "regs" in the fault handler, so it's still using the manual statistics. For each of the patch that fixes a specific arch, I'm CCing the maintainers and the arch list if there is. Besides, I only lightly tested this series on x86. Please have a look, thanks. Peter Xu (25): mm/um: Fix extra accounting for page fault retries mm: Introduce mm_fault_accounting() mm/alpha: Use mm_fault_accounting() mm/arc: Use mm_fault_accounting() mm/arm: Use mm_fault_accounting() mm/arm64: Use mm_fault_accounting() mm/csky: Use mm_fault_accounting() mm/hexagon: Use mm_fault_accounting() mm/ia64: Use mm_fault_accounting() mm/m68k: Use mm_fault_accounting() mm/microblaze: Use mm_fault_accounting() mm/mips: Use mm_fault_accounting() mm/nds32: Use mm_fault_accounting() mm/nios2: Use mm_fault_accounting() mm/openrisc: Use mm_fault_accounting() mm/parisc: Use mm_fault_accounting() mm/powerpc: Use mm_fault_accounting() mm/riscv: Use mm_fault_accounting() mm/s390: Use mm_fault_accounting() mm/sh: Use mm_fault_accounting() mm/sparc32: Use mm_fault_accounting() mm/sparc64: Use mm_fault_accounting() mm/unicore32: Use mm_fault_accounting() mm/x86: Use mm_fault_accounting() mm/xtensa: Use mm_fault_accounting() arch/alpha/mm/fault.c | 9 ++++----- arch/arc/mm/fault.c | 15 +++------------ arch/arm/mm/fault.c | 21 ++++----------------- arch/arm64/mm/fault.c | 17 ++--------------- arch/csky/mm/fault.c | 13 +------------ arch/hexagon/mm/vm_fault.c | 9 +++------ arch/ia64/mm/fault.c | 8 +++----- arch/m68k/mm/fault.c | 13 +++---------- arch/microblaze/mm/fault.c | 8 +++----- arch/mips/mm/fault.c | 14 +++----------- arch/nds32/mm/fault.c | 19 +++---------------- arch/nios2/mm/fault.c | 13 +++---------- arch/openrisc/mm/fault.c | 8 +++----- arch/parisc/mm/fault.c | 8 +++----- arch/powerpc/mm/fault.c | 13 ++++--------- arch/riscv/mm/fault.c | 21 +++------------------ arch/s390/mm/fault.c | 21 +++++---------------- arch/sh/mm/fault.c | 15 +++------------ arch/sparc/mm/fault_32.c | 16 +++------------- arch/sparc/mm/fault_64.c | 16 ++++------------ arch/um/kernel/trap.c | 13 +++++++------ arch/unicore32/mm/fault.c | 15 +++++++-------- arch/x86/mm/fault.c | 10 +--------- arch/xtensa/mm/fault.c | 14 +++----------- include/linux/mm.h | 2 ++ mm/memory.c | 18 ++++++++++++++++++ 26 files changed, 101 insertions(+), 248 deletions(-) -- 2.26.2