linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block,bfq: Skip tracing hooks if possible
@ 2019-11-01 13:11 Dmitry Monakhov
  2019-11-15  6:47 ` Paolo Valente
  2019-11-20 23:11 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Monakhov @ 2019-11-01 13:11 UTC (permalink / raw)
  To: linux-kernel; +Cc: axboe, paolo.valente, 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
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% |

Signed-off-by: Dmitry Monakhov <dmonakhov@gmail.com>
---
 block/bfq-iosched.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
index 5d1a519..b320fe9 100644
--- a/block/bfq-iosched.h
+++ b/block/bfq-iosched.h
@@ -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',		\
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] block,bfq: Skip tracing hooks if possible
  2019-11-01 13:11 [PATCH] block,bfq: Skip tracing hooks if possible Dmitry Monakhov
@ 2019-11-15  6:47 ` Paolo Valente
  2019-11-20 23:11 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Valente @ 2019-11-15  6:47 UTC (permalink / raw)
  To: Dmitry Monakhov; +Cc: linux-kernel, axboe



> Il giorno 1 nov 2019, alle ore 14:11, Dmitry Monakhov <dmonakhov@gmail.com> 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
> 
> # Results
> |        | baseline | w/ patch | gain |
> | iops   | 113.19K  | 126.42K  | +11% |
> 

Thank you very much for this simple yet effective improvement.

Acked-by: Paolo Valente <paolo.valente@linaro.org>

> Signed-off-by: Dmitry Monakhov <dmonakhov@gmail.com>
> ---
> block/bfq-iosched.h | 4 ++++
> 1 file changed, 4 insertions(+)
> 
> diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
> index 5d1a519..b320fe9 100644
> --- a/block/bfq-iosched.h
> +++ b/block/bfq-iosched.h
> @@ -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',		\
> -- 
> 2.7.4
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block,bfq: Skip tracing hooks if possible
  2019-11-01 13:11 [PATCH] block,bfq: Skip tracing hooks if possible Dmitry Monakhov
  2019-11-15  6:47 ` Paolo Valente
@ 2019-11-20 23:11 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2019-11-20 23:11 UTC (permalink / raw)
  To: Dmitry Monakhov, linux-kernel; +Cc: paolo.valente

On 11/1/19 7:11 AM, Dmitry Monakhov wrote:
> 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% |

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-21  1:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-01 13:11 [PATCH] block,bfq: Skip tracing hooks if possible Dmitry Monakhov
2019-11-15  6:47 ` Paolo Valente
2019-11-20 23:11 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).