2020-04-21 20:13:52 +00:00
|
|
|
From 9a9c6744f1401c493421737e4069babc9029adb4 Mon Sep 17 00:00:00 2001
|
2018-08-27 14:32:32 +00:00
|
|
|
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
2019-04-08 23:49:20 +00:00
|
|
|
Date: Tue, 3 Jul 2018 11:25:41 +0200
|
2020-04-21 20:13:52 +00:00
|
|
|
Subject: [PATCH 098/325] hrtimer: consolidate hrtimer_init() +
|
2019-04-08 23:49:20 +00:00
|
|
|
hrtimer_init_sleeper() calls
|
2020-04-21 20:13:52 +00:00
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.115-rt48.tar.xz
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
hrtimer_init_sleeper() calls require a prior initialisation of the
|
|
|
|
hrtimer object with hrtimer_init(). Lets make the initialisation of
|
|
|
|
the hrtimer object part of hrtimer_init_sleeper(). To remain
|
|
|
|
consistent consider init_on_stack as well.
|
|
|
|
|
|
|
|
Beside adapting the hrtimer_init_sleeper[_on_stack]() functions, call
|
|
|
|
sites need to be updated as well.
|
|
|
|
|
2018-08-31 15:16:36 +00:00
|
|
|
Link: http://lkml.kernel.org/r/20180703092541.2870-1-anna-maria@linutronix.de
|
2018-08-27 14:32:32 +00:00
|
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
2018-08-31 15:16:36 +00:00
|
|
|
[anna-maria: Updating the commit message, add staging/android/vsoc.c]
|
|
|
|
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
|
2018-08-27 14:32:32 +00:00
|
|
|
---
|
2019-04-08 23:49:20 +00:00
|
|
|
block/blk-mq.c | 3 +--
|
|
|
|
drivers/staging/android/vsoc.c | 6 ++---
|
|
|
|
include/linux/hrtimer.h | 19 +++++++++++---
|
|
|
|
include/linux/wait.h | 4 +--
|
|
|
|
kernel/futex.c | 19 ++++++--------
|
|
|
|
kernel/time/hrtimer.c | 46 ++++++++++++++++++++++++++--------
|
|
|
|
net/core/pktgen.c | 4 +--
|
2018-08-31 15:16:36 +00:00
|
|
|
7 files changed, 67 insertions(+), 34 deletions(-)
|
2018-08-27 14:32:32 +00:00
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/block/blk-mq.c b/block/blk-mq.c
|
2019-11-25 00:04:39 +00:00
|
|
|
index 684acaa96db7..4aa3284874f6 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/block/blk-mq.c
|
|
|
|
+++ b/block/blk-mq.c
|
2019-08-18 21:33:52 +00:00
|
|
|
@@ -3128,10 +3128,9 @@ static bool blk_mq_poll_hybrid_sleep(struct request_queue *q,
|
2018-08-27 14:32:32 +00:00
|
|
|
kt = nsecs;
|
|
|
|
|
|
|
|
mode = HRTIMER_MODE_REL;
|
|
|
|
- hrtimer_init_on_stack(&hs.timer, CLOCK_MONOTONIC, mode);
|
|
|
|
+ hrtimer_init_sleeper_on_stack(&hs, CLOCK_MONOTONIC, mode, current);
|
|
|
|
hrtimer_set_expires(&hs.timer, kt);
|
|
|
|
|
|
|
|
- hrtimer_init_sleeper(&hs, current);
|
|
|
|
do {
|
|
|
|
if (blk_mq_rq_state(rq) == MQ_RQ_COMPLETE)
|
|
|
|
break;
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/drivers/staging/android/vsoc.c b/drivers/staging/android/vsoc.c
|
2020-02-21 18:07:43 +00:00
|
|
|
index 034d86869772..d089b2cb5dd7 100644
|
2018-08-31 15:16:36 +00:00
|
|
|
--- a/drivers/staging/android/vsoc.c
|
|
|
|
+++ b/drivers/staging/android/vsoc.c
|
2020-02-21 18:07:43 +00:00
|
|
|
@@ -438,12 +438,10 @@ static int handle_vsoc_cond_wait(struct file *filp, struct vsoc_cond_wait *arg)
|
2018-08-31 15:16:36 +00:00
|
|
|
return -EINVAL;
|
2018-10-30 12:40:05 +00:00
|
|
|
wake_time = ktime_set(arg->wake_time_sec, arg->wake_time_nsec);
|
|
|
|
|
2018-08-31 15:16:36 +00:00
|
|
|
- hrtimer_init_on_stack(&to->timer, CLOCK_MONOTONIC,
|
|
|
|
- HRTIMER_MODE_ABS);
|
|
|
|
+ hrtimer_init_sleeper_on_stack(to, CLOCK_MONOTONIC,
|
|
|
|
+ HRTIMER_MODE_ABS, current);
|
2018-10-30 12:40:05 +00:00
|
|
|
hrtimer_set_expires_range_ns(&to->timer, wake_time,
|
2018-08-31 15:16:36 +00:00
|
|
|
current->timer_slack_ns);
|
|
|
|
-
|
|
|
|
- hrtimer_init_sleeper(to, current);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (1) {
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
|
2020-01-19 00:54:59 +00:00
|
|
|
index 542b4fa2cda9..cbd041b22088 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/include/linux/hrtimer.h
|
|
|
|
+++ b/include/linux/hrtimer.h
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -364,10 +364,17 @@ DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
|
2018-08-27 14:32:32 +00:00
|
|
|
/* Initialize timers: */
|
|
|
|
extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
|
|
|
|
enum hrtimer_mode mode);
|
|
|
|
+extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, clockid_t clock_id,
|
|
|
|
+ enum hrtimer_mode mode,
|
|
|
|
+ struct task_struct *task);
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
|
|
|
|
extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_clock,
|
|
|
|
enum hrtimer_mode mode);
|
|
|
|
+extern void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
|
|
|
|
+ clockid_t clock_id,
|
|
|
|
+ enum hrtimer_mode mode,
|
|
|
|
+ struct task_struct *task);
|
|
|
|
|
|
|
|
extern void destroy_hrtimer_on_stack(struct hrtimer *timer);
|
|
|
|
#else
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -377,6 +384,15 @@ static inline void hrtimer_init_on_stack(struct hrtimer *timer,
|
2018-08-27 14:32:32 +00:00
|
|
|
{
|
|
|
|
hrtimer_init(timer, which_clock, mode);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+static inline void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
|
|
|
|
+ clockid_t clock_id,
|
|
|
|
+ enum hrtimer_mode mode,
|
|
|
|
+ struct task_struct *task)
|
|
|
|
+{
|
|
|
|
+ hrtimer_init_sleeper(sl, clock_id, mode, task);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
|
|
|
|
#endif
|
|
|
|
|
2020-01-19 00:54:59 +00:00
|
|
|
@@ -486,9 +502,6 @@ extern long hrtimer_nanosleep(const struct timespec64 *rqtp,
|
2018-08-27 14:32:32 +00:00
|
|
|
const enum hrtimer_mode mode,
|
|
|
|
const clockid_t clockid);
|
|
|
|
|
|
|
|
-extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
|
|
|
|
- struct task_struct *tsk);
|
|
|
|
-
|
|
|
|
extern int schedule_hrtimeout_range(ktime_t *expires, u64 delta,
|
|
|
|
const enum hrtimer_mode mode);
|
|
|
|
extern int schedule_hrtimeout_range_clock(ktime_t *expires,
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/include/linux/wait.h b/include/linux/wait.h
|
|
|
|
index 2b5ef8e94d19..94bd2e841de6 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/include/linux/wait.h
|
|
|
|
+++ b/include/linux/wait.h
|
|
|
|
@@ -489,8 +489,8 @@ do { \
|
|
|
|
int __ret = 0; \
|
|
|
|
struct hrtimer_sleeper __t; \
|
|
|
|
\
|
|
|
|
- hrtimer_init_on_stack(&__t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); \
|
|
|
|
- hrtimer_init_sleeper(&__t, current); \
|
|
|
|
+ hrtimer_init_sleeper_on_stack(&__t, CLOCK_MONOTONIC, HRTIMER_MODE_REL, \
|
|
|
|
+ current); \
|
|
|
|
if ((timeout) != KTIME_MAX) \
|
|
|
|
hrtimer_start_range_ns(&__t.timer, timeout, \
|
|
|
|
current->timer_slack_ns, \
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/kernel/futex.c b/kernel/futex.c
|
2020-04-21 20:13:52 +00:00
|
|
|
index 32f9e3fa8c46..a8081f82579e 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/kernel/futex.c
|
|
|
|
+++ b/kernel/futex.c
|
2020-04-21 20:13:52 +00:00
|
|
|
@@ -2721,10 +2721,9 @@ static int futex_wait(u32 __user *uaddr, unsigned int flags, u32 val,
|
2018-08-27 14:32:32 +00:00
|
|
|
if (abs_time) {
|
|
|
|
to = &timeout;
|
|
|
|
|
|
|
|
- hrtimer_init_on_stack(&to->timer, (flags & FLAGS_CLOCKRT) ?
|
|
|
|
- CLOCK_REALTIME : CLOCK_MONOTONIC,
|
|
|
|
- HRTIMER_MODE_ABS);
|
|
|
|
- hrtimer_init_sleeper(to, current);
|
|
|
|
+ hrtimer_init_sleeper_on_stack(to, (flags & FLAGS_CLOCKRT) ?
|
|
|
|
+ CLOCK_REALTIME : CLOCK_MONOTONIC,
|
|
|
|
+ HRTIMER_MODE_ABS, current);
|
|
|
|
hrtimer_set_expires_range_ns(&to->timer, *abs_time,
|
|
|
|
current->timer_slack_ns);
|
|
|
|
}
|
2020-04-21 20:13:52 +00:00
|
|
|
@@ -2823,9 +2822,8 @@ static int futex_lock_pi(u32 __user *uaddr, unsigned int flags,
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
if (time) {
|
|
|
|
to = &timeout;
|
|
|
|
- hrtimer_init_on_stack(&to->timer, CLOCK_REALTIME,
|
|
|
|
- HRTIMER_MODE_ABS);
|
|
|
|
- hrtimer_init_sleeper(to, current);
|
|
|
|
+ hrtimer_init_sleeper_on_stack(to, CLOCK_REALTIME,
|
|
|
|
+ HRTIMER_MODE_ABS, current);
|
|
|
|
hrtimer_set_expires(&to->timer, *time);
|
|
|
|
}
|
|
|
|
|
2020-04-21 20:13:52 +00:00
|
|
|
@@ -3262,10 +3260,9 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
if (abs_time) {
|
|
|
|
to = &timeout;
|
|
|
|
- hrtimer_init_on_stack(&to->timer, (flags & FLAGS_CLOCKRT) ?
|
|
|
|
- CLOCK_REALTIME : CLOCK_MONOTONIC,
|
|
|
|
- HRTIMER_MODE_ABS);
|
|
|
|
- hrtimer_init_sleeper(to, current);
|
|
|
|
+ hrtimer_init_sleeper_on_stack(to, (flags & FLAGS_CLOCKRT) ?
|
|
|
|
+ CLOCK_REALTIME : CLOCK_MONOTONIC,
|
|
|
|
+ HRTIMER_MODE_ABS, current);
|
|
|
|
hrtimer_set_expires_range_ns(&to->timer, *abs_time,
|
|
|
|
current->timer_slack_ns);
|
|
|
|
}
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
|
2020-01-19 00:54:59 +00:00
|
|
|
index 7362554416fd..c6f755495a63 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/kernel/time/hrtimer.c
|
|
|
|
+++ b/kernel/time/hrtimer.c
|
2020-01-19 00:54:59 +00:00
|
|
|
@@ -1651,13 +1651,44 @@ static enum hrtimer_restart hrtimer_wakeup(struct hrtimer *timer)
|
2018-08-27 14:32:32 +00:00
|
|
|
return HRTIMER_NORESTART;
|
|
|
|
}
|
|
|
|
|
|
|
|
-void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, struct task_struct *task)
|
|
|
|
+static void __hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
|
|
|
|
+ clockid_t clock_id,
|
|
|
|
+ enum hrtimer_mode mode,
|
|
|
|
+ struct task_struct *task)
|
|
|
|
{
|
|
|
|
+ __hrtimer_init(&sl->timer, clock_id, mode);
|
|
|
|
sl->timer.function = hrtimer_wakeup;
|
|
|
|
sl->task = task;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * hrtimer_init_sleeper - initialize sleeper to the given clock
|
|
|
|
+ * @sl: sleeper to be initialized
|
|
|
|
+ * @clock_id: the clock to be used
|
|
|
|
+ * @mode: timer mode abs/rel
|
|
|
|
+ * @task: the task to wake up
|
|
|
|
+ */
|
|
|
|
+void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, clockid_t clock_id,
|
|
|
|
+ enum hrtimer_mode mode, struct task_struct *task)
|
|
|
|
+{
|
|
|
|
+ debug_init(&sl->timer, clock_id, mode);
|
|
|
|
+ __hrtimer_init_sleeper(sl, clock_id, mode, task);
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
EXPORT_SYMBOL_GPL(hrtimer_init_sleeper);
|
|
|
|
|
|
|
|
+#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
|
|
|
|
+void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
|
|
|
|
+ clockid_t clock_id,
|
|
|
|
+ enum hrtimer_mode mode,
|
|
|
|
+ struct task_struct *task)
|
|
|
|
+{
|
|
|
|
+ debug_object_init_on_stack(&sl->timer, &hrtimer_debug_descr);
|
|
|
|
+ __hrtimer_init_sleeper(sl, clock_id, mode, task);
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL_GPL(hrtimer_init_sleeper_on_stack);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts)
|
|
|
|
{
|
|
|
|
switch(restart->nanosleep.type) {
|
2020-01-19 00:54:59 +00:00
|
|
|
@@ -1681,8 +1712,6 @@ static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mod
|
2018-08-27 14:32:32 +00:00
|
|
|
{
|
|
|
|
struct restart_block *restart;
|
|
|
|
|
|
|
|
- hrtimer_init_sleeper(t, current);
|
|
|
|
-
|
|
|
|
do {
|
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
|
|
|
hrtimer_start_expires(&t->timer, mode);
|
2020-01-19 00:54:59 +00:00
|
|
|
@@ -1719,10 +1748,9 @@ static long __sched hrtimer_nanosleep_restart(struct restart_block *restart)
|
2018-08-27 14:32:32 +00:00
|
|
|
struct hrtimer_sleeper t;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
- hrtimer_init_on_stack(&t.timer, restart->nanosleep.clockid,
|
|
|
|
- HRTIMER_MODE_ABS);
|
|
|
|
+ hrtimer_init_sleeper_on_stack(&t, restart->nanosleep.clockid,
|
|
|
|
+ HRTIMER_MODE_ABS, current);
|
|
|
|
hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires);
|
|
|
|
-
|
|
|
|
ret = do_nanosleep(&t, HRTIMER_MODE_ABS);
|
|
|
|
destroy_hrtimer_on_stack(&t.timer);
|
|
|
|
return ret;
|
2020-01-19 00:54:59 +00:00
|
|
|
@@ -1740,7 +1768,7 @@ long hrtimer_nanosleep(const struct timespec64 *rqtp,
|
2018-08-27 14:32:32 +00:00
|
|
|
if (dl_task(current) || rt_task(current))
|
|
|
|
slack = 0;
|
|
|
|
|
|
|
|
- hrtimer_init_on_stack(&t.timer, clockid, mode);
|
|
|
|
+ hrtimer_init_sleeper_on_stack(&t, clockid, mode, current);
|
|
|
|
hrtimer_set_expires_range_ns(&t.timer, timespec64_to_ktime(*rqtp), slack);
|
|
|
|
ret = do_nanosleep(&t, mode);
|
|
|
|
if (ret != -ERESTART_RESTARTBLOCK)
|
2020-01-19 00:54:59 +00:00
|
|
|
@@ -1939,11 +1967,9 @@ schedule_hrtimeout_range_clock(ktime_t *expires, u64 delta,
|
2018-08-27 14:32:32 +00:00
|
|
|
return -EINTR;
|
|
|
|
}
|
|
|
|
|
|
|
|
- hrtimer_init_on_stack(&t.timer, clock_id, mode);
|
|
|
|
+ hrtimer_init_sleeper_on_stack(&t, clock_id, mode, current);
|
|
|
|
hrtimer_set_expires_range_ns(&t.timer, *expires, delta);
|
|
|
|
|
|
|
|
- hrtimer_init_sleeper(&t, current);
|
|
|
|
-
|
|
|
|
hrtimer_start_expires(&t.timer, mode);
|
|
|
|
|
|
|
|
if (likely(t.task))
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
|
2019-08-18 21:33:52 +00:00
|
|
|
index 092fa3d75b32..9d472d626aaa 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/net/core/pktgen.c
|
|
|
|
+++ b/net/core/pktgen.c
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -2160,7 +2160,8 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
|
2018-08-27 14:32:32 +00:00
|
|
|
s64 remaining;
|
|
|
|
struct hrtimer_sleeper t;
|
|
|
|
|
|
|
|
- hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
|
|
|
|
+ hrtimer_init_sleeper_on_stack(&t, CLOCK_MONOTONIC, HRTIMER_MODE_ABS,
|
|
|
|
+ current);
|
|
|
|
hrtimer_set_expires(&t.timer, spin_until);
|
|
|
|
|
|
|
|
remaining = ktime_to_ns(hrtimer_expires_remaining(&t.timer));
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -2175,7 +2176,6 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
|
2018-08-27 14:32:32 +00:00
|
|
|
} while (ktime_compare(end_time, spin_until) < 0);
|
|
|
|
} else {
|
|
|
|
/* see do_nanosleep */
|
|
|
|
- hrtimer_init_sleeper(&t, current);
|
|
|
|
do {
|
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
|
|
|
hrtimer_start_expires(&t.timer, HRTIMER_MODE_ABS);
|
2020-01-03 23:36:11 +00:00
|
|
|
--
|
2020-04-09 19:44:24 +00:00
|
|
|
2.25.1
|
2020-01-03 23:36:11 +00:00
|
|
|
|