sched_rt.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359
  1. /*
  2. * Real-Time Scheduling Class (mapped to the SCHED_FIFO and SCHED_RR
  3. * policies)
  4. */
  5. #ifdef CONFIG_SMP
  6. static inline int rt_overloaded(struct rq *rq)
  7. {
  8. return atomic_read(&rq->rd->rto_count);
  9. }
  10. static inline void rt_set_overload(struct rq *rq)
  11. {
  12. if (!rq->online)
  13. return;
  14. cpu_set(rq->cpu, rq->rd->rto_mask);
  15. /*
  16. * Make sure the mask is visible before we set
  17. * the overload count. That is checked to determine
  18. * if we should look at the mask. It would be a shame
  19. * if we looked at the mask, but the mask was not
  20. * updated yet.
  21. */
  22. wmb();
  23. atomic_inc(&rq->rd->rto_count);
  24. }
  25. static inline void rt_clear_overload(struct rq *rq)
  26. {
  27. if (!rq->online)
  28. return;
  29. /* the order here really doesn't matter */
  30. atomic_dec(&rq->rd->rto_count);
  31. cpu_clear(rq->cpu, rq->rd->rto_mask);
  32. }
  33. static void update_rt_migration(struct rq *rq)
  34. {
  35. if (rq->rt.rt_nr_migratory && (rq->rt.rt_nr_running > 1)) {
  36. if (!rq->rt.overloaded) {
  37. rt_set_overload(rq);
  38. rq->rt.overloaded = 1;
  39. }
  40. } else if (rq->rt.overloaded) {
  41. rt_clear_overload(rq);
  42. rq->rt.overloaded = 0;
  43. }
  44. }
  45. #endif /* CONFIG_SMP */
  46. static inline struct task_struct *rt_task_of(struct sched_rt_entity *rt_se)
  47. {
  48. return container_of(rt_se, struct task_struct, rt);
  49. }
  50. static inline int on_rt_rq(struct sched_rt_entity *rt_se)
  51. {
  52. return !list_empty(&rt_se->run_list);
  53. }
  54. #ifdef CONFIG_RT_GROUP_SCHED
  55. static inline u64 sched_rt_runtime(struct rt_rq *rt_rq)
  56. {
  57. if (!rt_rq->tg)
  58. return RUNTIME_INF;
  59. return rt_rq->rt_runtime;
  60. }
  61. static inline u64 sched_rt_period(struct rt_rq *rt_rq)
  62. {
  63. return ktime_to_ns(rt_rq->tg->rt_bandwidth.rt_period);
  64. }
  65. #define for_each_leaf_rt_rq(rt_rq, rq) \
  66. list_for_each_entry(rt_rq, &rq->leaf_rt_rq_list, leaf_rt_rq_list)
  67. static inline struct rq *rq_of_rt_rq(struct rt_rq *rt_rq)
  68. {
  69. return rt_rq->rq;
  70. }
  71. static inline struct rt_rq *rt_rq_of_se(struct sched_rt_entity *rt_se)
  72. {
  73. return rt_se->rt_rq;
  74. }
  75. #define for_each_sched_rt_entity(rt_se) \
  76. for (; rt_se; rt_se = rt_se->parent)
  77. static inline struct rt_rq *group_rt_rq(struct sched_rt_entity *rt_se)
  78. {
  79. return rt_se->my_q;
  80. }
  81. static void enqueue_rt_entity(struct sched_rt_entity *rt_se);
  82. static void dequeue_rt_entity(struct sched_rt_entity *rt_se);
  83. static void sched_rt_rq_enqueue(struct rt_rq *rt_rq)
  84. {
  85. struct sched_rt_entity *rt_se = rt_rq->rt_se;
  86. if (rt_se && !on_rt_rq(rt_se) && rt_rq->rt_nr_running) {
  87. struct task_struct *curr = rq_of_rt_rq(rt_rq)->curr;
  88. enqueue_rt_entity(rt_se);
  89. if (rt_rq->highest_prio < curr->prio)
  90. resched_task(curr);
  91. }
  92. }
  93. static void sched_rt_rq_dequeue(struct rt_rq *rt_rq)
  94. {
  95. struct sched_rt_entity *rt_se = rt_rq->rt_se;
  96. if (rt_se && on_rt_rq(rt_se))
  97. dequeue_rt_entity(rt_se);
  98. }
  99. static inline int rt_rq_throttled(struct rt_rq *rt_rq)
  100. {
  101. return rt_rq->rt_throttled && !rt_rq->rt_nr_boosted;
  102. }
  103. static int rt_se_boosted(struct sched_rt_entity *rt_se)
  104. {
  105. struct rt_rq *rt_rq = group_rt_rq(rt_se);
  106. struct task_struct *p;
  107. if (rt_rq)
  108. return !!rt_rq->rt_nr_boosted;
  109. p = rt_task_of(rt_se);
  110. return p->prio != p->normal_prio;
  111. }
  112. #ifdef CONFIG_SMP
  113. static inline cpumask_t sched_rt_period_mask(void)
  114. {
  115. return cpu_rq(smp_processor_id())->rd->span;
  116. }
  117. #else
  118. static inline cpumask_t sched_rt_period_mask(void)
  119. {
  120. return cpu_online_map;
  121. }
  122. #endif
  123. static inline
  124. struct rt_rq *sched_rt_period_rt_rq(struct rt_bandwidth *rt_b, int cpu)
  125. {
  126. return container_of(rt_b, struct task_group, rt_bandwidth)->rt_rq[cpu];
  127. }
  128. static inline struct rt_bandwidth *sched_rt_bandwidth(struct rt_rq *rt_rq)
  129. {
  130. return &rt_rq->tg->rt_bandwidth;
  131. }
  132. #else
  133. static inline u64 sched_rt_runtime(struct rt_rq *rt_rq)
  134. {
  135. return rt_rq->rt_runtime;
  136. }
  137. static inline u64 sched_rt_period(struct rt_rq *rt_rq)
  138. {
  139. return ktime_to_ns(def_rt_bandwidth.rt_period);
  140. }
  141. #define for_each_leaf_rt_rq(rt_rq, rq) \
  142. for (rt_rq = &rq->rt; rt_rq; rt_rq = NULL)
  143. static inline struct rq *rq_of_rt_rq(struct rt_rq *rt_rq)
  144. {
  145. return container_of(rt_rq, struct rq, rt);
  146. }
  147. static inline struct rt_rq *rt_rq_of_se(struct sched_rt_entity *rt_se)
  148. {
  149. struct task_struct *p = rt_task_of(rt_se);
  150. struct rq *rq = task_rq(p);
  151. return &rq->rt;
  152. }
  153. #define for_each_sched_rt_entity(rt_se) \
  154. for (; rt_se; rt_se = NULL)
  155. static inline struct rt_rq *group_rt_rq(struct sched_rt_entity *rt_se)
  156. {
  157. return NULL;
  158. }
  159. static inline void sched_rt_rq_enqueue(struct rt_rq *rt_rq)
  160. {
  161. }
  162. static inline void sched_rt_rq_dequeue(struct rt_rq *rt_rq)
  163. {
  164. }
  165. static inline int rt_rq_throttled(struct rt_rq *rt_rq)
  166. {
  167. return rt_rq->rt_throttled;
  168. }
  169. static inline cpumask_t sched_rt_period_mask(void)
  170. {
  171. return cpu_online_map;
  172. }
  173. static inline
  174. struct rt_rq *sched_rt_period_rt_rq(struct rt_bandwidth *rt_b, int cpu)
  175. {
  176. return &cpu_rq(cpu)->rt;
  177. }
  178. static inline struct rt_bandwidth *sched_rt_bandwidth(struct rt_rq *rt_rq)
  179. {
  180. return &def_rt_bandwidth;
  181. }
  182. #endif
  183. static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
  184. {
  185. int i, idle = 1;
  186. cpumask_t span;
  187. if (rt_b->rt_runtime == RUNTIME_INF)
  188. return 1;
  189. span = sched_rt_period_mask();
  190. for_each_cpu_mask(i, span) {
  191. int enqueue = 0;
  192. struct rt_rq *rt_rq = sched_rt_period_rt_rq(rt_b, i);
  193. struct rq *rq = rq_of_rt_rq(rt_rq);
  194. spin_lock(&rq->lock);
  195. if (rt_rq->rt_time) {
  196. u64 runtime;
  197. spin_lock(&rt_rq->rt_runtime_lock);
  198. runtime = rt_rq->rt_runtime;
  199. rt_rq->rt_time -= min(rt_rq->rt_time, overrun*runtime);
  200. if (rt_rq->rt_throttled && rt_rq->rt_time < runtime) {
  201. rt_rq->rt_throttled = 0;
  202. enqueue = 1;
  203. }
  204. if (rt_rq->rt_time || rt_rq->rt_nr_running)
  205. idle = 0;
  206. spin_unlock(&rt_rq->rt_runtime_lock);
  207. }
  208. if (enqueue)
  209. sched_rt_rq_enqueue(rt_rq);
  210. spin_unlock(&rq->lock);
  211. }
  212. return idle;
  213. }
  214. #ifdef CONFIG_SMP
  215. static int balance_runtime(struct rt_rq *rt_rq)
  216. {
  217. struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
  218. struct root_domain *rd = cpu_rq(smp_processor_id())->rd;
  219. int i, weight, more = 0;
  220. u64 rt_period;
  221. weight = cpus_weight(rd->span);
  222. spin_lock(&rt_b->rt_runtime_lock);
  223. rt_period = ktime_to_ns(rt_b->rt_period);
  224. for_each_cpu_mask(i, rd->span) {
  225. struct rt_rq *iter = sched_rt_period_rt_rq(rt_b, i);
  226. s64 diff;
  227. if (iter == rt_rq)
  228. continue;
  229. spin_lock(&iter->rt_runtime_lock);
  230. diff = iter->rt_runtime - iter->rt_time;
  231. if (diff > 0) {
  232. do_div(diff, weight);
  233. if (rt_rq->rt_runtime + diff > rt_period)
  234. diff = rt_period - rt_rq->rt_runtime;
  235. iter->rt_runtime -= diff;
  236. rt_rq->rt_runtime += diff;
  237. more = 1;
  238. if (rt_rq->rt_runtime == rt_period) {
  239. spin_unlock(&iter->rt_runtime_lock);
  240. break;
  241. }
  242. }
  243. spin_unlock(&iter->rt_runtime_lock);
  244. }
  245. spin_unlock(&rt_b->rt_runtime_lock);
  246. return more;
  247. }
  248. #endif
  249. static inline int rt_se_prio(struct sched_rt_entity *rt_se)
  250. {
  251. #ifdef CONFIG_RT_GROUP_SCHED
  252. struct rt_rq *rt_rq = group_rt_rq(rt_se);
  253. if (rt_rq)
  254. return rt_rq->highest_prio;
  255. #endif
  256. return rt_task_of(rt_se)->prio;
  257. }
  258. static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
  259. {
  260. u64 runtime = sched_rt_runtime(rt_rq);
  261. if (runtime == RUNTIME_INF)
  262. return 0;
  263. if (rt_rq->rt_throttled)
  264. return rt_rq_throttled(rt_rq);
  265. if (sched_rt_runtime(rt_rq) >= sched_rt_period(rt_rq))
  266. return 0;
  267. #ifdef CONFIG_SMP
  268. if (rt_rq->rt_time > runtime) {
  269. int more;
  270. spin_unlock(&rt_rq->rt_runtime_lock);
  271. more = balance_runtime(rt_rq);
  272. spin_lock(&rt_rq->rt_runtime_lock);
  273. if (more)
  274. runtime = sched_rt_runtime(rt_rq);
  275. }
  276. #endif
  277. if (rt_rq->rt_time > runtime) {
  278. rt_rq->rt_throttled = 1;
  279. if (rt_rq_throttled(rt_rq)) {
  280. sched_rt_rq_dequeue(rt_rq);
  281. return 1;
  282. }
  283. }
  284. return 0;
  285. }
  286. /*
  287. * Update the current task's runtime statistics. Skip current tasks that
  288. * are not in our scheduling class.
  289. */
  290. static void update_curr_rt(struct rq *rq)
  291. {
  292. struct task_struct *curr = rq->curr;
  293. struct sched_rt_entity *rt_se = &curr->rt;
  294. struct rt_rq *rt_rq = rt_rq_of_se(rt_se);
  295. u64 delta_exec;
  296. if (!task_has_rt_policy(curr))
  297. return;
  298. delta_exec = rq->clock - curr->se.exec_start;
  299. if (unlikely((s64)delta_exec < 0))
  300. delta_exec = 0;
  301. schedstat_set(curr->se.exec_max, max(curr->se.exec_max, delta_exec));
  302. curr->se.sum_exec_runtime += delta_exec;
  303. curr->se.exec_start = rq->clock;
  304. cpuacct_charge(curr, delta_exec);
  305. for_each_sched_rt_entity(rt_se) {
  306. rt_rq = rt_rq_of_se(rt_se);
  307. spin_lock(&rt_rq->rt_runtime_lock);
  308. rt_rq->rt_time += delta_exec;
  309. if (sched_rt_runtime_exceeded(rt_rq))
  310. resched_task(curr);
  311. spin_unlock(&rt_rq->rt_runtime_lock);
  312. }
  313. }
  314. static inline
  315. void inc_rt_tasks(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
  316. {
  317. WARN_ON(!rt_prio(rt_se_prio(rt_se)));
  318. rt_rq->rt_nr_running++;
  319. #if defined CONFIG_SMP || defined CONFIG_RT_GROUP_SCHED
  320. if (rt_se_prio(rt_se) < rt_rq->highest_prio) {
  321. struct rq *rq = rq_of_rt_rq(rt_rq);
  322. rt_rq->highest_prio = rt_se_prio(rt_se);
  323. if (rq->online)
  324. cpupri_set(&rq->rd->cpupri, rq->cpu,
  325. rt_se_prio(rt_se));
  326. }
  327. #endif
  328. #ifdef CONFIG_SMP
  329. if (rt_se->nr_cpus_allowed > 1) {
  330. struct rq *rq = rq_of_rt_rq(rt_rq);
  331. rq->rt.rt_nr_migratory++;
  332. }
  333. update_rt_migration(rq_of_rt_rq(rt_rq));
  334. #endif
  335. #ifdef CONFIG_RT_GROUP_SCHED
  336. if (rt_se_boosted(rt_se))
  337. rt_rq->rt_nr_boosted++;
  338. if (rt_rq->tg)
  339. start_rt_bandwidth(&rt_rq->tg->rt_bandwidth);
  340. #else
  341. start_rt_bandwidth(&def_rt_bandwidth);
  342. #endif
  343. }
  344. static inline
  345. void dec_rt_tasks(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
  346. {
  347. #ifdef CONFIG_SMP
  348. int highest_prio = rt_rq->highest_prio;
  349. #endif
  350. WARN_ON(!rt_prio(rt_se_prio(rt_se)));
  351. WARN_ON(!rt_rq->rt_nr_running);
  352. rt_rq->rt_nr_running--;
  353. #if defined CONFIG_SMP || defined CONFIG_RT_GROUP_SCHED
  354. if (rt_rq->rt_nr_running) {
  355. struct rt_prio_array *array;
  356. WARN_ON(rt_se_prio(rt_se) < rt_rq->highest_prio);
  357. if (rt_se_prio(rt_se) == rt_rq->highest_prio) {
  358. /* recalculate */
  359. array = &rt_rq->active;
  360. rt_rq->highest_prio =
  361. sched_find_first_bit(array->bitmap);
  362. } /* otherwise leave rq->highest prio alone */
  363. } else
  364. rt_rq->highest_prio = MAX_RT_PRIO;
  365. #endif
  366. #ifdef CONFIG_SMP
  367. if (rt_se->nr_cpus_allowed > 1) {
  368. struct rq *rq = rq_of_rt_rq(rt_rq);
  369. rq->rt.rt_nr_migratory--;
  370. }
  371. if (rt_rq->highest_prio != highest_prio) {
  372. struct rq *rq = rq_of_rt_rq(rt_rq);
  373. if (rq->online)
  374. cpupri_set(&rq->rd->cpupri, rq->cpu,
  375. rt_rq->highest_prio);
  376. }
  377. update_rt_migration(rq_of_rt_rq(rt_rq));
  378. #endif /* CONFIG_SMP */
  379. #ifdef CONFIG_RT_GROUP_SCHED
  380. if (rt_se_boosted(rt_se))
  381. rt_rq->rt_nr_boosted--;
  382. WARN_ON(!rt_rq->rt_nr_running && rt_rq->rt_nr_boosted);
  383. #endif
  384. }
  385. static void enqueue_rt_entity(struct sched_rt_entity *rt_se)
  386. {
  387. struct rt_rq *rt_rq = rt_rq_of_se(rt_se);
  388. struct rt_prio_array *array = &rt_rq->active;
  389. struct rt_rq *group_rq = group_rt_rq(rt_se);
  390. if (group_rq && rt_rq_throttled(group_rq))
  391. return;
  392. if (rt_se->nr_cpus_allowed == 1)
  393. list_add_tail(&rt_se->run_list,
  394. array->xqueue + rt_se_prio(rt_se));
  395. else
  396. list_add_tail(&rt_se->run_list,
  397. array->squeue + rt_se_prio(rt_se));
  398. __set_bit(rt_se_prio(rt_se), array->bitmap);
  399. inc_rt_tasks(rt_se, rt_rq);
  400. }
  401. static void dequeue_rt_entity(struct sched_rt_entity *rt_se)
  402. {
  403. struct rt_rq *rt_rq = rt_rq_of_se(rt_se);
  404. struct rt_prio_array *array = &rt_rq->active;
  405. list_del_init(&rt_se->run_list);
  406. if (list_empty(array->squeue + rt_se_prio(rt_se))
  407. && list_empty(array->xqueue + rt_se_prio(rt_se)))
  408. __clear_bit(rt_se_prio(rt_se), array->bitmap);
  409. dec_rt_tasks(rt_se, rt_rq);
  410. }
  411. /*
  412. * Because the prio of an upper entry depends on the lower
  413. * entries, we must remove entries top - down.
  414. */
  415. static void dequeue_rt_stack(struct task_struct *p)
  416. {
  417. struct sched_rt_entity *rt_se, *back = NULL;
  418. rt_se = &p->rt;
  419. for_each_sched_rt_entity(rt_se) {
  420. rt_se->back = back;
  421. back = rt_se;
  422. }
  423. for (rt_se = back; rt_se; rt_se = rt_se->back) {
  424. if (on_rt_rq(rt_se))
  425. dequeue_rt_entity(rt_se);
  426. }
  427. }
  428. /*
  429. * Adding/removing a task to/from a priority array:
  430. */
  431. static void enqueue_task_rt(struct rq *rq, struct task_struct *p, int wakeup)
  432. {
  433. struct sched_rt_entity *rt_se = &p->rt;
  434. if (wakeup)
  435. rt_se->timeout = 0;
  436. dequeue_rt_stack(p);
  437. /*
  438. * enqueue everybody, bottom - up.
  439. */
  440. for_each_sched_rt_entity(rt_se)
  441. enqueue_rt_entity(rt_se);
  442. }
  443. static void dequeue_task_rt(struct rq *rq, struct task_struct *p, int sleep)
  444. {
  445. struct sched_rt_entity *rt_se = &p->rt;
  446. struct rt_rq *rt_rq;
  447. update_curr_rt(rq);
  448. dequeue_rt_stack(p);
  449. /*
  450. * re-enqueue all non-empty rt_rq entities.
  451. */
  452. for_each_sched_rt_entity(rt_se) {
  453. rt_rq = group_rt_rq(rt_se);
  454. if (rt_rq && rt_rq->rt_nr_running)
  455. enqueue_rt_entity(rt_se);
  456. }
  457. }
  458. /*
  459. * Put task to the end of the run list without the overhead of dequeue
  460. * followed by enqueue.
  461. *
  462. * Note: We always enqueue the task to the shared-queue, regardless of its
  463. * previous position w.r.t. exclusive vs shared. This is so that exclusive RR
  464. * tasks fairly round-robin with all tasks on the runqueue, not just other
  465. * exclusive tasks.
  466. */
  467. static
  468. void requeue_rt_entity(struct rt_rq *rt_rq, struct sched_rt_entity *rt_se)
  469. {
  470. struct rt_prio_array *array = &rt_rq->active;
  471. list_del_init(&rt_se->run_list);
  472. list_add_tail(&rt_se->run_list, array->squeue + rt_se_prio(rt_se));
  473. }
  474. static void requeue_task_rt(struct rq *rq, struct task_struct *p)
  475. {
  476. struct sched_rt_entity *rt_se = &p->rt;
  477. struct rt_rq *rt_rq;
  478. for_each_sched_rt_entity(rt_se) {
  479. rt_rq = rt_rq_of_se(rt_se);
  480. requeue_rt_entity(rt_rq, rt_se);
  481. }
  482. }
  483. static void yield_task_rt(struct rq *rq)
  484. {
  485. requeue_task_rt(rq, rq->curr);
  486. }
  487. #ifdef CONFIG_SMP
  488. static int find_lowest_rq(struct task_struct *task);
  489. static int select_task_rq_rt(struct task_struct *p, int sync)
  490. {
  491. struct rq *rq = task_rq(p);
  492. /*
  493. * If the current task is an RT task, then
  494. * try to see if we can wake this RT task up on another
  495. * runqueue. Otherwise simply start this RT task
  496. * on its current runqueue.
  497. *
  498. * We want to avoid overloading runqueues. Even if
  499. * the RT task is of higher priority than the current RT task.
  500. * RT tasks behave differently than other tasks. If
  501. * one gets preempted, we try to push it off to another queue.
  502. * So trying to keep a preempting RT task on the same
  503. * cache hot CPU will force the running RT task to
  504. * a cold CPU. So we waste all the cache for the lower
  505. * RT task in hopes of saving some of a RT task
  506. * that is just being woken and probably will have
  507. * cold cache anyway.
  508. */
  509. if (unlikely(rt_task(rq->curr)) &&
  510. (p->rt.nr_cpus_allowed > 1)) {
  511. int cpu = find_lowest_rq(p);
  512. return (cpu == -1) ? task_cpu(p) : cpu;
  513. }
  514. /*
  515. * Otherwise, just let it ride on the affined RQ and the
  516. * post-schedule router will push the preempted task away
  517. */
  518. return task_cpu(p);
  519. }
  520. #endif /* CONFIG_SMP */
  521. static struct sched_rt_entity *pick_next_rt_entity(struct rq *rq,
  522. struct rt_rq *rt_rq);
  523. /*
  524. * Preempt the current task with a newly woken task if needed:
  525. */
  526. static void check_preempt_curr_rt(struct rq *rq, struct task_struct *p)
  527. {
  528. if (p->prio < rq->curr->prio) {
  529. resched_task(rq->curr);
  530. return;
  531. }
  532. #ifdef CONFIG_SMP
  533. /*
  534. * If:
  535. *
  536. * - the newly woken task is of equal priority to the current task
  537. * - the newly woken task is non-migratable while current is migratable
  538. * - current will be preempted on the next reschedule
  539. *
  540. * we should check to see if current can readily move to a different
  541. * cpu. If so, we will reschedule to allow the push logic to try
  542. * to move current somewhere else, making room for our non-migratable
  543. * task.
  544. */
  545. if((p->prio == rq->curr->prio)
  546. && p->rt.nr_cpus_allowed == 1
  547. && rq->curr->rt.nr_cpus_allowed != 1
  548. && pick_next_rt_entity(rq, &rq->rt) != &rq->curr->rt) {
  549. cpumask_t mask;
  550. if (cpupri_find(&rq->rd->cpupri, rq->curr, &mask))
  551. /*
  552. * There appears to be other cpus that can accept
  553. * current, so lets reschedule to try and push it away
  554. */
  555. resched_task(rq->curr);
  556. }
  557. #endif
  558. }
  559. static struct sched_rt_entity *pick_next_rt_entity(struct rq *rq,
  560. struct rt_rq *rt_rq)
  561. {
  562. struct rt_prio_array *array = &rt_rq->active;
  563. struct sched_rt_entity *next = NULL;
  564. struct list_head *queue;
  565. int idx;
  566. idx = sched_find_first_bit(array->bitmap);
  567. BUG_ON(idx >= MAX_RT_PRIO);
  568. queue = array->xqueue + idx;
  569. if (!list_empty(queue))
  570. next = list_entry(queue->next, struct sched_rt_entity,
  571. run_list);
  572. else {
  573. queue = array->squeue + idx;
  574. next = list_entry(queue->next, struct sched_rt_entity,
  575. run_list);
  576. }
  577. return next;
  578. }
  579. static struct task_struct *pick_next_task_rt(struct rq *rq)
  580. {
  581. struct sched_rt_entity *rt_se;
  582. struct task_struct *p;
  583. struct rt_rq *rt_rq;
  584. rt_rq = &rq->rt;
  585. if (unlikely(!rt_rq->rt_nr_running))
  586. return NULL;
  587. if (rt_rq_throttled(rt_rq))
  588. return NULL;
  589. do {
  590. rt_se = pick_next_rt_entity(rq, rt_rq);
  591. BUG_ON(!rt_se);
  592. rt_rq = group_rt_rq(rt_se);
  593. } while (rt_rq);
  594. p = rt_task_of(rt_se);
  595. p->se.exec_start = rq->clock;
  596. return p;
  597. }
  598. static void put_prev_task_rt(struct rq *rq, struct task_struct *p)
  599. {
  600. update_curr_rt(rq);
  601. p->se.exec_start = 0;
  602. }
  603. #ifdef CONFIG_SMP
  604. /* Only try algorithms three times */
  605. #define RT_MAX_TRIES 3
  606. static int double_lock_balance(struct rq *this_rq, struct rq *busiest);
  607. static void deactivate_task(struct rq *rq, struct task_struct *p, int sleep);
  608. static int pick_rt_task(struct rq *rq, struct task_struct *p, int cpu)
  609. {
  610. if (!task_running(rq, p) &&
  611. (cpu < 0 || cpu_isset(cpu, p->cpus_allowed)) &&
  612. (p->rt.nr_cpus_allowed > 1))
  613. return 1;
  614. return 0;
  615. }
  616. /* Return the second highest RT task, NULL otherwise */
  617. static struct task_struct *pick_next_highest_task_rt(struct rq *rq, int cpu)
  618. {
  619. struct task_struct *next = NULL;
  620. struct sched_rt_entity *rt_se;
  621. struct rt_prio_array *array;
  622. struct rt_rq *rt_rq;
  623. int idx;
  624. for_each_leaf_rt_rq(rt_rq, rq) {
  625. array = &rt_rq->active;
  626. idx = sched_find_first_bit(array->bitmap);
  627. next_idx:
  628. if (idx >= MAX_RT_PRIO)
  629. continue;
  630. if (next && next->prio < idx)
  631. continue;
  632. list_for_each_entry(rt_se, array->squeue + idx, run_list) {
  633. struct task_struct *p = rt_task_of(rt_se);
  634. if (pick_rt_task(rq, p, cpu)) {
  635. next = p;
  636. break;
  637. }
  638. }
  639. if (!next) {
  640. idx = find_next_bit(array->bitmap, MAX_RT_PRIO, idx+1);
  641. goto next_idx;
  642. }
  643. }
  644. return next;
  645. }
  646. static DEFINE_PER_CPU(cpumask_t, local_cpu_mask);
  647. static inline int pick_optimal_cpu(int this_cpu, cpumask_t *mask)
  648. {
  649. int first;
  650. /* "this_cpu" is cheaper to preempt than a remote processor */
  651. if ((this_cpu != -1) && cpu_isset(this_cpu, *mask))
  652. return this_cpu;
  653. first = first_cpu(*mask);
  654. if (first != NR_CPUS)
  655. return first;
  656. return -1;
  657. }
  658. static int find_lowest_rq(struct task_struct *task)
  659. {
  660. struct sched_domain *sd;
  661. cpumask_t *lowest_mask = &__get_cpu_var(local_cpu_mask);
  662. int this_cpu = smp_processor_id();
  663. int cpu = task_cpu(task);
  664. if (task->rt.nr_cpus_allowed == 1)
  665. return -1; /* No other targets possible */
  666. if (!cpupri_find(&task_rq(task)->rd->cpupri, task, lowest_mask))
  667. return -1; /* No targets found */
  668. /*
  669. * At this point we have built a mask of cpus representing the
  670. * lowest priority tasks in the system. Now we want to elect
  671. * the best one based on our affinity and topology.
  672. *
  673. * We prioritize the last cpu that the task executed on since
  674. * it is most likely cache-hot in that location.
  675. */
  676. if (cpu_isset(cpu, *lowest_mask))
  677. return cpu;
  678. /*
  679. * Otherwise, we consult the sched_domains span maps to figure
  680. * out which cpu is logically closest to our hot cache data.
  681. */
  682. if (this_cpu == cpu)
  683. this_cpu = -1; /* Skip this_cpu opt if the same */
  684. for_each_domain(cpu, sd) {
  685. if (sd->flags & SD_WAKE_AFFINE) {
  686. cpumask_t domain_mask;
  687. int best_cpu;
  688. cpus_and(domain_mask, sd->span, *lowest_mask);
  689. best_cpu = pick_optimal_cpu(this_cpu,
  690. &domain_mask);
  691. if (best_cpu != -1)
  692. return best_cpu;
  693. }
  694. }
  695. /*
  696. * And finally, if there were no matches within the domains
  697. * just give the caller *something* to work with from the compatible
  698. * locations.
  699. */
  700. return pick_optimal_cpu(this_cpu, lowest_mask);
  701. }
  702. /* Will lock the rq it finds */
  703. static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq)
  704. {
  705. struct rq *lowest_rq = NULL;
  706. int tries;
  707. int cpu;
  708. for (tries = 0; tries < RT_MAX_TRIES; tries++) {
  709. cpu = find_lowest_rq(task);
  710. if ((cpu == -1) || (cpu == rq->cpu))
  711. break;
  712. lowest_rq = cpu_rq(cpu);
  713. /* if the prio of this runqueue changed, try again */
  714. if (double_lock_balance(rq, lowest_rq)) {
  715. /*
  716. * We had to unlock the run queue. In
  717. * the mean time, task could have
  718. * migrated already or had its affinity changed.
  719. * Also make sure that it wasn't scheduled on its rq.
  720. */
  721. if (unlikely(task_rq(task) != rq ||
  722. !cpu_isset(lowest_rq->cpu,
  723. task->cpus_allowed) ||
  724. task_running(rq, task) ||
  725. !task->se.on_rq)) {
  726. spin_unlock(&lowest_rq->lock);
  727. lowest_rq = NULL;
  728. break;
  729. }
  730. }
  731. /* If this rq is still suitable use it. */
  732. if (lowest_rq->rt.highest_prio > task->prio)
  733. break;
  734. /* try again */
  735. spin_unlock(&lowest_rq->lock);
  736. lowest_rq = NULL;
  737. }
  738. return lowest_rq;
  739. }
  740. /*
  741. * If the current CPU has more than one RT task, see if the non
  742. * running task can migrate over to a CPU that is running a task
  743. * of lesser priority.
  744. */
  745. static int push_rt_task(struct rq *rq)
  746. {
  747. struct task_struct *next_task;
  748. struct rq *lowest_rq;
  749. int ret = 0;
  750. int paranoid = RT_MAX_TRIES;
  751. if (!rq->rt.overloaded)
  752. return 0;
  753. next_task = pick_next_highest_task_rt(rq, -1);
  754. if (!next_task)
  755. return 0;
  756. retry:
  757. if (unlikely(next_task == rq->curr)) {
  758. WARN_ON(1);
  759. return 0;
  760. }
  761. /*
  762. * It's possible that the next_task slipped in of
  763. * higher priority than current. If that's the case
  764. * just reschedule current.
  765. */
  766. if (unlikely(next_task->prio < rq->curr->prio)) {
  767. resched_task(rq->curr);
  768. return 0;
  769. }
  770. /* We might release rq lock */
  771. get_task_struct(next_task);
  772. /* find_lock_lowest_rq locks the rq if found */
  773. lowest_rq = find_lock_lowest_rq(next_task, rq);
  774. if (!lowest_rq) {
  775. struct task_struct *task;
  776. /*
  777. * find lock_lowest_rq releases rq->lock
  778. * so it is possible that next_task has changed.
  779. * If it has, then try again.
  780. */
  781. task = pick_next_highest_task_rt(rq, -1);
  782. if (unlikely(task != next_task) && task && paranoid--) {
  783. put_task_struct(next_task);
  784. next_task = task;
  785. goto retry;
  786. }
  787. goto out;
  788. }
  789. deactivate_task(rq, next_task, 0);
  790. set_task_cpu(next_task, lowest_rq->cpu);
  791. activate_task(lowest_rq, next_task, 0);
  792. resched_task(lowest_rq->curr);
  793. spin_unlock(&lowest_rq->lock);
  794. ret = 1;
  795. out:
  796. put_task_struct(next_task);
  797. return ret;
  798. }
  799. /*
  800. * TODO: Currently we just use the second highest prio task on
  801. * the queue, and stop when it can't migrate (or there's
  802. * no more RT tasks). There may be a case where a lower
  803. * priority RT task has a different affinity than the
  804. * higher RT task. In this case the lower RT task could
  805. * possibly be able to migrate where as the higher priority
  806. * RT task could not. We currently ignore this issue.
  807. * Enhancements are welcome!
  808. */
  809. static void push_rt_tasks(struct rq *rq)
  810. {
  811. /* push_rt_task will return true if it moved an RT */
  812. while (push_rt_task(rq))
  813. ;
  814. }
  815. static int pull_rt_task(struct rq *this_rq)
  816. {
  817. int this_cpu = this_rq->cpu, ret = 0, cpu;
  818. struct task_struct *p, *next;
  819. struct rq *src_rq;
  820. if (likely(!rt_overloaded(this_rq)))
  821. return 0;
  822. next = pick_next_task_rt(this_rq);
  823. for_each_cpu_mask(cpu, this_rq->rd->rto_mask) {
  824. if (this_cpu == cpu)
  825. continue;
  826. src_rq = cpu_rq(cpu);
  827. /*
  828. * We can potentially drop this_rq's lock in
  829. * double_lock_balance, and another CPU could
  830. * steal our next task - hence we must cause
  831. * the caller to recalculate the next task
  832. * in that case:
  833. */
  834. if (double_lock_balance(this_rq, src_rq)) {
  835. struct task_struct *old_next = next;
  836. next = pick_next_task_rt(this_rq);
  837. if (next != old_next)
  838. ret = 1;
  839. }
  840. /*
  841. * Are there still pullable RT tasks?
  842. */
  843. if (src_rq->rt.rt_nr_running <= 1)
  844. goto skip;
  845. p = pick_next_highest_task_rt(src_rq, this_cpu);
  846. /*
  847. * Do we have an RT task that preempts
  848. * the to-be-scheduled task?
  849. */
  850. if (p && (!next || (p->prio < next->prio))) {
  851. WARN_ON(p == src_rq->curr);
  852. WARN_ON(!p->se.on_rq);
  853. /*
  854. * There's a chance that p is higher in priority
  855. * than what's currently running on its cpu.
  856. * This is just that p is wakeing up and hasn't
  857. * had a chance to schedule. We only pull
  858. * p if it is lower in priority than the
  859. * current task on the run queue or
  860. * this_rq next task is lower in prio than
  861. * the current task on that rq.
  862. */
  863. if (p->prio < src_rq->curr->prio ||
  864. (next && next->prio < src_rq->curr->prio))
  865. goto skip;
  866. ret = 1;
  867. deactivate_task(src_rq, p, 0);
  868. set_task_cpu(p, this_cpu);
  869. activate_task(this_rq, p, 0);
  870. /*
  871. * We continue with the search, just in
  872. * case there's an even higher prio task
  873. * in another runqueue. (low likelyhood
  874. * but possible)
  875. *
  876. * Update next so that we won't pick a task
  877. * on another cpu with a priority lower (or equal)
  878. * than the one we just picked.
  879. */
  880. next = p;
  881. }
  882. skip:
  883. spin_unlock(&src_rq->lock);
  884. }
  885. return ret;
  886. }
  887. static void pre_schedule_rt(struct rq *rq, struct task_struct *prev)
  888. {
  889. /* Try to pull RT tasks here if we lower this rq's prio */
  890. if (unlikely(rt_task(prev)) && rq->rt.highest_prio > prev->prio)
  891. pull_rt_task(rq);
  892. }
  893. static void post_schedule_rt(struct rq *rq)
  894. {
  895. /*
  896. * If we have more than one rt_task queued, then
  897. * see if we can push the other rt_tasks off to other CPUS.
  898. * Note we may release the rq lock, and since
  899. * the lock was owned by prev, we need to release it
  900. * first via finish_lock_switch and then reaquire it here.
  901. */
  902. if (unlikely(rq->rt.overloaded)) {
  903. spin_lock_irq(&rq->lock);
  904. push_rt_tasks(rq);
  905. spin_unlock_irq(&rq->lock);
  906. }
  907. }
  908. /*
  909. * If we are not running and we are not going to reschedule soon, we should
  910. * try to push tasks away now
  911. */
  912. static void task_wake_up_rt(struct rq *rq, struct task_struct *p)
  913. {
  914. if (!task_running(rq, p) &&
  915. !test_tsk_need_resched(rq->curr) &&
  916. rq->rt.overloaded)
  917. push_rt_tasks(rq);
  918. }
  919. static unsigned long
  920. load_balance_rt(struct rq *this_rq, int this_cpu, struct rq *busiest,
  921. unsigned long max_load_move,
  922. struct sched_domain *sd, enum cpu_idle_type idle,
  923. int *all_pinned, int *this_best_prio)
  924. {
  925. /* don't touch RT tasks */
  926. return 0;
  927. }
  928. static int
  929. move_one_task_rt(struct rq *this_rq, int this_cpu, struct rq *busiest,
  930. struct sched_domain *sd, enum cpu_idle_type idle)
  931. {
  932. /* don't touch RT tasks */
  933. return 0;
  934. }
  935. static void set_cpus_allowed_rt(struct task_struct *p,
  936. const cpumask_t *new_mask)
  937. {
  938. int weight = cpus_weight(*new_mask);
  939. BUG_ON(!rt_task(p));
  940. /*
  941. * Update the migration status of the RQ if we have an RT task
  942. * which is running AND changing its weight value.
  943. */
  944. if (p->se.on_rq && (weight != p->rt.nr_cpus_allowed)) {
  945. struct rq *rq = task_rq(p);
  946. if ((p->rt.nr_cpus_allowed <= 1) && (weight > 1)) {
  947. rq->rt.rt_nr_migratory++;
  948. } else if ((p->rt.nr_cpus_allowed > 1) && (weight <= 1)) {
  949. BUG_ON(!rq->rt.rt_nr_migratory);
  950. rq->rt.rt_nr_migratory--;
  951. }
  952. update_rt_migration(rq);
  953. if (unlikely(weight == 1 || p->rt.nr_cpus_allowed == 1))
  954. /*
  955. * If either the new or old weight is a "1", we need
  956. * to requeue to properly move between shared and
  957. * exclusive queues.
  958. */
  959. requeue_task_rt(rq, p);
  960. }
  961. p->cpus_allowed = *new_mask;
  962. p->rt.nr_cpus_allowed = weight;
  963. }
  964. /* Assumes rq->lock is held */
  965. static void rq_online_rt(struct rq *rq)
  966. {
  967. if (rq->rt.overloaded)
  968. rt_set_overload(rq);
  969. cpupri_set(&rq->rd->cpupri, rq->cpu, rq->rt.highest_prio);
  970. }
  971. /* Assumes rq->lock is held */
  972. static void rq_offline_rt(struct rq *rq)
  973. {
  974. if (rq->rt.overloaded)
  975. rt_clear_overload(rq);
  976. cpupri_set(&rq->rd->cpupri, rq->cpu, CPUPRI_INVALID);
  977. }
  978. /*
  979. * When switch from the rt queue, we bring ourselves to a position
  980. * that we might want to pull RT tasks from other runqueues.
  981. */
  982. static void switched_from_rt(struct rq *rq, struct task_struct *p,
  983. int running)
  984. {
  985. /*
  986. * If there are other RT tasks then we will reschedule
  987. * and the scheduling of the other RT tasks will handle
  988. * the balancing. But if we are the last RT task
  989. * we may need to handle the pulling of RT tasks
  990. * now.
  991. */
  992. if (!rq->rt.rt_nr_running)
  993. pull_rt_task(rq);
  994. }
  995. #endif /* CONFIG_SMP */
  996. /*
  997. * When switching a task to RT, we may overload the runqueue
  998. * with RT tasks. In this case we try to push them off to
  999. * other runqueues.
  1000. */
  1001. static void switched_to_rt(struct rq *rq, struct task_struct *p,
  1002. int running)
  1003. {
  1004. int check_resched = 1;
  1005. /*
  1006. * If we are already running, then there's nothing
  1007. * that needs to be done. But if we are not running
  1008. * we may need to preempt the current running task.
  1009. * If that current running task is also an RT task
  1010. * then see if we can move to another run queue.
  1011. */
  1012. if (!running) {
  1013. #ifdef CONFIG_SMP
  1014. if (rq->rt.overloaded && push_rt_task(rq) &&
  1015. /* Don't resched if we changed runqueues */
  1016. rq != task_rq(p))
  1017. check_resched = 0;
  1018. #endif /* CONFIG_SMP */
  1019. if (check_resched && p->prio < rq->curr->prio)
  1020. resched_task(rq->curr);
  1021. }
  1022. }
  1023. /*
  1024. * Priority of the task has changed. This may cause
  1025. * us to initiate a push or pull.
  1026. */
  1027. static void prio_changed_rt(struct rq *rq, struct task_struct *p,
  1028. int oldprio, int running)
  1029. {
  1030. if (running) {
  1031. #ifdef CONFIG_SMP
  1032. /*
  1033. * If our priority decreases while running, we
  1034. * may need to pull tasks to this runqueue.
  1035. */
  1036. if (oldprio < p->prio)
  1037. pull_rt_task(rq);
  1038. /*
  1039. * If there's a higher priority task waiting to run
  1040. * then reschedule. Note, the above pull_rt_task
  1041. * can release the rq lock and p could migrate.
  1042. * Only reschedule if p is still on the same runqueue.
  1043. */
  1044. if (p->prio > rq->rt.highest_prio && rq->curr == p)
  1045. resched_task(p);
  1046. #else
  1047. /* For UP simply resched on drop of prio */
  1048. if (oldprio < p->prio)
  1049. resched_task(p);
  1050. #endif /* CONFIG_SMP */
  1051. } else {
  1052. /*
  1053. * This task is not running, but if it is
  1054. * greater than the current running task
  1055. * then reschedule.
  1056. */
  1057. if (p->prio < rq->curr->prio)
  1058. resched_task(rq->curr);
  1059. }
  1060. }
  1061. static void watchdog(struct rq *rq, struct task_struct *p)
  1062. {
  1063. unsigned long soft, hard;
  1064. if (!p->signal)
  1065. return;
  1066. soft = p->signal->rlim[RLIMIT_RTTIME].rlim_cur;
  1067. hard = p->signal->rlim[RLIMIT_RTTIME].rlim_max;
  1068. if (soft != RLIM_INFINITY) {
  1069. unsigned long next;
  1070. p->rt.timeout++;
  1071. next = DIV_ROUND_UP(min(soft, hard), USEC_PER_SEC/HZ);
  1072. if (p->rt.timeout > next)
  1073. p->it_sched_expires = p->se.sum_exec_runtime;
  1074. }
  1075. }
  1076. static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued)
  1077. {
  1078. update_curr_rt(rq);
  1079. watchdog(rq, p);
  1080. /*
  1081. * RR tasks need a special form of timeslice management.
  1082. * FIFO tasks have no timeslices.
  1083. */
  1084. if (p->policy != SCHED_RR)
  1085. return;
  1086. if (--p->rt.time_slice)
  1087. return;
  1088. p->rt.time_slice = DEF_TIMESLICE;
  1089. /*
  1090. * Requeue to the end of queue if we are not the only element
  1091. * on the queue:
  1092. */
  1093. if (p->rt.run_list.prev != p->rt.run_list.next) {
  1094. requeue_task_rt(rq, p);
  1095. set_tsk_need_resched(p);
  1096. }
  1097. }
  1098. static void set_curr_task_rt(struct rq *rq)
  1099. {
  1100. struct task_struct *p = rq->curr;
  1101. p->se.exec_start = rq->clock;
  1102. }
  1103. static const struct sched_class rt_sched_class = {
  1104. .next = &fair_sched_class,
  1105. .enqueue_task = enqueue_task_rt,
  1106. .dequeue_task = dequeue_task_rt,
  1107. .yield_task = yield_task_rt,
  1108. #ifdef CONFIG_SMP
  1109. .select_task_rq = select_task_rq_rt,
  1110. #endif /* CONFIG_SMP */
  1111. .check_preempt_curr = check_preempt_curr_rt,
  1112. .pick_next_task = pick_next_task_rt,
  1113. .put_prev_task = put_prev_task_rt,
  1114. #ifdef CONFIG_SMP
  1115. .load_balance = load_balance_rt,
  1116. .move_one_task = move_one_task_rt,
  1117. .set_cpus_allowed = set_cpus_allowed_rt,
  1118. .rq_online = rq_online_rt,
  1119. .rq_offline = rq_offline_rt,
  1120. .pre_schedule = pre_schedule_rt,
  1121. .post_schedule = post_schedule_rt,
  1122. .task_wake_up = task_wake_up_rt,
  1123. .switched_from = switched_from_rt,
  1124. #endif
  1125. .set_curr_task = set_curr_task_rt,
  1126. .task_tick = task_tick_rt,
  1127. .prio_changed = prio_changed_rt,
  1128. .switched_to = switched_to_rt,
  1129. };