|
|
|
|
@@ -64,8 +64,7 @@ static void blk_unregister_tracepoints(void);
|
|
|
|
|
* Send out a notify message.
|
|
|
|
|
*/
|
|
|
|
|
static void trace_note(struct blk_trace *bt, pid_t pid, int action,
|
|
|
|
|
const void *data, size_t len,
|
|
|
|
|
union kernfs_node_id *cgid)
|
|
|
|
|
const void *data, size_t len, u64 cgid)
|
|
|
|
|
{
|
|
|
|
|
struct blk_io_trace *t;
|
|
|
|
|
struct ring_buffer_event *event = NULL;
|
|
|
|
|
@@ -73,7 +72,7 @@ static void trace_note(struct blk_trace *bt, pid_t pid, int action,
|
|
|
|
|
int pc = 0;
|
|
|
|
|
int cpu = smp_processor_id();
|
|
|
|
|
bool blk_tracer = blk_tracer_enabled;
|
|
|
|
|
ssize_t cgid_len = cgid ? sizeof(*cgid) : 0;
|
|
|
|
|
ssize_t cgid_len = cgid ? sizeof(cgid) : 0;
|
|
|
|
|
|
|
|
|
|
if (blk_tracer) {
|
|
|
|
|
buffer = blk_tr->trace_buffer.buffer;
|
|
|
|
|
@@ -100,8 +99,8 @@ record_it:
|
|
|
|
|
t->pid = pid;
|
|
|
|
|
t->cpu = cpu;
|
|
|
|
|
t->pdu_len = len + cgid_len;
|
|
|
|
|
if (cgid)
|
|
|
|
|
memcpy((void *)t + sizeof(*t), cgid, cgid_len);
|
|
|
|
|
if (cgid_len)
|
|
|
|
|
memcpy((void *)t + sizeof(*t), &cgid, cgid_len);
|
|
|
|
|
memcpy((void *) t + sizeof(*t) + cgid_len, data, len);
|
|
|
|
|
|
|
|
|
|
if (blk_tracer)
|
|
|
|
|
@@ -122,7 +121,7 @@ static void trace_note_tsk(struct task_struct *tsk)
|
|
|
|
|
spin_lock_irqsave(&running_trace_lock, flags);
|
|
|
|
|
list_for_each_entry(bt, &running_trace_list, running_list) {
|
|
|
|
|
trace_note(bt, tsk->pid, BLK_TN_PROCESS, tsk->comm,
|
|
|
|
|
sizeof(tsk->comm), NULL);
|
|
|
|
|
sizeof(tsk->comm), 0);
|
|
|
|
|
}
|
|
|
|
|
spin_unlock_irqrestore(&running_trace_lock, flags);
|
|
|
|
|
}
|
|
|
|
|
@@ -139,7 +138,7 @@ static void trace_note_time(struct blk_trace *bt)
|
|
|
|
|
words[1] = now.tv_nsec;
|
|
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
|
trace_note(bt, 0, BLK_TN_TIMESTAMP, words, sizeof(words), NULL);
|
|
|
|
|
trace_note(bt, 0, BLK_TN_TIMESTAMP, words, sizeof(words), 0);
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -172,9 +171,9 @@ void __trace_note_message(struct blk_trace *bt, struct blkcg *blkcg,
|
|
|
|
|
blkcg = NULL;
|
|
|
|
|
#ifdef CONFIG_BLK_CGROUP
|
|
|
|
|
trace_note(bt, 0, BLK_TN_MESSAGE, buf, n,
|
|
|
|
|
blkcg ? cgroup_get_kernfs_id(blkcg->css.cgroup) : NULL);
|
|
|
|
|
blkcg ? cgroup_get_kernfs_id(blkcg->css.cgroup) : 0);
|
|
|
|
|
#else
|
|
|
|
|
trace_note(bt, 0, BLK_TN_MESSAGE, buf, n, NULL);
|
|
|
|
|
trace_note(bt, 0, BLK_TN_MESSAGE, buf, n, 0);
|
|
|
|
|
#endif
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
|
}
|
|
|
|
|
@@ -212,7 +211,7 @@ static const u32 ddir_act[2] = { BLK_TC_ACT(BLK_TC_READ),
|
|
|
|
|
*/
|
|
|
|
|
static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
|
|
|
|
|
int op, int op_flags, u32 what, int error, int pdu_len,
|
|
|
|
|
void *pdu_data, union kernfs_node_id *cgid)
|
|
|
|
|
void *pdu_data, u64 cgid)
|
|
|
|
|
{
|
|
|
|
|
struct task_struct *tsk = current;
|
|
|
|
|
struct ring_buffer_event *event = NULL;
|
|
|
|
|
@@ -223,7 +222,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
|
|
|
|
|
pid_t pid;
|
|
|
|
|
int cpu, pc = 0;
|
|
|
|
|
bool blk_tracer = blk_tracer_enabled;
|
|
|
|
|
ssize_t cgid_len = cgid ? sizeof(*cgid) : 0;
|
|
|
|
|
ssize_t cgid_len = cgid ? sizeof(cgid) : 0;
|
|
|
|
|
|
|
|
|
|
if (unlikely(bt->trace_state != Blktrace_running && !blk_tracer))
|
|
|
|
|
return;
|
|
|
|
|
@@ -294,7 +293,7 @@ record_it:
|
|
|
|
|
t->pdu_len = pdu_len + cgid_len;
|
|
|
|
|
|
|
|
|
|
if (cgid_len)
|
|
|
|
|
memcpy((void *)t + sizeof(*t), cgid, cgid_len);
|
|
|
|
|
memcpy((void *)t + sizeof(*t), &cgid, cgid_len);
|
|
|
|
|
if (pdu_len)
|
|
|
|
|
memcpy((void *)t + sizeof(*t) + cgid_len, pdu_data, pdu_len);
|
|
|
|
|
|
|
|
|
|
@@ -751,31 +750,29 @@ void blk_trace_shutdown(struct request_queue *q)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_BLK_CGROUP
|
|
|
|
|
static union kernfs_node_id *
|
|
|
|
|
blk_trace_bio_get_cgid(struct request_queue *q, struct bio *bio)
|
|
|
|
|
static u64 blk_trace_bio_get_cgid(struct request_queue *q, struct bio *bio)
|
|
|
|
|
{
|
|
|
|
|
struct blk_trace *bt = q->blk_trace;
|
|
|
|
|
|
|
|
|
|
if (!bt || !(blk_tracer_flags.val & TRACE_BLK_OPT_CGROUP))
|
|
|
|
|
return NULL;
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (!bio->bi_blkg)
|
|
|
|
|
return NULL;
|
|
|
|
|
return 0;
|
|
|
|
|
return cgroup_get_kernfs_id(bio_blkcg(bio)->css.cgroup);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
static union kernfs_node_id *
|
|
|
|
|
blk_trace_bio_get_cgid(struct request_queue *q, struct bio *bio)
|
|
|
|
|
u64 blk_trace_bio_get_cgid(struct request_queue *q, struct bio *bio)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static union kernfs_node_id *
|
|
|
|
|
static u64
|
|
|
|
|
blk_trace_request_get_cgid(struct request_queue *q, struct request *rq)
|
|
|
|
|
{
|
|
|
|
|
if (!rq->bio)
|
|
|
|
|
return NULL;
|
|
|
|
|
return 0;
|
|
|
|
|
/* Use the first bio */
|
|
|
|
|
return blk_trace_bio_get_cgid(q, rq->bio);
|
|
|
|
|
}
|
|
|
|
|
@@ -797,8 +794,7 @@ blk_trace_request_get_cgid(struct request_queue *q, struct request *rq)
|
|
|
|
|
*
|
|
|
|
|
**/
|
|
|
|
|
static void blk_add_trace_rq(struct request *rq, int error,
|
|
|
|
|
unsigned int nr_bytes, u32 what,
|
|
|
|
|
union kernfs_node_id *cgid)
|
|
|
|
|
unsigned int nr_bytes, u32 what, u64 cgid)
|
|
|
|
|
{
|
|
|
|
|
struct blk_trace *bt = rq->q->blk_trace;
|
|
|
|
|
|
|
|
|
|
@@ -913,7 +909,7 @@ static void blk_add_trace_getrq(void *ignore,
|
|
|
|
|
|
|
|
|
|
if (bt)
|
|
|
|
|
__blk_add_trace(bt, 0, 0, rw, 0, BLK_TA_GETRQ, 0, 0,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
NULL, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -929,7 +925,7 @@ static void blk_add_trace_sleeprq(void *ignore,
|
|
|
|
|
|
|
|
|
|
if (bt)
|
|
|
|
|
__blk_add_trace(bt, 0, 0, rw, 0, BLK_TA_SLEEPRQ,
|
|
|
|
|
0, 0, NULL, NULL);
|
|
|
|
|
0, 0, NULL, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -938,7 +934,7 @@ static void blk_add_trace_plug(void *ignore, struct request_queue *q)
|
|
|
|
|
struct blk_trace *bt = q->blk_trace;
|
|
|
|
|
|
|
|
|
|
if (bt)
|
|
|
|
|
__blk_add_trace(bt, 0, 0, 0, 0, BLK_TA_PLUG, 0, 0, NULL, NULL);
|
|
|
|
|
__blk_add_trace(bt, 0, 0, 0, 0, BLK_TA_PLUG, 0, 0, NULL, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void blk_add_trace_unplug(void *ignore, struct request_queue *q,
|
|
|
|
|
@@ -955,7 +951,7 @@ static void blk_add_trace_unplug(void *ignore, struct request_queue *q,
|
|
|
|
|
else
|
|
|
|
|
what = BLK_TA_UNPLUG_TIMER;
|
|
|
|
|
|
|
|
|
|
__blk_add_trace(bt, 0, 0, 0, 0, what, 0, sizeof(rpdu), &rpdu, NULL);
|
|
|
|
|
__blk_add_trace(bt, 0, 0, 0, 0, what, 0, sizeof(rpdu), &rpdu, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1172,19 +1168,17 @@ const struct blk_io_trace *te_blk_io_trace(const struct trace_entry *ent)
|
|
|
|
|
|
|
|
|
|
static inline const void *pdu_start(const struct trace_entry *ent, bool has_cg)
|
|
|
|
|
{
|
|
|
|
|
return (void *)(te_blk_io_trace(ent) + 1) +
|
|
|
|
|
(has_cg ? sizeof(union kernfs_node_id) : 0);
|
|
|
|
|
return (void *)(te_blk_io_trace(ent) + 1) + (has_cg ? sizeof(u64) : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline const void *cgid_start(const struct trace_entry *ent)
|
|
|
|
|
static inline u64 t_cgid(const struct trace_entry *ent)
|
|
|
|
|
{
|
|
|
|
|
return (void *)(te_blk_io_trace(ent) + 1);
|
|
|
|
|
return *(u64 *)(te_blk_io_trace(ent) + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int pdu_real_len(const struct trace_entry *ent, bool has_cg)
|
|
|
|
|
{
|
|
|
|
|
return te_blk_io_trace(ent)->pdu_len -
|
|
|
|
|
(has_cg ? sizeof(union kernfs_node_id) : 0);
|
|
|
|
|
return te_blk_io_trace(ent)->pdu_len - (has_cg ? sizeof(u64) : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline u32 t_action(const struct trace_entry *ent)
|
|
|
|
|
@@ -1257,7 +1251,7 @@ static void blk_log_action(struct trace_iterator *iter, const char *act,
|
|
|
|
|
|
|
|
|
|
fill_rwbs(rwbs, t);
|
|
|
|
|
if (has_cg) {
|
|
|
|
|
const union kernfs_node_id *id = cgid_start(iter->ent);
|
|
|
|
|
u64 id = t_cgid(iter->ent);
|
|
|
|
|
|
|
|
|
|
if (blk_tracer_flags.val & TRACE_BLK_OPT_CGNAME) {
|
|
|
|
|
char blkcg_name_buf[NAME_MAX + 1] = "<...>";
|
|
|
|
|
@@ -1269,9 +1263,10 @@ static void blk_log_action(struct trace_iterator *iter, const char *act,
|
|
|
|
|
blkcg_name_buf, act, rwbs);
|
|
|
|
|
} else
|
|
|
|
|
trace_seq_printf(&iter->seq,
|
|
|
|
|
"%3d,%-3d %x,%-x %2s %3s ",
|
|
|
|
|
"%3d,%-3d %lx,%-x %2s %3s ",
|
|
|
|
|
MAJOR(t->device), MINOR(t->device),
|
|
|
|
|
id->ino, id->generation, act, rwbs);
|
|
|
|
|
kernfs_id_ino(id), kernfs_id_gen(id),
|
|
|
|
|
act, rwbs);
|
|
|
|
|
} else
|
|
|
|
|
trace_seq_printf(&iter->seq, "%3d,%-3d %2s %3s ",
|
|
|
|
|
MAJOR(t->device), MINOR(t->device), act, rwbs);
|
|
|
|
|
|