[patch 12/15] LTTng instrumentation - hugetlb

From: Mathieu Desnoyers
Date: Wed Jul 09 2008 - 11:05:15 EST


Instrumentation of hugetlb activity (alloc/free/reserve).

Those tracepoints are used by LTTng.

About the performance impact of tracepoints (which is comparable to markers),
even without immediate values optimizations, tests done by Hideo Aoki on ia64
show no regression. His test case was using hackbench on a kernel where
scheduler instrumentation (about 5 events in code scheduler code) was added.
See the "Tracepoints" patch header for performance result detail.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxx>
CC: William Lee Irwin III <wli@xxxxxxxxxxxxxx>
CC: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
CC: 'Peter Zijlstra' <peterz@xxxxxxxxxxxxx>
CC: "Frank Ch. Eigler" <fche@xxxxxxxxxx>
CC: 'Ingo Molnar' <mingo@xxxxxxx>
CC: 'Hideo AOKI' <haoki@xxxxxxxxxx>
CC: Takashi Nishiie <t-nishiie@xxxxxxxxxxxxxxxxxx>
CC: 'Steven Rostedt' <rostedt@xxxxxxxxxxx>
CC: Eduard - Gabriel Munteanu <eduard.munteanu@xxxxxxxxxxx>
---
mm/hugetlb-trace.h | 19 +++++++++++++++++++
mm/hugetlb.c | 8 +++++++-
2 files changed, 26 insertions(+), 1 deletion(-)

Index: linux-2.6-lttng/mm/hugetlb.c
===================================================================
--- linux-2.6-lttng.orig/mm/hugetlb.c 2008-07-07 16:31:44.000000000 -0400
+++ linux-2.6-lttng/mm/hugetlb.c 2008-07-08 10:51:17.000000000 -0400
@@ -14,6 +14,7 @@
#include <linux/mempolicy.h>
#include <linux/cpuset.h>
#include <linux/mutex.h>
+#include "hugetlb-trace.h"

#include <asm/page.h>
#include <asm/pgtable.h>
@@ -141,6 +142,7 @@ static void free_huge_page(struct page *
int nid = page_to_nid(page);
struct address_space *mapping;

+ trace_hugetlb_page_free(page);
mapping = (struct address_space *) page_private(page);
set_page_private(page, 0);
BUG_ON(page_count(page));
@@ -509,6 +511,7 @@ static struct page *alloc_huge_page(stru
if (!IS_ERR(page)) {
set_page_refcounted(page);
set_page_private(page, (unsigned long) mapping);
+ trace_hugetlb_page_alloc(page);
}
return page;
}
@@ -1306,13 +1309,16 @@ int hugetlb_reserve_pages(struct inode *
return ret;
}
region_add(&inode->i_mapping->private_list, from, to);
+ trace_hugetlb_pages_reserve(inode, from, to);
return 0;
}

void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed)
{
- long chg = region_truncate(&inode->i_mapping->private_list, offset);
+ long chg;

+ trace_hugetlb_pages_unreserve(inode, offset, freed);
+ chg = region_truncate(&inode->i_mapping->private_list, offset);
spin_lock(&inode->i_lock);
inode->i_blocks -= BLOCKS_PER_HUGEPAGE * freed;
spin_unlock(&inode->i_lock);
Index: linux-2.6-lttng/mm/hugetlb-trace.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/mm/hugetlb-trace.h 2008-07-08 10:45:15.000000000 -0400
@@ -0,0 +1,19 @@
+#ifndef _HUGETLB_TRACE_H
+#define _HUGETLB_TRACE_H
+
+#include <linux/tracepoint.h>
+
+DEFINE_TRACE(hugetlb_page_alloc,
+ TPPROTO(struct page *page),
+ TPARGS(page));
+DEFINE_TRACE(hugetlb_page_free,
+ TPPROTO(struct page *page),
+ TPARGS(page));
+DEFINE_TRACE(hugetlb_pages_reserve,
+ TPPROTO(struct inode *inode, long from, long to),
+ TPARGS(inode, from, to));
+DEFINE_TRACE(hugetlb_pages_unreserve,
+ TPPROTO(struct inode *inode, long offset, long freed),
+ TPARGS(inode, offset, freed));
+
+#endif

--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/