* [PATCH] blk-iolatency:postpone ktime_get() execution until blk_iolatency_enabled() return true
@ 2020-07-01 6:04 Hongnan Li
2020-07-01 7:52 ` Johannes Thumshirn
0 siblings, 1 reply; 2+ messages in thread
From: Hongnan Li @ 2020-07-01 6:04 UTC (permalink / raw)
To: linux-block; +Cc: axboe, Hongnan Li
ktime_to_ns(ktime_get()) which is expensive do not need to be executed if
blk_iolatency_enabled() return false in blkcg_iolatency_done_bio().
Postponing ktime_to_ns(ktime_get()) execution can reduce CPU usage
when blk_iolatency was disabled.
Signed-off-by: Hongnan Li <hongnan.li@linux.alibaba.com>
---
block/blk-iolatency.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
index c128d50..8c1487e 100644
--- a/block/blk-iolatency.c
+++ b/block/blk-iolatency.c
@@ -591,7 +591,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio)
struct rq_wait *rqw;
struct iolatency_grp *iolat;
u64 window_start;
- u64 now = ktime_to_ns(ktime_get());
+
bool issue_as_root = bio_issue_as_root_blkg(bio);
bool enabled = false;
int inflight = 0;
@@ -608,6 +608,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio)
if (!enabled)
return;
+ u64 now = ktime_to_ns(ktime_get());
while (blkg && blkg->parent) {
iolat = blkg_to_lat(blkg);
if (!iolat) {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] blk-iolatency:postpone ktime_get() execution until blk_iolatency_enabled() return true
2020-07-01 6:04 [PATCH] blk-iolatency:postpone ktime_get() execution until blk_iolatency_enabled() return true Hongnan Li
@ 2020-07-01 7:52 ` Johannes Thumshirn
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Thumshirn @ 2020-07-01 7:52 UTC (permalink / raw)
To: Hongnan Li, linux-block; +Cc: axboe
On 01/07/2020 08:05, Hongnan Li wrote:
> ktime_to_ns(ktime_get()) which is expensive do not need to be executed if
> blk_iolatency_enabled() return false in blkcg_iolatency_done_bio().
> Postponing ktime_to_ns(ktime_get()) execution can reduce CPU usage
> when blk_iolatency was disabled.
>
> Signed-off-by: Hongnan Li <hongnan.li@linux.alibaba.com>
> ---
> block/blk-iolatency.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
> index c128d50..8c1487e 100644
> --- a/block/blk-iolatency.c
> +++ b/block/blk-iolatency.c
> @@ -591,7 +591,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio)
> struct rq_wait *rqw;
> struct iolatency_grp *iolat;
> u64 window_start;
> - u64 now = ktime_to_ns(ktime_get());
> +
> bool issue_as_root = bio_issue_as_root_blkg(bio);
> bool enabled = false;
> int inflight = 0;
> @@ -608,6 +608,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio)
> if (!enabled)
> return;
>
> + u64 now = ktime_to_ns(ktime_get());
> while (blkg && blkg->parent) {
> iolat = blkg_to_lat(blkg);
> if (!iolat) {
>
You're mixing declarations and code.
please do
- u64 now = ktime_to_ns(ktime_get());
+ u64 now;
[...]
+ now = ktime_to_ns(ktime_get());
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-01 7:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01 6:04 [PATCH] blk-iolatency:postpone ktime_get() execution until blk_iolatency_enabled() return true Hongnan Li
2020-07-01 7:52 ` Johannes Thumshirn
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).