Re: [PATCH] ftrace: add an fsync tracer

From: Marcin Slusarz
Date: Wed Nov 05 2008 - 14:46:38 EST


On Wed, Nov 05, 2008 at 09:49:02AM -0800, Arjan van de Ven wrote:
> --- /dev/null
> +++ b/kernel/trace/trace_fsync.c
> @@ -0,0 +1,165 @@
> +/*
> + * trace fsync calls
> + * Copyright (C) 2008 Intel Corporation
> + *
> + * Based extensively on trace_sched_switch.c
> + * Copyright (C) 2007 Steven Rostedt <srostedt@xxxxxxxxxx>
> + *
> + */
> +#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 tracer_enabled;
> +static atomic_t fsync_ref;
> +
> +static void
> +probe_do_fsync(struct file *file, int datasync)
> +{
> + char *buffer;
> + char *err;
> +
> + if (!atomic_read(&fsync_ref))
> + return;
> +
> + if (!tracer_enabled)
> + return;
> +
> + buffer = kmalloc(4096, GFP_KERNEL);
> + if (!buffer)
> + return;
> +
> + memset(buffer, 0, 4096);

kzalloc?

> + err = d_path(&file->f_path, buffer, 4096);
> +
> + if (IS_ERR(err))
> + goto out;
> +
> + ftrace_printk("Process %s is calling fsync on %s\n",
> + current->comm, err);

err? not buffer?

> +
> +out:
> + kfree(buffer);
> +}
> +
> (...)
--
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/