All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shailabh Nagar <nagar@watson.ibm.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [Patch 3/4] Delay accounting: Page fault delays
Date: Mon, 14 Nov 2005 23:35:50 -0500	[thread overview]
Message-ID: <437965A6.6080607@watson.ibm.com> (raw)

delayacct-pgflt.patch

Record time spent by a task waiting for page fault completion.

Signed-off-by: Shailabh Nagar <nagar@watson.ibm.com>

 include/linux/delayacct.h |   20 ++++++++++++++++++++
 include/linux/sched.h     |    2 ++
 mm/memory.c               |   17 ++++++++++++++---
 3 files changed, 36 insertions(+), 3 deletions(-)

Index: linux-2.6.14/include/linux/delayacct.h
===================================================================
--- linux-2.6.14.orig/include/linux/delayacct.h
+++ linux-2.6.14/include/linux/delayacct.h
@@ -56,6 +56,24 @@ static inline void delayacct_blkio(unsig
 	spin_unlock(&current->delays.lock);
 }

+static inline void delayacct_pgflt(unsigned long long ts)
+{
+	unsigned long long now = sched_clock();
+
+	if (!test_ts_integrity(ts, now))
+		return;
+
+	/* Lock and pgflt_count may be unnecessary.
+	 * pgflt_count is equivalent to current->min_flt+current->maj_flt
+	 * but if the sum cannot be safely taken when current->delays is read
+	 * the lock and redundant addition may still be needed.
+	 */
+	spin_lock(&current->delays.lock);
+	current->delays.pgflt_delay += now - ts;
+	current->delays.pgflt_count++;
+	spin_unlock(&current->delays.lock);
+}
+
 #else

 static inline void delayacct_init(struct task_struct *tsk)
@@ -65,6 +83,8 @@ static inline void delayacct_timestamp(u
 {}
 static inline void delayacct_blkio(unsigned long long ts)
 {}
+static inline void delayacct_pgflt(unsigned long long ts)
+{}
 #endif /* CONFIG_DELAY_ACCT */


Index: linux-2.6.14/include/linux/sched.h
===================================================================
--- linux-2.6.14.orig/include/linux/sched.h
+++ linux-2.6.14/include/linux/sched.h
@@ -504,6 +504,8 @@ struct task_delay_info {
 	/* Add stats in pairs: uint64_t delay, uint32_t count */
 	uint64_t blkio_delay;	/* wait for block io completion */
 	uint32_t blkio_count;
+	uint64_t pgflt_delay;	/* wait for page fault completion */
+	uint32_t pgflt_count;
 };
 #endif

Index: linux-2.6.14/mm/memory.c
===================================================================
--- linux-2.6.14.orig/mm/memory.c
+++ linux-2.6.14/mm/memory.c
@@ -48,6 +48,8 @@
 #include <linux/rmap.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/delayacct.h>

 #include <asm/pgalloc.h>
 #include <asm/uaccess.h>
@@ -2040,13 +2042,19 @@ int __handle_mm_fault(struct mm_struct *
 	pud_t *pud;
 	pmd_t *pmd;
 	pte_t *pte;
+	int rc;
+	delayacct_def_var(ts);

+	delayacct_timestamp(&ts);
 	__set_current_state(TASK_RUNNING);

 	inc_page_state(pgfault);

-	if (unlikely(is_vm_hugetlb_page(vma)))
-		return hugetlb_fault(mm, vma, address, write_access);
+	if (unlikely(is_vm_hugetlb_page(vma))) {
+		rc = hugetlb_fault(mm, vma, address, write_access);
+		delayacct_pgflt(ts);
+		return rc;
+	}

 	/*
 	 * We need the page table lock to synchronize with kswapd
@@ -2067,10 +2075,13 @@ int __handle_mm_fault(struct mm_struct *
 	if (!pte)
 		goto oom;
 	
-	return handle_pte_fault(mm, vma, address, write_access, pte, pmd);
+	rc = handle_pte_fault(mm, vma, address, write_access, pte, pmd);
+	delayacct_pgflt(ts);
+	return rc;

  oom:
 	spin_unlock(&mm->page_table_lock);
+	delayacct_pgflt(ts);
 	return VM_FAULT_OOM;
 }


                 reply	other threads:[~2005-11-15  3:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=437965A6.6080607@watson.ibm.com \
    --to=nagar@watson.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.