Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140683
b: refs/heads/master
c: ce70a0b
h: refs/heads/master
i:
  140681: 74f1cd9
  140679: 40885a7
v: v3
  • Loading branch information
Ingo Molnar committed Feb 4, 2009
1 parent e6d8951 commit f2c1093
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 226 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 79fb0768fbd371f3b94d909f51f587b3a24ab272
refs/heads/master: ce70a0b472e06feae3a580ecb3fbef1e1e020a9b
83 changes: 63 additions & 20 deletions trunk/block/blktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <linux/debugfs.h>
#include <linux/time.h>
#include <trace/block.h>
#include <asm/uaccess.h>
#include <linux/uaccess.h>
#include <../kernel/trace/trace_output.h>

static unsigned int blktrace_seq __read_mostly = 1;
Expand Down Expand Up @@ -148,11 +148,12 @@ static int act_log_check(struct blk_trace *bt, u32 what, sector_t sector,
/*
* Data direction bit lookup
*/
static u32 ddir_act[2] __read_mostly = { BLK_TC_ACT(BLK_TC_READ), BLK_TC_ACT(BLK_TC_WRITE) };
static u32 ddir_act[2] __read_mostly = { BLK_TC_ACT(BLK_TC_READ),
BLK_TC_ACT(BLK_TC_WRITE) };

/* The ilog2() calls fall out because they're constant */
#define MASK_TC_BIT(rw, __name) ( (rw & (1 << BIO_RW_ ## __name)) << \
(ilog2(BLK_TC_ ## __name) + BLK_TC_SHIFT - BIO_RW_ ## __name) )
#define MASK_TC_BIT(rw, __name) ((rw & (1 << BIO_RW_ ## __name)) << \
(ilog2(BLK_TC_ ## __name) + BLK_TC_SHIFT - BIO_RW_ ## __name))

/*
* The worker for the various blk_add_trace*() types. Fills out a
Expand Down Expand Up @@ -219,9 +220,16 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION;
t->sequence = ++(*sequence);
t->time = ktime_to_ns(ktime_get());
record_it:
/*
* These two are not needed in ftrace as they are in the
* generic trace_entry, filled by tracing_generic_entry_update,
* but for the trace_event->bin() synthesizer benefit we do it
* here too.
*/
t->cpu = cpu;
t->pid = pid;
record_it:

t->sector = sector;
t->bytes = bytes;
t->action = what;
Expand Down Expand Up @@ -446,7 +454,8 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
atomic_set(&bt->dropped, 0);

ret = -EIO;
bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt, &blk_dropped_fops);
bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
&blk_dropped_fops);
if (!bt->dropped_file)
goto err;

Expand Down Expand Up @@ -528,10 +537,10 @@ EXPORT_SYMBOL_GPL(blk_trace_setup);

int blk_trace_startstop(struct request_queue *q, int start)
{
struct blk_trace *bt;
int ret;
struct blk_trace *bt = q->blk_trace;

if ((bt = q->blk_trace) == NULL)
if (bt == NULL)
return -EINVAL;

/*
Expand Down Expand Up @@ -667,12 +676,14 @@ static void blk_add_trace_rq_issue(struct request_queue *q, struct request *rq)
blk_add_trace_rq(q, rq, BLK_TA_ISSUE);
}

static void blk_add_trace_rq_requeue(struct request_queue *q, struct request *rq)
static void blk_add_trace_rq_requeue(struct request_queue *q,
struct request *rq)
{
blk_add_trace_rq(q, rq, BLK_TA_REQUEUE);
}

static void blk_add_trace_rq_complete(struct request_queue *q, struct request *rq)
static void blk_add_trace_rq_complete(struct request_queue *q,
struct request *rq)
{
blk_add_trace_rq(q, rq, BLK_TA_COMPLETE);
}
Expand Down Expand Up @@ -709,12 +720,14 @@ static void blk_add_trace_bio_complete(struct request_queue *q, struct bio *bio)
blk_add_trace_bio(q, bio, BLK_TA_COMPLETE);
}

static void blk_add_trace_bio_backmerge(struct request_queue *q, struct bio *bio)
static void blk_add_trace_bio_backmerge(struct request_queue *q,
struct bio *bio)
{
blk_add_trace_bio(q, bio, BLK_TA_BACKMERGE);
}

static void blk_add_trace_bio_frontmerge(struct request_queue *q, struct bio *bio)
static void blk_add_trace_bio_frontmerge(struct request_queue *q,
struct bio *bio)
{
blk_add_trace_bio(q, bio, BLK_TA_FRONTMERGE);
}
Expand All @@ -724,7 +737,8 @@ static void blk_add_trace_bio_queue(struct request_queue *q, struct bio *bio)
blk_add_trace_bio(q, bio, BLK_TA_QUEUE);
}

static void blk_add_trace_getrq(struct request_queue *q, struct bio *bio, int rw)
static void blk_add_trace_getrq(struct request_queue *q,
struct bio *bio, int rw)
{
if (bio)
blk_add_trace_bio(q, bio, BLK_TA_GETRQ);
Expand All @@ -737,15 +751,17 @@ static void blk_add_trace_getrq(struct request_queue *q, struct bio *bio, int rw
}


static void blk_add_trace_sleeprq(struct request_queue *q, struct bio *bio, int rw)
static void blk_add_trace_sleeprq(struct request_queue *q,
struct bio *bio, int rw)
{
if (bio)
blk_add_trace_bio(q, bio, BLK_TA_SLEEPRQ);
else {
struct blk_trace *bt = q->blk_trace;

if (bt)
__blk_add_trace(bt, 0, 0, rw, BLK_TA_SLEEPRQ, 0, 0, NULL);
__blk_add_trace(bt, 0, 0, rw, BLK_TA_SLEEPRQ,
0, 0, NULL);
}
}

Expand Down Expand Up @@ -1086,6 +1102,7 @@ static void blk_tracer_start(struct trace_array *tr)
if (blk_register_tracepoints())
atomic_dec(&blk_probes_ref);
mutex_unlock(&blk_probe_mutex);
trace_flags &= ~TRACE_ITER_CONTEXT_INFO;
}

static int blk_tracer_init(struct trace_array *tr)
Expand All @@ -1100,6 +1117,7 @@ static int blk_tracer_init(struct trace_array *tr)

static void blk_tracer_stop(struct trace_array *tr)
{
trace_flags |= TRACE_ITER_CONTEXT_INFO;
mutex_lock(&blk_probe_mutex);
if (atomic_dec_and_test(&blk_probes_ref))
blk_unregister_tracepoints();
Expand Down Expand Up @@ -1140,25 +1158,50 @@ static struct {
[__BLK_TA_REMAP] = {{ "A", "remap" }, blk_log_remap },
};

static int blk_trace_event_print(struct trace_seq *s, struct trace_entry *ent,
int flags)
static int blk_trace_event_print(struct trace_iterator *iter, int flags)
{
const struct blk_io_trace *t = (struct blk_io_trace *)ent;
struct trace_seq *s = &iter->seq;
const struct blk_io_trace *t = (struct blk_io_trace *)iter->ent;
const u16 what = t->action & ((1 << BLK_TC_SHIFT) - 1);
int ret;

if (trace_print_context(iter))
return TRACE_TYPE_PARTIAL_LINE;

if (unlikely(what == 0 || what > ARRAY_SIZE(what2act)))
ret = trace_seq_printf(s, "Bad pc action %x\n", what);
else {
const bool long_act = !!(trace_flags & TRACE_ITER_VERBOSE);
ret = blk_log_action_seq(s, t, what2act[what].act[long_act]);
if (ret)
ret = what2act[what].print(s, ent);
ret = what2act[what].print(s, iter->ent);
}

return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
}

static int blk_trace_synthesize_old_trace(struct trace_iterator *iter)
{
struct trace_seq *s = &iter->seq;
struct blk_io_trace *t = (struct blk_io_trace *)iter->ent;
const int offset = offsetof(struct blk_io_trace, sector);
struct blk_io_trace old = {
.magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION,
.time = ns2usecs(iter->ts),
};

if (!trace_seq_putmem(s, &old, offset))
return 0;
return trace_seq_putmem(s, &t->sector,
sizeof(old) - offset + t->pdu_len);
}

static int blk_trace_event_print_binary(struct trace_iterator *iter, int flags)
{
return blk_trace_synthesize_old_trace(iter) ?
TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
}

static enum print_line_t blk_tracer_print_line(struct trace_iterator *iter)
{
const struct blk_io_trace *t;
Expand Down Expand Up @@ -1200,7 +1243,7 @@ static struct trace_event trace_blk_event = {
.latency_trace = blk_trace_event_print,
.raw = trace_nop_print,
.hex = trace_nop_print,
.binary = trace_nop_print,
.binary = blk_trace_event_print_binary,
};

static int __init init_blk_tracer(void)
Expand Down
5 changes: 5 additions & 0 deletions trunk/kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1729,19 +1729,24 @@ static void clear_ftrace_pid(struct pid *pid)
{
struct task_struct *p;

rcu_read_lock();
do_each_pid_task(pid, PIDTYPE_PID, p) {
clear_tsk_trace_trace(p);
} while_each_pid_task(pid, PIDTYPE_PID, p);
rcu_read_unlock();

put_pid(pid);
}

static void set_ftrace_pid(struct pid *pid)
{
struct task_struct *p;

rcu_read_lock();
do_each_pid_task(pid, PIDTYPE_PID, p) {
set_tsk_trace_trace(p);
} while_each_pid_task(pid, PIDTYPE_PID, p);
rcu_read_unlock();
}

static void clear_ftrace_pid_task(struct pid **pid)
Expand Down
Loading

0 comments on commit f2c1093

Please sign in to comment.