[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200508032919.52147-9-gshan@redhat.com>
Date: Fri, 8 May 2020 13:29:18 +1000
From: Gavin Shan <gshan@...hat.com>
To: kvmarm@...ts.cs.columbia.edu
Cc: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
maz@...nel.org, mark.rutland@....com, will@...nel.org,
catalin.marinas@....com, james.morse@....com,
suzuki.poulose@....com, drjones@...hat.com, eric.auger@...hat.com,
aarcange@...hat.com, shan.gavin@...il.com
Subject: [PATCH RFCv2 8/9] kernel/sched: Add cpu_rq_is_locked()
This adds API cpu_rq_is_locked() to check if the CPU's runqueue has been
locked or not. It's used in the subsequent patch to determine the task
wakeup should be executed immediately or delayed.
Signed-off-by: Gavin Shan <gshan@...hat.com>
---
include/linux/sched.h | 1 +
kernel/sched/core.c | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 4418f5cb8324..e68882443da7 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1691,6 +1691,7 @@ extern struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *n
*/
extern struct task_struct *find_get_task_by_vpid(pid_t nr);
+extern bool cpu_rq_is_locked(int cpu);
extern int wake_up_state(struct task_struct *tsk, unsigned int state);
extern int wake_up_process(struct task_struct *tsk);
extern void wake_up_new_task(struct task_struct *tsk);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9a2fbf98fd6f..30f4a8845495 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -73,6 +73,14 @@ __read_mostly int scheduler_running;
*/
int sysctl_sched_rt_runtime = 950000;
+bool cpu_rq_is_locked(int cpu)
+{
+ struct rq *rq = cpu_rq(cpu);
+
+ return raw_spin_is_locked(&rq->lock) ? true : false;
+}
+EXPORT_SYMBOL_GPL(cpu_rq_is_locked);
+
/*
* __task_rq_lock - lock the rq @p resides on.
*/
--
2.23.0
Powered by blists - more mailing lists