* [PATCH] dm mpath: fixup sched_clock() usage in historical selector
@ 2022-04-11 22:03 Khazhismel Kumykov
2022-04-11 23:48 ` Gabriel Krisman Bertazi
0 siblings, 1 reply; 2+ messages in thread
From: Khazhismel Kumykov @ 2022-04-11 22:03 UTC (permalink / raw)
To: Mike Snitzer, Alasdair Kergon
Cc: dm-devel, Khazhismel Kumykov, Gabriel Krisman Bertazi, linux-kernel
mixing sched_clock() and ktime_get_ns() will give bad results, don't do
it
Fixes: 2613eab11996 ("dm mpath: add Historical Service Time Path Selector")
Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
---
drivers/md/dm-ps-historical-service-time.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/md/dm-ps-historical-service-time.c b/drivers/md/dm-ps-historical-service-time.c
index 875bca30a0dd..82f2a06153dc 100644
--- a/drivers/md/dm-ps-historical-service-time.c
+++ b/drivers/md/dm-ps-historical-service-time.c
@@ -27,7 +27,6 @@
#include <linux/blkdev.h>
#include <linux/slab.h>
#include <linux/module.h>
-#include <linux/sched/clock.h>
#define DM_MSG_PREFIX "multipath historical-service-time"
@@ -433,7 +432,7 @@ static struct dm_path *hst_select_path(struct path_selector *ps,
{
struct selector *s = ps->context;
struct path_info *pi = NULL, *best = NULL;
- u64 time_now = sched_clock();
+ u64 time_now = ktime_get_ns();
struct dm_path *ret = NULL;
unsigned long flags;
@@ -474,7 +473,7 @@ static int hst_start_io(struct path_selector *ps, struct dm_path *path,
static u64 path_service_time(struct path_info *pi, u64 start_time)
{
- u64 sched_now = ktime_get_ns();
+ u64 now = ktime_get_ns();
/* if a previous disk request has finished after this IO was
* sent to the hardware, pretend the submission happened
@@ -483,11 +482,11 @@ static u64 path_service_time(struct path_info *pi, u64 start_time)
if (time_after64(pi->last_finish, start_time))
start_time = pi->last_finish;
- pi->last_finish = sched_now;
- if (time_before64(sched_now, start_time))
+ pi->last_finish = now;
+ if (time_before64(now, start_time))
return 0;
- return sched_now - start_time;
+ return now - start_time;
}
static int hst_end_io(struct path_selector *ps, struct dm_path *path,
--
2.35.1.1178.g4f1659d476-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dm mpath: fixup sched_clock() usage in historical selector
2022-04-11 22:03 [PATCH] dm mpath: fixup sched_clock() usage in historical selector Khazhismel Kumykov
@ 2022-04-11 23:48 ` Gabriel Krisman Bertazi
0 siblings, 0 replies; 2+ messages in thread
From: Gabriel Krisman Bertazi @ 2022-04-11 23:48 UTC (permalink / raw)
To: Khazhismel Kumykov; +Cc: Mike Snitzer, Alasdair Kergon, dm-devel, linux-kernel
Khazhismel Kumykov <khazhy@google.com> writes:
> mixing sched_clock() and ktime_get_ns() will give bad results, don't do
> it
>
> Fixes: 2613eab11996 ("dm mpath: add Historical Service Time Path Selector")
> Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
Looks good.
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
> ---
> drivers/md/dm-ps-historical-service-time.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/md/dm-ps-historical-service-time.c b/drivers/md/dm-ps-historical-service-time.c
> index 875bca30a0dd..82f2a06153dc 100644
> --- a/drivers/md/dm-ps-historical-service-time.c
> +++ b/drivers/md/dm-ps-historical-service-time.c
> @@ -27,7 +27,6 @@
> #include <linux/blkdev.h>
> #include <linux/slab.h>
> #include <linux/module.h>
> -#include <linux/sched/clock.h>
>
>
> #define DM_MSG_PREFIX "multipath historical-service-time"
> @@ -433,7 +432,7 @@ static struct dm_path *hst_select_path(struct path_selector *ps,
> {
> struct selector *s = ps->context;
> struct path_info *pi = NULL, *best = NULL;
> - u64 time_now = sched_clock();
> + u64 time_now = ktime_get_ns();
> struct dm_path *ret = NULL;
> unsigned long flags;
>
> @@ -474,7 +473,7 @@ static int hst_start_io(struct path_selector *ps, struct dm_path *path,
>
> static u64 path_service_time(struct path_info *pi, u64 start_time)
> {
> - u64 sched_now = ktime_get_ns();
> + u64 now = ktime_get_ns();
>
> /* if a previous disk request has finished after this IO was
> * sent to the hardware, pretend the submission happened
> @@ -483,11 +482,11 @@ static u64 path_service_time(struct path_info *pi, u64 start_time)
> if (time_after64(pi->last_finish, start_time))
> start_time = pi->last_finish;
>
> - pi->last_finish = sched_now;
> - if (time_before64(sched_now, start_time))
> + pi->last_finish = now;
> + if (time_before64(now, start_time))
> return 0;
>
> - return sched_now - start_time;
> + return now - start_time;
> }
>
> static int hst_end_io(struct path_selector *ps, struct dm_path *path,
--
Gabriel Krisman Bertazi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-11 23:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11 22:03 [PATCH] dm mpath: fixup sched_clock() usage in historical selector Khazhismel Kumykov
2022-04-11 23:48 ` Gabriel Krisman Bertazi
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).