Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753128AbaAPB3R (ORCPT ); Wed, 15 Jan 2014 20:29:17 -0500 Received: from mga02.intel.com ([134.134.136.20]:49058 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752556AbaAPBZK (ORCPT ); Wed, 15 Jan 2014 20:25:10 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,666,1384329600"; d="scan'208";a="439548597" From: Matthew Wilcox To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-ext4@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH v5 21/22] xip: Add reporting of major faults Date: Wed, 15 Jan 2014 20:24:39 -0500 Message-Id: <256d3855b43f76f5f26bb65c816955978561ffe2.1389779962.git.matthew.r.wilcox@intel.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we have to call get_block with the create argument set to 1, then the filesystem almost certainly had to zero the block. which is an I/O, which should be reported as a major fault. Note that major faults on XIP files happen for different reasons than major faults on non-XIP files. XIP files behave as if everything except file holes is already cached. That's all the more reason to report major faults when we do have to do I/O; it may be a valuable resource for sysadmins trying to diagnose performance problems. Signed-off-by: Matthew Wilcox --- fs/xip.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/xip.c b/fs/xip.c index 9087e0f..88a516b 100644 --- a/fs/xip.c +++ b/fs/xip.c @@ -19,10 +19,12 @@ #include #include #include +#include #include #include #include #include +#include int xip_clear_blocks(struct inode *inode, sector_t block, long size) { @@ -250,6 +252,7 @@ static int do_xip_fault(struct vm_area_struct *vma, struct vm_fault *vmf, pgoff_t size; unsigned long pfn; int error; + int major = 0; size = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT; if (vmf->pgoff >= size) @@ -265,6 +268,9 @@ static int do_xip_fault(struct vm_area_struct *vma, struct vm_fault *vmf, if (!buffer_mapped(&bh) && !vmf->cow_page) { if (vmf->flags & FAULT_FLAG_WRITE) { error = get_block(inode, block, &bh, 1); + count_vm_event(PGMAJFAULT); + mem_cgroup_count_vm_event(vma->vm_mm, PGMAJFAULT); + major = VM_FAULT_MAJOR; if (error || bh.b_size < PAGE_SIZE) return VM_FAULT_SIGBUS; } else { @@ -296,7 +302,7 @@ static int do_xip_fault(struct vm_area_struct *vma, struct vm_fault *vmf, /* -EBUSY is fine, somebody else faulted on the same PTE */ if (error != -EBUSY) BUG_ON(error); - return VM_FAULT_NOPAGE; + return VM_FAULT_NOPAGE | major; } /** -- 1.8.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/