Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/core: Remove the tsk_nr_cpus_allowed() wrapper

tsk_nr_cpus_allowed() too is a pretty pointless wrapper that
is not used consistently and which makes the code both harder
to read and longer as well.

So remove it - this also shrinks <linux/sched.h> a bit.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

+27 -32
-5
include/linux/sched.h
··· 1995 1995 } 1996 1996 #endif 1997 1997 1998 - static inline int tsk_nr_cpus_allowed(struct task_struct *p) 1999 - { 2000 - return p->nr_cpus_allowed; 2001 - } 2002 - 2003 1998 #define TNF_MIGRATED 0x01 2004 1999 #define TNF_NO_GROUP 0x02 2005 2000 #define TNF_SHARED 0x04
+1 -1
kernel/sched/core.c
··· 1549 1549 { 1550 1550 lockdep_assert_held(&p->pi_lock); 1551 1551 1552 - if (tsk_nr_cpus_allowed(p) > 1) 1552 + if (p->nr_cpus_allowed > 1) 1553 1553 cpu = p->sched_class->select_task_rq(p, cpu, sd_flags, wake_flags); 1554 1554 else 1555 1555 cpu = cpumask_any(&p->cpus_allowed);
+14 -14
kernel/sched/deadline.c
··· 134 134 { 135 135 struct task_struct *p = dl_task_of(dl_se); 136 136 137 - if (tsk_nr_cpus_allowed(p) > 1) 137 + if (p->nr_cpus_allowed > 1) 138 138 dl_rq->dl_nr_migratory++; 139 139 140 140 update_dl_migration(dl_rq); ··· 144 144 { 145 145 struct task_struct *p = dl_task_of(dl_se); 146 146 147 - if (tsk_nr_cpus_allowed(p) > 1) 147 + if (p->nr_cpus_allowed > 1) 148 148 dl_rq->dl_nr_migratory--; 149 149 150 150 update_dl_migration(dl_rq); ··· 958 958 959 959 enqueue_dl_entity(&p->dl, pi_se, flags); 960 960 961 - if (!task_current(rq, p) && tsk_nr_cpus_allowed(p) > 1) 961 + if (!task_current(rq, p) && p->nr_cpus_allowed > 1) 962 962 enqueue_pushable_dl_task(rq, p); 963 963 } 964 964 ··· 1032 1032 * try to make it stay here, it might be important. 1033 1033 */ 1034 1034 if (unlikely(dl_task(curr)) && 1035 - (tsk_nr_cpus_allowed(curr) < 2 || 1035 + (curr->nr_cpus_allowed < 2 || 1036 1036 !dl_entity_preempt(&p->dl, &curr->dl)) && 1037 - (tsk_nr_cpus_allowed(p) > 1)) { 1037 + (p->nr_cpus_allowed > 1)) { 1038 1038 int target = find_later_rq(p); 1039 1039 1040 1040 if (target != -1 && ··· 1055 1055 * Current can't be migrated, useless to reschedule, 1056 1056 * let's hope p can move out. 1057 1057 */ 1058 - if (tsk_nr_cpus_allowed(rq->curr) == 1 || 1058 + if (rq->curr->nr_cpus_allowed == 1 || 1059 1059 cpudl_find(&rq->rd->cpudl, rq->curr, NULL) == -1) 1060 1060 return; 1061 1061 ··· 1063 1063 * p is migratable, so let's not schedule it and 1064 1064 * see if it is pushed or pulled somewhere else. 1065 1065 */ 1066 - if (tsk_nr_cpus_allowed(p) != 1 && 1066 + if (p->nr_cpus_allowed != 1 && 1067 1067 cpudl_find(&rq->rd->cpudl, p, NULL) != -1) 1068 1068 return; 1069 1069 ··· 1178 1178 { 1179 1179 update_curr_dl(rq); 1180 1180 1181 - if (on_dl_rq(&p->dl) && tsk_nr_cpus_allowed(p) > 1) 1181 + if (on_dl_rq(&p->dl) && p->nr_cpus_allowed > 1) 1182 1182 enqueue_pushable_dl_task(rq, p); 1183 1183 } 1184 1184 ··· 1279 1279 if (unlikely(!later_mask)) 1280 1280 return -1; 1281 1281 1282 - if (tsk_nr_cpus_allowed(task) == 1) 1282 + if (task->nr_cpus_allowed == 1) 1283 1283 return -1; 1284 1284 1285 1285 /* ··· 1424 1424 1425 1425 BUG_ON(rq->cpu != task_cpu(p)); 1426 1426 BUG_ON(task_current(rq, p)); 1427 - BUG_ON(tsk_nr_cpus_allowed(p) <= 1); 1427 + BUG_ON(p->nr_cpus_allowed <= 1); 1428 1428 1429 1429 BUG_ON(!task_on_rq_queued(p)); 1430 1430 BUG_ON(!dl_task(p)); ··· 1463 1463 */ 1464 1464 if (dl_task(rq->curr) && 1465 1465 dl_time_before(next_task->dl.deadline, rq->curr->dl.deadline) && 1466 - tsk_nr_cpus_allowed(rq->curr) > 1) { 1466 + rq->curr->nr_cpus_allowed > 1) { 1467 1467 resched_curr(rq); 1468 1468 return 0; 1469 1469 } ··· 1610 1610 { 1611 1611 if (!task_running(rq, p) && 1612 1612 !test_tsk_need_resched(rq->curr) && 1613 - tsk_nr_cpus_allowed(p) > 1 && 1613 + p->nr_cpus_allowed > 1 && 1614 1614 dl_task(rq->curr) && 1615 - (tsk_nr_cpus_allowed(rq->curr) < 2 || 1615 + (rq->curr->nr_cpus_allowed < 2 || 1616 1616 !dl_entity_preempt(&p->dl, &rq->curr->dl))) { 1617 1617 push_dl_tasks(rq); 1618 1618 } ··· 1726 1726 1727 1727 if (rq->curr != p) { 1728 1728 #ifdef CONFIG_SMP 1729 - if (tsk_nr_cpus_allowed(p) > 1 && rq->dl.overloaded) 1729 + if (p->nr_cpus_allowed > 1 && rq->dl.overloaded) 1730 1730 queue_push_tasks(rq); 1731 1731 #endif 1732 1732 if (dl_task(rq->curr))
+12 -12
kernel/sched/rt.c
··· 335 335 rt_rq = &rq_of_rt_rq(rt_rq)->rt; 336 336 337 337 rt_rq->rt_nr_total++; 338 - if (tsk_nr_cpus_allowed(p) > 1) 338 + if (p->nr_cpus_allowed > 1) 339 339 rt_rq->rt_nr_migratory++; 340 340 341 341 update_rt_migration(rt_rq); ··· 352 352 rt_rq = &rq_of_rt_rq(rt_rq)->rt; 353 353 354 354 rt_rq->rt_nr_total--; 355 - if (tsk_nr_cpus_allowed(p) > 1) 355 + if (p->nr_cpus_allowed > 1) 356 356 rt_rq->rt_nr_migratory--; 357 357 358 358 update_rt_migration(rt_rq); ··· 1324 1324 1325 1325 enqueue_rt_entity(rt_se, flags); 1326 1326 1327 - if (!task_current(rq, p) && tsk_nr_cpus_allowed(p) > 1) 1327 + if (!task_current(rq, p) && p->nr_cpus_allowed > 1) 1328 1328 enqueue_pushable_task(rq, p); 1329 1329 } 1330 1330 ··· 1413 1413 * will have to sort it out. 1414 1414 */ 1415 1415 if (curr && unlikely(rt_task(curr)) && 1416 - (tsk_nr_cpus_allowed(curr) < 2 || 1416 + (curr->nr_cpus_allowed < 2 || 1417 1417 curr->prio <= p->prio)) { 1418 1418 int target = find_lowest_rq(p); 1419 1419 ··· 1437 1437 * Current can't be migrated, useless to reschedule, 1438 1438 * let's hope p can move out. 1439 1439 */ 1440 - if (tsk_nr_cpus_allowed(rq->curr) == 1 || 1440 + if (rq->curr->nr_cpus_allowed == 1 || 1441 1441 !cpupri_find(&rq->rd->cpupri, rq->curr, NULL)) 1442 1442 return; 1443 1443 ··· 1445 1445 * p is migratable, so let's not schedule it and 1446 1446 * see if it is pushed or pulled somewhere else. 1447 1447 */ 1448 - if (tsk_nr_cpus_allowed(p) != 1 1448 + if (p->nr_cpus_allowed != 1 1449 1449 && cpupri_find(&rq->rd->cpupri, p, NULL)) 1450 1450 return; 1451 1451 ··· 1579 1579 * The previous task needs to be made eligible for pushing 1580 1580 * if it is still active 1581 1581 */ 1582 - if (on_rt_rq(&p->rt) && tsk_nr_cpus_allowed(p) > 1) 1582 + if (on_rt_rq(&p->rt) && p->nr_cpus_allowed > 1) 1583 1583 enqueue_pushable_task(rq, p); 1584 1584 } 1585 1585 ··· 1629 1629 if (unlikely(!lowest_mask)) 1630 1630 return -1; 1631 1631 1632 - if (tsk_nr_cpus_allowed(task) == 1) 1632 + if (task->nr_cpus_allowed == 1) 1633 1633 return -1; /* No other targets possible */ 1634 1634 1635 1635 if (!cpupri_find(&task_rq(task)->rd->cpupri, task, lowest_mask)) ··· 1761 1761 1762 1762 BUG_ON(rq->cpu != task_cpu(p)); 1763 1763 BUG_ON(task_current(rq, p)); 1764 - BUG_ON(tsk_nr_cpus_allowed(p) <= 1); 1764 + BUG_ON(p->nr_cpus_allowed <= 1); 1765 1765 1766 1766 BUG_ON(!task_on_rq_queued(p)); 1767 1767 BUG_ON(!rt_task(p)); ··· 2121 2121 { 2122 2122 if (!task_running(rq, p) && 2123 2123 !test_tsk_need_resched(rq->curr) && 2124 - tsk_nr_cpus_allowed(p) > 1 && 2124 + p->nr_cpus_allowed > 1 && 2125 2125 (dl_task(rq->curr) || rt_task(rq->curr)) && 2126 - (tsk_nr_cpus_allowed(rq->curr) < 2 || 2126 + (rq->curr->nr_cpus_allowed < 2 || 2127 2127 rq->curr->prio <= p->prio)) 2128 2128 push_rt_tasks(rq); 2129 2129 } ··· 2196 2196 */ 2197 2197 if (task_on_rq_queued(p) && rq->curr != p) { 2198 2198 #ifdef CONFIG_SMP 2199 - if (tsk_nr_cpus_allowed(p) > 1 && rq->rt.overloaded) 2199 + if (p->nr_cpus_allowed > 1 && rq->rt.overloaded) 2200 2200 queue_push_tasks(rq); 2201 2201 #endif /* CONFIG_SMP */ 2202 2202 if (p->prio < rq->curr->prio)