summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Olexa <darkside@gentoo.org>2009-03-27 12:59:24 +0000
committerJeremy Olexa <darkside@gentoo.org>2009-03-27 12:59:24 +0000
commit4e40ba3f419b1700bb0c25964bf1e953bbe6da14 (patch)
tree7f05273aca16493edda14821daa0b3f1a27b91e8 /sys-apps/sreadahead
parentSparc stable, preparation for bug #245707. (diff)
downloadgentoo-2-4e40ba3f419b1700bb0c25964bf1e953bbe6da14.tar.gz
gentoo-2-4e40ba3f419b1700bb0c25964bf1e953bbe6da14.tar.bz2
gentoo-2-4e40ba3f419b1700bb0c25964bf1e953bbe6da14.zip
Version bump, with patch from upstream - experimental and may not work yet. bug 257207
(Portage version: 2.1.6.9/cvs/Linux x86_64)
Diffstat (limited to 'sys-apps/sreadahead')
-rw-r--r--sys-apps/sreadahead/ChangeLog10
-rw-r--r--sys-apps/sreadahead/files/0001-kernel-trace-open.patch251
-rw-r--r--sys-apps/sreadahead/files/sreadahead_iter_ctrl.patch19
-rw-r--r--sys-apps/sreadahead/sreadahead-1.0.ebuild38
4 files changed, 317 insertions, 1 deletions
diff --git a/sys-apps/sreadahead/ChangeLog b/sys-apps/sreadahead/ChangeLog
index e171f3dfa582..d81c5c27d7b6 100644
--- a/sys-apps/sreadahead/ChangeLog
+++ b/sys-apps/sreadahead/ChangeLog
@@ -1,6 +1,14 @@
# ChangeLog for sys-apps/sreadahead
# Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/sreadahead/ChangeLog,v 1.1 2009/01/23 05:57:56 darkside Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/sreadahead/ChangeLog,v 1.2 2009/03/27 12:59:24 darkside Exp $
+
+*sreadahead-1.0 (27 Mar 2009)
+
+ 27 Mar 2009; Jeremy Olexa <darkside@gentoo.org>
+ +files/0001-kernel-trace-open.patch, +files/sreadahead_iter_ctrl.patch,
+ +sreadahead-1.0.ebuild:
+ Version bump, with patch from upstream - experimental and may not work yet.
+ bug 257207
*sreadahead-0.04 (23 Jan 2009)
diff --git a/sys-apps/sreadahead/files/0001-kernel-trace-open.patch b/sys-apps/sreadahead/files/0001-kernel-trace-open.patch
new file mode 100644
index 000000000000..fcb7ae480e16
--- /dev/null
+++ b/sys-apps/sreadahead/files/0001-kernel-trace-open.patch
@@ -0,0 +1,251 @@
+commit e9c4f51ad2b76ddbf90863c44085574197247ba3
+Author: Auke Kok <auke-jan.h.kok@intel.com>
+Date: Tue Jan 27 11:26:00 2009 -0800
+
+ trace: tracer for sys_open() - sreadahead
+
+ This tracer monitors regular file open() syscalls. This is a fast
+ and low-overhead alternative to strace, and does not allow or
+ require to be attached to every process.
+
+ Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
+
+diff --git a/fs/open.c b/fs/open.c
+index a3a78ce..bd9eb9d 100644
+--- a/fs/open.c
++++ b/fs/open.c
+@@ -30,6 +30,10 @@
+ #include <linux/audit.h>
+ #include <linux/falloc.h>
+
++#include <trace/fs.h>
++
++DEFINE_TRACE(do_sys_open);
++
+ int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
+ {
+ int retval = -ENODEV;
+@@ -1039,6 +1043,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, int mode)
+ } else {
+ fsnotify_open(f->f_path.dentry);
+ fd_install(fd, f);
++ trace_do_sys_open(f, flags, mode, fd);
+ }
+ }
+ putname(tmp);
+diff --git a/include/trace/fs.h b/include/trace/fs.h
+new file mode 100644
+index 0000000..870eec2
+--- /dev/null
++++ b/include/trace/fs.h
+@@ -0,0 +1,11 @@
++#ifndef _TRACE_FS_H
++#define _TRACE_FS_H
++
++#include <linux/fs.h>
++#include <linux/tracepoint.h>
++
++DECLARE_TRACE(do_sys_open,
++ TPPROTO(struct file *filp, int flags, int mode, long fd),
++ TPARGS(filp, flags, mode, fd));
++
++#endif
+diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
+index e2a4ff6..d2a1ec1 100644
+--- a/kernel/trace/Kconfig
++++ b/kernel/trace/Kconfig
+@@ -149,6 +149,15 @@ config CONTEXT_SWITCH_TRACER
+ This tracer gets called from the context switch and records
+ all switching of tasks.
+
++config OPEN_TRACER
++ bool "Trace open() calls"
++ depends on DEBUG_KERNEL
++ select TRACING
++ select MARKERS
++ help
++ This tracer records open() syscalls. These calls are made when
++ files are accessed on disk.
++
+ config BOOT_TRACER
+ bool "Trace boot initcalls"
+ depends on DEBUG_KERNEL
+diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
+index 349d5a9..7f2a366 100644
+--- a/kernel/trace/Makefile
++++ b/kernel/trace/Makefile
+@@ -20,6 +20,7 @@ obj-$(CONFIG_RING_BUFFER) += ring_buffer.o
+
+ obj-$(CONFIG_TRACING) += trace.o
+ obj-$(CONFIG_CONTEXT_SWITCH_TRACER) += trace_sched_switch.o
++obj-$(CONFIG_OPEN_TRACER) += trace_open.o
+ obj-$(CONFIG_SYSPROF_TRACER) += trace_sysprof.o
+ obj-$(CONFIG_FUNCTION_TRACER) += trace_functions.o
+ obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o
+diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
+index 4d3d381..24c17d2 100644
+--- a/kernel/trace/trace.h
++++ b/kernel/trace/trace.h
+@@ -30,6 +30,7 @@ enum trace_type {
+ TRACE_USER_STACK,
+ TRACE_HW_BRANCHES,
+ TRACE_POWER,
++ TRACE_OPEN,
+
+ __TRACE_LAST_TYPE
+ };
+diff --git a/kernel/trace/trace_open.c b/kernel/trace/trace_open.c
+new file mode 100644
+index 0000000..7153dfc
+--- /dev/null
++++ b/kernel/trace/trace_open.c
+@@ -0,0 +1,149 @@
++/*
++ * trace open calls
++ * Copyright (C) 2009 Intel Corporation
++ *
++ * Based extensively on trace_sched_switch.c
++ * Copyright (C) 2007 Steven Rostedt <srostedt@redhat.com>
++ *
++ */
++
++#include <linux/module.h>
++#include <linux/fs.h>
++#include <linux/debugfs.h>
++#include <linux/kallsyms.h>
++#include <linux/uaccess.h>
++#include <linux/ftrace.h>
++#include <trace/fs.h>
++
++#include "trace.h"
++
++
++static struct trace_array *ctx_trace;
++static int __read_mostly open_trace_enabled;
++static atomic_t open_ref;
++
++static void probe_do_sys_open(struct file *filp, int flags, int mode, long fd)
++{
++ char *buf;
++ char *fname;
++
++ if (!atomic_read(&open_ref))
++ return;
++
++ if (!open_trace_enabled)
++ return;
++
++ buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
++ if (!buf)
++ return;
++
++ fname = d_path(&filp->f_path, buf, PAGE_SIZE);
++ if (IS_ERR(fname))
++ goto out;
++
++ ftrace_printk("%s: open(\"%s\", %d, %d) = %ld\n",
++ current->comm, fname, flags, mode, fd);
++
++out:
++ kfree(buf);
++}
++
++static void open_trace_reset(struct trace_array *tr)
++{
++ tr->time_start = ftrace_now(tr->cpu);
++ tracing_reset_online_cpus(tr);
++}
++
++static int open_trace_register(void)
++{
++ int ret;
++
++ ret = register_trace_do_sys_open(probe_do_sys_open);
++ if (ret) {
++ pr_info("open trace: Could not activate tracepoint"
++ " probe to do_open\n");
++ }
++
++ return ret;
++}
++
++static void open_trace_unregister(void)
++{
++ unregister_trace_do_sys_open(probe_do_sys_open);
++}
++
++static void open_trace_start(void)
++{
++ long ref;
++
++ ref = atomic_inc_return(&open_ref);
++ if (ref == 1)
++ open_trace_register();
++}
++
++static void open_trace_stop(void)
++{
++ long ref;
++
++ ref = atomic_dec_and_test(&open_ref);
++ if (ref)
++ open_trace_unregister();
++}
++
++void open_trace_start_cmdline_record(void)
++{
++ open_trace_start();
++}
++
++void open_trace_stop_cmdline_record(void)
++{
++ open_trace_stop();
++}
++
++static void open_start_trace(struct trace_array *tr)
++{
++ open_trace_reset(tr);
++ open_trace_start_cmdline_record();
++ open_trace_enabled = 1;
++}
++
++static void open_stop_trace(struct trace_array *tr)
++{
++ open_trace_enabled = 0;
++ open_trace_stop_cmdline_record();
++}
++
++static int open_trace_init(struct trace_array *tr)
++{
++ ctx_trace = tr;
++
++ open_start_trace(tr);
++ return 0;
++}
++
++static void reset_open_trace(struct trace_array *tr)
++{
++ open_stop_trace(tr);
++}
++
++static struct tracer open_trace __read_mostly =
++{
++ .name = "open",
++ .init = open_trace_init,
++ .reset = reset_open_trace,
++};
++
++__init static int init_open_trace(void)
++{
++ int ret = 0;
++
++ if (atomic_read(&open_ref))
++ ret = open_trace_register();
++ if (ret) {
++ pr_info("error registering open trace\n");
++ return ret;
++ }
++ return register_tracer(&open_trace);
++}
++device_initcall(init_open_trace);
++
diff --git a/sys-apps/sreadahead/files/sreadahead_iter_ctrl.patch b/sys-apps/sreadahead/files/sreadahead_iter_ctrl.patch
new file mode 100644
index 000000000000..3ab2f39ea7c1
--- /dev/null
+++ b/sys-apps/sreadahead/files/sreadahead_iter_ctrl.patch
@@ -0,0 +1,19 @@
+--- sreadahead.c.orig 2009-01-28 17:26:48.000000000 +1000
++++ sreadahead.c 2009-02-01 16:36:32.000000000 +1000
+@@ -419,6 +419,16 @@
+ exit(EXIT_FAILURE);
+ }
+
++ /* Set to print out info - AW - 20090201 */
++ file = fopen("tracing/iter_ctrl", "w");
++ if (!file) {
++ perror("Unable to set iter_ctrl\n");
++ /* non-fatal */
++ } else {
++ fprintf(file, "ftrace_printk");
++ fclose(file);
++ }
++
+ file = fopen("tracing/tracing_enabled", "w");
+ if (!file) {
+ perror("Unable to enable tracing\n");
diff --git a/sys-apps/sreadahead/sreadahead-1.0.ebuild b/sys-apps/sreadahead/sreadahead-1.0.ebuild
new file mode 100644
index 000000000000..5438232d3e36
--- /dev/null
+++ b/sys-apps/sreadahead/sreadahead-1.0.ebuild
@@ -0,0 +1,38 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/sreadahead/sreadahead-1.0.ebuild,v 1.1 2009/03/27 12:59:24 darkside Exp $
+
+inherit eutils
+
+DESCRIPTION="A readahead implementation optimized for solid state discs"
+HOMEPAGE="http://code.google.com/p/sreadahead/"
+SRC_URI="http://sreadahead.googlecode.com/files/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE=""
+
+DEPEND=""
+RDEPEND=""
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+ epatch "${FILESDIR}/sreadahead_iter_ctrl.patch"
+}
+
+src_install() {
+ emake DESTDIR="${D}" install || die "emake install failed"
+ dodoc README "${FILESDIR}/0001-kernel-trace-open.patch" || die
+ newinitd "${FILESDIR}"/sreadahead.rc sreadahead || die
+}
+
+pkg_postinst() {
+ elog "Sreadahead requires a kernel built with the trace-open patch,"
+ elog "which can be found in /usr/share/doc/${PF}"
+ elog "If you don't know how to do this, it may be best to stay away from it"
+ elog
+ elog "To add sreadahead to your runlevels:"
+ elog " # rc-update add sreadahead boot"
+}