From 091048b54d215afd5e647959fac93ad91bbbba70 Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Wed, 12 Dec 2018 10:50:30 +0530 Subject: [PATCH 1/2] cpu/hotplug: Ensure that sched domains are rebuilt before hotplug When cpusets are enabled, the rebuilding of the scheduling domains is deferred to a workqueue context. Make sure that the work is completed before proceeding to the next hotplug. Otherwise scheduler observes an inconsistent view of online and offline CPUs in the root domain. If the online CPUs are still stuck in the offline i.e default domain, those CPUs would not be visible when scheduling happens on from other CPUs in the root domain. This results in packing tasks more on certain CPUs while leaving the other CPUs idle. Also RT_RUNTIME_SHARE feature i.e borrowing RT runtime from the other CPUs would not work correctly. Because the CPUs in the root domain can't borrow the runtime from the online CPUs but stuck in the offline/default domain. Change-Id: I93c51d2abc8a9c099b62f1d2cbb9095d3a788bda Signed-off-by: Pavankumar Kondeti [satyap@codeaurora.org: fix trivial merge conflict] Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/cpu.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/cpu.c b/kernel/cpu.c index 41b259b8be9d..8512a3d690cd 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #define CREATE_TRACE_POINTS @@ -1052,6 +1053,18 @@ static int do_cpu_down(unsigned int cpu, enum cpuhp_state target) { int err; + /* + * When cpusets are enabled, the rebuilding of the scheduling + * domains is deferred to a workqueue context. Make sure + * that the work is completed before proceeding to the next + * hotplug. Otherwise scheduler observes an inconsistent + * view of online and offline CPUs in the root domain. If + * the online CPUs are still stuck in the offline (default) + * domain, those CPUs would not be visible when scheduling + * happens on from other CPUs in the root domain. + */ + cpuset_wait_for_hotplug(); + cpu_maps_update_begin(); err = cpu_down_maps_locked(cpu, target); cpu_maps_update_done(); @@ -1215,6 +1228,8 @@ static int do_cpu_up(unsigned int cpu, enum cpuhp_state target) return -EINVAL; } + cpuset_wait_for_hotplug(); + switch_err = switch_to_rt_policy(); if (switch_err < 0) return switch_err; From 3f223d4909d1b790f117ed8dc086dfd486bbc489 Mon Sep 17 00:00:00 2001 From: Satya Durga Srinivasu Prabhala Date: Thu, 7 Mar 2019 22:22:49 -0800 Subject: [PATCH 2/2] trace/sched: set priority to 150 for deadline tasks As deadline tasks doesn't have priority, their priority is set to -1. If there are any deadline tasks in the system, chrome/tracing doesn't show results as expected as it can't recognize tasks with priority -1. Fix it by using 150 as priority for deadline tasks. Change-Id: I49b43f77b97ebfe6d79a7c9e9ec346ea60e79768 Signed-off-by: Satya Durga Srinivasu Prabhala --- include/trace/events/sched.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index 420e80e56e55..9fea72f19d85 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -156,11 +156,11 @@ TRACE_EVENT(sched_switch, TP_fast_assign( memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); __entry->prev_pid = prev->pid; - __entry->prev_prio = prev->prio; + __entry->prev_prio = prev->prio == -1 ? 150 : prev->prio; __entry->prev_state = __trace_sched_switch_state(preempt, prev); memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); __entry->next_pid = next->pid; - __entry->next_prio = next->prio; + __entry->next_prio = next->prio == -1 ? 150 : next->prio; /* XXX SCHED_DEADLINE */ ),