From 479ed3e13994141b42b5c650a07aa2043c79f21c Mon Sep 17 00:00:00 2001 From: Omar Sandoval Date: Mon, 23 Jul 2018 17:33:08 +0300 Subject: BACKPORT: block: use ktime_get_ns() instead of sched_clock() for cfq cfq has some internal fields that use sched_clock() which can trivially use ktime_get_ns() instead. Their timestamp fields in struct request can also use ktime_get_ns(), which resolves the 8 year old comment added by commit 28f4197e5d47 ("block: disable preemption before using sched_clock()"). Signed-off-by: Omar Sandoval Signed-off-by: Jens Axboe Signed-off-by: celtare21 Signed-off-by: Yaroslav Furman - improved comment. --- include/linux/blkdev.h | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'include/linux/blkdev.h') diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 8ba034b90e9b..0d6082119489 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1453,42 +1453,33 @@ int kblockd_schedule_delayed_work(struct delayed_work *dwork, unsigned long dela int kblockd_schedule_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay); #ifdef CONFIG_BLK_CGROUP -/* - * This should not be using sched_clock(). A real patch is in progress - * to fix this up, until that is in place we need to disable preemption - * around sched_clock() in this function and set_io_start_time_ns(). - */ static inline void set_start_time_ns(struct request *req) { - preempt_disable(); - req->start_time_ns = sched_clock(); - preempt_enable(); + req->start_time_ns = ktime_get_ns(); } static inline void set_io_start_time_ns(struct request *req) { - preempt_disable(); - req->io_start_time_ns = sched_clock(); - preempt_enable(); + req->io_start_time_ns = ktime_get_ns(); } -static inline uint64_t rq_start_time_ns(struct request *req) +static inline u64 rq_start_time_ns(struct request *req) { return req->start_time_ns; } -static inline uint64_t rq_io_start_time_ns(struct request *req) +static inline u64 rq_io_start_time_ns(struct request *req) { return req->io_start_time_ns; } #else static inline void set_start_time_ns(struct request *req) {} static inline void set_io_start_time_ns(struct request *req) {} -static inline uint64_t rq_start_time_ns(struct request *req) +static inline u64 rq_start_time_ns(struct request *req) { return 0; } -static inline uint64_t rq_io_start_time_ns(struct request *req) +static inline u64 rq_io_start_time_ns(struct request *req) { return 0; } -- cgit v1.2.3