public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add tracepoints to track pagecache transition
@ 2009-02-17  9:00 Atsushi Tsuji
  2009-02-17  9:33 ` Peter Zijlstra
  0 siblings, 1 reply; 14+ messages in thread
From: Atsushi Tsuji @ 2009-02-17  9:00 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jason Baron, Ingo Molnar, Mathieu Desnoyers, Frank Ch. Eigler,
	Kazuto Miyoshi, rostedt

[-- Attachment #1: Type: text/plain, Size: 2564 bytes --]

Hi,

The below patch adds instrumentation for pagecache.

I thought it would be useful to trace pagecache behavior for problem
analysis (performance bottlenecks, behavior differences between stable
time and trouble time).

By using those tracepoints, we can describe and visualize pagecache
transition (file-by-file basis) in kernel and  pagecache
consumes most of the memory in running system and pagecache hit rate
and writeback behavior will influence system load and performance.

I attached an example which is visualization of pagecache status using
SystemTap. That graph describes pagecache transition of File A and File B
on a file-by-file basis with the situation where regular I/O to File A
is delayed because of other I/O to File B. We visually understand
pagecache for File A is narrowed down due to I/O pressure from File B.


Signed-off-by: Atsushi Tsuji <a-tsuji@bk.jp.nec.com>
---
diff --git a/include/trace/filemap.h b/include/trace/filemap.h
new file mode 100644
index 0000000..196955e
--- /dev/null
+++ b/include/trace/filemap.h
@@ -0,0 +1,13 @@
+#ifndef _TRACE_FILEMAP_H
+#define _TRACE_FILEMAP_H
+
+#include <linux/tracepoint.h>
+
+DECLARE_TRACE(filemap_add_to_page_cache,
+	TPPROTO(struct address_space *mapping, pgoff_t offset),
+	TPARGS(mapping, offset));
+DECLARE_TRACE(filemap_remove_from_page_cache,
+	TPPROTO(struct address_space *mapping),
+	TPARGS(mapping));
+
+#endif
diff --git a/mm/filemap.c b/mm/filemap.c
index 23acefe..76a6887 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -34,6 +34,7 @@
 #include <linux/hardirq.h> /* for BUG_ON(!in_atomic()) only */
 #include <linux/memcontrol.h>
 #include <linux/mm_inline.h> /* for page_is_file_cache() */
+#include <trace/filemap.h>
 #include "internal.h"
 
 /*
@@ -43,6 +44,8 @@
 
 #include <asm/mman.h>
 
+DEFINE_TRACE(filemap_add_to_page_cache);
+DEFINE_TRACE(filemap_remove_from_page_cache);
 
 /*
  * Shared mappings implemented 30.11.1994. It's not fully working yet,
@@ -120,6 +123,7 @@ void __remove_from_page_cache(struct page *page)
 	page->mapping = NULL;
 	mapping->nrpages--;
 	__dec_zone_page_state(page, NR_FILE_PAGES);
+	trace_filemap_remove_from_page_cache(mapping);
 	BUG_ON(page_mapped(page));
 	mem_cgroup_uncharge_cache_page(page);
 
@@ -475,6 +479,7 @@ int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
 		if (likely(!error)) {
 			mapping->nrpages++;
 			__inc_zone_page_state(page, NR_FILE_PAGES);
+			trace_filemap_add_to_page_cache(mapping, offset);
 		} else {
 			page->mapping = NULL;
 			mem_cgroup_uncharge_cache_page(page);



[-- Attachment #2: pgcache.jpg --]
[-- Type: image/jpeg, Size: 38334 bytes --]

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-02-20  1:13 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-17  9:00 [PATCH] Add tracepoints to track pagecache transition Atsushi Tsuji
2009-02-17  9:33 ` Peter Zijlstra
2009-02-17 11:04   ` Atsushi Tsuji
2009-02-17 11:38     ` KOSAKI Motohiro
2009-02-17 11:54       ` Peter Zijlstra
2009-02-17 12:33         ` KOSAKI Motohiro
2009-02-17 14:33       ` Frederic Weisbecker
2009-02-18  0:29         ` KOSAKI Motohiro
2009-02-19  4:41       ` Atsushi Tsuji
2009-02-19 13:12         ` KOSAKI Motohiro
2009-02-19 14:21           ` Lee Schermerhorn
2009-02-20  1:13             ` KOSAKI Motohiro
2009-02-17 15:24     ` Steven Rostedt
2009-02-19 18:51       ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox