Skip to content

Commit f4a6a61

Browse files
Christoph Hellwigaxboe
authored andcommitted
blktrace: cleanup the __trace_note_message interface
Pass the cgroup_subsys_state instead of a the blkg so that blktrace doesn't need to poke into blk-cgroup internals, and give the name a blk prefix as the current name is way too generic for a public interface. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20220420042723.1010598-9-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent dec223c commit f4a6a61

4 files changed

Lines changed: 17 additions & 19 deletions

File tree

block/bfq-iosched.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,13 +1102,13 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq);
11021102
break; \
11031103
bfq_bfqq_name((bfqq), pid_str, MAX_BFQQ_NAME_LENGTH); \
11041104
blk_add_cgroup_trace_msg((bfqd)->queue, \
1105-
bfqg_to_blkg(bfqq_group(bfqq))->blkcg, \
1105+
&bfqg_to_blkg(bfqq_group(bfqq))->blkcg->css, \
11061106
"%s " fmt, pid_str, ##args); \
11071107
} while (0)
11081108

11091109
#define bfq_log_bfqg(bfqd, bfqg, fmt, args...) do { \
11101110
blk_add_cgroup_trace_msg((bfqd)->queue, \
1111-
bfqg_to_blkg(bfqg)->blkcg, fmt, ##args); \
1111+
&bfqg_to_blkg(bfqg)->blkcg->css, fmt, ##args); \
11121112
} while (0)
11131113

11141114
#else /* CONFIG_BFQ_GROUP_IOSCHED */

block/blk-throttle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static unsigned int tg_iops_limit(struct throtl_grp *tg, int rw)
227227
break; \
228228
if ((__tg)) { \
229229
blk_add_cgroup_trace_msg(__td->queue, \
230-
tg_to_blkg(__tg)->blkcg, "throtl " fmt, ##args);\
230+
&tg_to_blkg(__tg)->blkcg->css, "throtl " fmt, ##args);\
231231
} else { \
232232
blk_add_trace_msg(__td->queue, "throtl " fmt, ##args); \
233233
} \

include/linux/blktrace_api.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ struct blk_trace {
2727
atomic_t dropped;
2828
};
2929

30-
struct blkcg;
31-
3230
extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
3331
extern void blk_trace_shutdown(struct request_queue *);
34-
extern __printf(3, 4)
35-
void __trace_note_message(struct blk_trace *, struct blkcg *blkcg, const char *fmt, ...);
32+
__printf(3, 4) void __blk_trace_note_message(struct blk_trace *bt,
33+
struct cgroup_subsys_state *css, const char *fmt, ...);
3634

3735
/**
3836
* blk_add_trace_msg - Add a (simple) message to the blktrace stream
@@ -47,14 +45,14 @@ void __trace_note_message(struct blk_trace *, struct blkcg *blkcg, const char *f
4745
* NOTE: Can not use 'static inline' due to presence of var args...
4846
*
4947
**/
50-
#define blk_add_cgroup_trace_msg(q, cg, fmt, ...) \
48+
#define blk_add_cgroup_trace_msg(q, css, fmt, ...) \
5149
do { \
5250
struct blk_trace *bt; \
5351
\
5452
rcu_read_lock(); \
5553
bt = rcu_dereference((q)->blk_trace); \
5654
if (unlikely(bt)) \
57-
__trace_note_message(bt, cg, fmt, ##__VA_ARGS__);\
55+
__blk_trace_note_message(bt, css, fmt, ##__VA_ARGS__);\
5856
rcu_read_unlock(); \
5957
} while (0)
6058
#define blk_add_trace_msg(q, fmt, ...) \

kernel/trace/blktrace.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,14 @@ static void trace_note_time(struct blk_trace *bt)
145145
local_irq_restore(flags);
146146
}
147147

148-
void __trace_note_message(struct blk_trace *bt, struct blkcg *blkcg,
149-
const char *fmt, ...)
148+
void __blk_trace_note_message(struct blk_trace *bt,
149+
struct cgroup_subsys_state *css, const char *fmt, ...)
150150
{
151151
int n;
152152
va_list args;
153153
unsigned long flags;
154154
char *buf;
155+
u64 cgid = 0;
155156

156157
if (unlikely(bt->trace_state != Blktrace_running &&
157158
!blk_tracer_enabled))
@@ -170,17 +171,16 @@ void __trace_note_message(struct blk_trace *bt, struct blkcg *blkcg,
170171
n = vscnprintf(buf, BLK_TN_MAX_MSG, fmt, args);
171172
va_end(args);
172173

173-
if (!(blk_tracer_flags.val & TRACE_BLK_OPT_CGROUP))
174-
blkcg = NULL;
175174
#ifdef CONFIG_BLK_CGROUP
176-
trace_note(bt, current->pid, BLK_TN_MESSAGE, buf, n,
177-
blkcg ? cgroup_id(blkcg->css.cgroup) : 1);
178-
#else
179-
trace_note(bt, current->pid, BLK_TN_MESSAGE, buf, n, 0);
175+
if (css && (blk_tracer_flags.val & TRACE_BLK_OPT_CGROUP))
176+
cgid = cgroup_id(css->cgroup);
177+
else
178+
cgid = 1;
180179
#endif
180+
trace_note(bt, current->pid, BLK_TN_MESSAGE, buf, n, cgid);
181181
local_irq_restore(flags);
182182
}
183-
EXPORT_SYMBOL_GPL(__trace_note_message);
183+
EXPORT_SYMBOL_GPL(__blk_trace_note_message);
184184

185185
static int act_log_check(struct blk_trace *bt, u32 what, sector_t sector,
186186
pid_t pid)
@@ -411,7 +411,7 @@ static ssize_t blk_msg_write(struct file *filp, const char __user *buffer,
411411
return PTR_ERR(msg);
412412

413413
bt = filp->private_data;
414-
__trace_note_message(bt, NULL, "%s", msg);
414+
__blk_trace_note_message(bt, NULL, "%s", msg);
415415
kfree(msg);
416416

417417
return count;

0 commit comments

Comments
 (0)