Skip to contentSkip to conversation

block,bfq: Skip tracing hooks if possible

PATCH Applied Dmitry Monakhov 3 participants 3 messages Nov 1, 2019 – Nov 21, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block,bfq: Skip tracing hooks if possible

In most cases blk_tracing is not active, but bfq_log_bfqq macro generate pid_str unconditionally, which result in significant overhead.

## Test
modprobe null_blk
echo bfq > /sys/block/nullb0/queue/scheduler
fio --name=t --ioengine=libaio --direct=1 --filename=/dev/nullb0 \
--runtime=30 --time_based=1 --rw=write --iodepth=128 --bs=4k

# Results

|        | baseline | w/ patch | gain |
| iops   | 113.19K  | 126.42K  | +11% |
---
 block/bfq-iosched.h | 4 ++++
 1 file changed, 4 insertions(+)
block/bfq-iosched.h +4 -0
index 5d1a519..b320fe9 100644
@@ -1062,6 +1062,8 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq);
 
 #define bfq_log_bfqq(bfqd, bfqq, fmt, args...)	do {			\
 	char pid_str[MAX_PID_STR_LENGTH];	\
+	if (likely(!blk_trace_note_message_enabled((bfqd)->queue)))	\
+		break;							\
 	bfq_pid_to_str((bfqq)->pid, pid_str, MAX_PID_STR_LENGTH);	\
 	blk_add_cgroup_trace_msg((bfqd)->queue,				\
 			bfqg_to_blkg(bfqq_group(bfqq))->blkcg,		\
@@ -1078,6 +1080,8 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq);
 
 #define bfq_log_bfqq(bfqd, bfqq, fmt, args...) do {	\
 	char pid_str[MAX_PID_STR_LENGTH];	\
+	if (likely(!blk_trace_note_message_enabled((bfqd)->queue)))	\
+		break;							\
 	bfq_pid_to_str((bfqq)->pid, pid_str, MAX_PID_STR_LENGTH);	\
 	blk_add_trace_msg((bfqd)->queue, "bfq%s%c " fmt, pid_str,	\
 			bfq_bfqq_sync((bfqq)) ? 'S' : 'A',		\
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines

Il giorno 1 nov 2019, alle ore 14:11, Dmitry Monakhov <[email protected]> ha scritto:

In most cases blk_tracing is not active, but bfq_log_bfqq macro generate pid_str unconditionally, which result in significant overhead.

## Test
modprobe null_blk
echo bfq > /sys/block/nullb0/queue/scheduler
fio --name=t --ioengine=libaio --direct=1 --filename=/dev/nullb0 \
--runtime=30 --time_based=1 --rw=write --iodepth=128 --bs=4k

Quoted 4 lines

# Results

|        | baseline | w/ patch | gain |
| iops   | 113.19K  | 126.42K  | +11% |

Thank you very much for this simple yet effective improvement.

Quoted 30 lines

---
block/bfq-iosched.h | 4 ++++

1 file changed, 4 insertions(+)
block/bfq-iosched.h +4 -0
index 5d1a519..b320fe9 100644
@@ -1062,6 +1062,8 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq);
 
 #define bfq_log_bfqq(bfqd, bfqq, fmt, args...)	do {			\
 	char pid_str[MAX_PID_STR_LENGTH];	\
+	if (likely(!blk_trace_note_message_enabled((bfqd)->queue)))	\
+		break;							\
 	bfq_pid_to_str((bfqq)->pid, pid_str, MAX_PID_STR_LENGTH);	\
 	blk_add_cgroup_trace_msg((bfqd)->queue,				\
 			bfqg_to_blkg(bfqq_group(bfqq))->blkcg,		\
@@ -1078,6 +1080,8 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq);
 
 #define bfq_log_bfqq(bfqd, bfqq, fmt, args...) do {	\
 	char pid_str[MAX_PID_STR_LENGTH];	\
+	if (likely(!blk_trace_note_message_enabled((bfqd)->queue)))	\
+		break;							\
 	bfq_pid_to_str((bfqq)->pid, pid_str, MAX_PID_STR_LENGTH);	\
 	blk_add_trace_msg((bfqd)->queue, "bfq%s%c " fmt, pid_str,	\
 			bfq_bfqq_sync((bfqq)) ? 'S' : 'A',		\
Signature · 1 line
2.7.4
maintainer Applied
#2 lore raw
In reply to Dmitry Monakhov
Quoted 6 lines · Dmitry Monakhov

In most cases blk_tracing is not active, but bfq_log_bfqq macro generate pid_str unconditionally, which result in significant overhead.

## Test
modprobe null_blk
echo bfq > /sys/block/nullb0/queue/scheduler

Quoted 6 lines
fio --name=t --ioengine=libaio --direct=1 --filename=/dev/nullb0 \
    --runtime=30 --time_based=1 --rw=write --iodepth=128 --bs=4k

# Results

|        | baseline | w/ patch | gain |
| iops   | 113.19K  | 126.42K  | +11% |

Applied, thanks.

Signature · 1 line
Jens Axboe