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_cpus_allowed() wrapper

So the original intention of tsk_cpus_allowed() was to 'future-proof'
the field - but it's pretty ineffectual at that, because half of
the code uses ->cpus_allowed directly ...

Also, the wrapper makes the code longer than the original expression!

So just get rid of 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>

+42 -48
+1 -1
arch/powerpc/kernel/smp.c
··· 795 795 * se we pin us down to CPU 0 for a short while 796 796 */ 797 797 alloc_cpumask_var(&old_mask, GFP_NOWAIT); 798 - cpumask_copy(old_mask, tsk_cpus_allowed(current)); 798 + cpumask_copy(old_mask, &current->cpus_allowed); 799 799 set_cpus_allowed_ptr(current, cpumask_of(boot_cpuid)); 800 800 801 801 if (smp_ops && smp_ops->setup_cpu)
+1 -1
arch/powerpc/platforms/cell/spufs/sched.c
··· 140 140 * runqueue. The context will be rescheduled on the proper node 141 141 * if it is timesliced or preempted. 142 142 */ 143 - cpumask_copy(&ctx->cpus_allowed, tsk_cpus_allowed(current)); 143 + cpumask_copy(&ctx->cpus_allowed, &current->cpus_allowed); 144 144 145 145 /* Save the current cpu id for spu interrupt routing. */ 146 146 ctx->last_ran = raw_smp_processor_id();
+1 -1
arch/sparc/kernel/sysfs.c
··· 106 106 cpumask_t old_affinity; 107 107 unsigned long ret; 108 108 109 - cpumask_copy(&old_affinity, tsk_cpus_allowed(current)); 109 + cpumask_copy(&old_affinity, &current->cpus_allowed); 110 110 /* should return -EINVAL to userspace */ 111 111 if (set_cpus_allowed_ptr(current, cpumask_of(cpu))) 112 112 return 0;
+2 -2
drivers/cpufreq/sparc-us2e-cpufreq.c
··· 234 234 cpumask_t cpus_allowed; 235 235 unsigned long clock_tick, estar; 236 236 237 - cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current)); 237 + cpumask_copy(&cpus_allowed, &current->cpus_allowed); 238 238 set_cpus_allowed_ptr(current, cpumask_of(cpu)); 239 239 240 240 clock_tick = sparc64_get_clock_tick(cpu) / 1000; ··· 252 252 unsigned long clock_tick, divisor, old_divisor, estar; 253 253 cpumask_t cpus_allowed; 254 254 255 - cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current)); 255 + cpumask_copy(&cpus_allowed, &current->cpus_allowed); 256 256 set_cpus_allowed_ptr(current, cpumask_of(cpu)); 257 257 258 258 new_freq = clock_tick = sparc64_get_clock_tick(cpu) / 1000;
+2 -2
drivers/cpufreq/sparc-us3-cpufreq.c
··· 82 82 unsigned long reg; 83 83 unsigned int ret; 84 84 85 - cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current)); 85 + cpumask_copy(&cpus_allowed, &current->cpus_allowed); 86 86 set_cpus_allowed_ptr(current, cpumask_of(cpu)); 87 87 88 88 reg = read_safari_cfg(); ··· 99 99 unsigned long new_bits, new_freq, reg; 100 100 cpumask_t cpus_allowed; 101 101 102 - cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current)); 102 + cpumask_copy(&cpus_allowed, &current->cpus_allowed); 103 103 set_cpus_allowed_ptr(current, cpumask_of(cpu)); 104 104 105 105 new_freq = sparc64_get_clock_tick(cpu) / 1000;
+1 -1
drivers/infiniband/hw/hfi1/affinity.c
··· 576 576 struct hfi1_affinity_node *entry; 577 577 cpumask_var_t diff, hw_thread_mask, available_mask, intrs_mask; 578 578 const struct cpumask *node_mask, 579 - *proc_mask = tsk_cpus_allowed(current); 579 + *proc_mask = &current->cpus_allowed; 580 580 struct hfi1_affinity_node_list *affinity = &node_affinity; 581 581 struct cpu_mask_set *set = &affinity->proc; 582 582
+1 -1
drivers/infiniband/hw/hfi1/sdma.c
··· 856 856 { 857 857 struct sdma_rht_node *rht_node; 858 858 struct sdma_engine *sde = NULL; 859 - const struct cpumask *current_mask = tsk_cpus_allowed(current); 859 + const struct cpumask *current_mask = &current->cpus_allowed; 860 860 unsigned long cpu_id; 861 861 862 862 /*
-3
include/linux/sched.h
··· 1995 1995 } 1996 1996 #endif 1997 1997 1998 - /* Future-safe accessor for struct task_struct's cpus_allowed. */ 1999 - #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed) 2000 - 2001 1998 static inline int tsk_nr_cpus_allowed(struct task_struct *p) 2002 1999 { 2003 2000 return p->nr_cpus_allowed;
+10 -10
kernel/sched/core.c
··· 981 981 return rq; 982 982 983 983 /* Affinity changed (again). */ 984 - if (!cpumask_test_cpu(dest_cpu, tsk_cpus_allowed(p))) 984 + if (!cpumask_test_cpu(dest_cpu, &p->cpus_allowed)) 985 985 return rq; 986 986 987 987 rq = move_queued_task(rq, p, dest_cpu); ··· 1259 1259 if (task_cpu(arg->src_task) != arg->src_cpu) 1260 1260 goto unlock; 1261 1261 1262 - if (!cpumask_test_cpu(arg->dst_cpu, tsk_cpus_allowed(arg->src_task))) 1262 + if (!cpumask_test_cpu(arg->dst_cpu, &arg->src_task->cpus_allowed)) 1263 1263 goto unlock; 1264 1264 1265 - if (!cpumask_test_cpu(arg->src_cpu, tsk_cpus_allowed(arg->dst_task))) 1265 + if (!cpumask_test_cpu(arg->src_cpu, &arg->dst_task->cpus_allowed)) 1266 1266 goto unlock; 1267 1267 1268 1268 __migrate_swap_task(arg->src_task, arg->dst_cpu); ··· 1303 1303 if (!cpu_active(arg.src_cpu) || !cpu_active(arg.dst_cpu)) 1304 1304 goto out; 1305 1305 1306 - if (!cpumask_test_cpu(arg.dst_cpu, tsk_cpus_allowed(arg.src_task))) 1306 + if (!cpumask_test_cpu(arg.dst_cpu, &arg.src_task->cpus_allowed)) 1307 1307 goto out; 1308 1308 1309 - if (!cpumask_test_cpu(arg.src_cpu, tsk_cpus_allowed(arg.dst_task))) 1309 + if (!cpumask_test_cpu(arg.src_cpu, &arg.dst_task->cpus_allowed)) 1310 1310 goto out; 1311 1311 1312 1312 trace_sched_swap_numa(cur, arg.src_cpu, p, arg.dst_cpu); ··· 1490 1490 for_each_cpu(dest_cpu, nodemask) { 1491 1491 if (!cpu_active(dest_cpu)) 1492 1492 continue; 1493 - if (cpumask_test_cpu(dest_cpu, tsk_cpus_allowed(p))) 1493 + if (cpumask_test_cpu(dest_cpu, &p->cpus_allowed)) 1494 1494 return dest_cpu; 1495 1495 } 1496 1496 } 1497 1497 1498 1498 for (;;) { 1499 1499 /* Any allowed, online CPU? */ 1500 - for_each_cpu(dest_cpu, tsk_cpus_allowed(p)) { 1500 + for_each_cpu(dest_cpu, &p->cpus_allowed) { 1501 1501 if (!(p->flags & PF_KTHREAD) && !cpu_active(dest_cpu)) 1502 1502 continue; 1503 1503 if (!cpu_online(dest_cpu)) ··· 1552 1552 if (tsk_nr_cpus_allowed(p) > 1) 1553 1553 cpu = p->sched_class->select_task_rq(p, cpu, sd_flags, wake_flags); 1554 1554 else 1555 - cpu = cpumask_any(tsk_cpus_allowed(p)); 1555 + cpu = cpumask_any(&p->cpus_allowed); 1556 1556 1557 1557 /* 1558 1558 * In order not to call set_task_cpu() on a blocking task we need ··· 1564 1564 * [ this allows ->select_task() to simply return task_cpu(p) and 1565 1565 * not worry about this generic constraint ] 1566 1566 */ 1567 - if (unlikely(!cpumask_test_cpu(cpu, tsk_cpus_allowed(p)) || 1567 + if (unlikely(!cpumask_test_cpu(cpu, &p->cpus_allowed) || 1568 1568 !cpu_online(cpu))) 1569 1569 cpu = select_fallback_rq(task_cpu(p), p); 1570 1570 ··· 5473 5473 if (curr_cpu == target_cpu) 5474 5474 return 0; 5475 5475 5476 - if (!cpumask_test_cpu(target_cpu, tsk_cpus_allowed(p))) 5476 + if (!cpumask_test_cpu(target_cpu, &p->cpus_allowed)) 5477 5477 return -EINVAL; 5478 5478 5479 5479 /* TODO: This is not properly updating schedstats */
+2 -2
kernel/sched/cpudeadline.c
··· 128 128 const struct sched_dl_entity *dl_se = &p->dl; 129 129 130 130 if (later_mask && 131 - cpumask_and(later_mask, cp->free_cpus, tsk_cpus_allowed(p))) { 131 + cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed)) { 132 132 best_cpu = cpumask_any(later_mask); 133 133 goto out; 134 - } else if (cpumask_test_cpu(cpudl_maximum(cp), tsk_cpus_allowed(p)) && 134 + } else if (cpumask_test_cpu(cpudl_maximum(cp), &p->cpus_allowed) && 135 135 dl_time_before(dl_se->deadline, cp->elements[0].dl)) { 136 136 best_cpu = cpudl_maximum(cp); 137 137 if (later_mask)
+2 -2
kernel/sched/cpupri.c
··· 103 103 if (skip) 104 104 continue; 105 105 106 - if (cpumask_any_and(tsk_cpus_allowed(p), vec->mask) >= nr_cpu_ids) 106 + if (cpumask_any_and(&p->cpus_allowed, vec->mask) >= nr_cpu_ids) 107 107 continue; 108 108 109 109 if (lowest_mask) { 110 - cpumask_and(lowest_mask, tsk_cpus_allowed(p), vec->mask); 110 + cpumask_and(lowest_mask, &p->cpus_allowed, vec->mask); 111 111 112 112 /* 113 113 * We have to ensure that we have at least one bit
+3 -4
kernel/sched/deadline.c
··· 252 252 * If we cannot preempt any rq, fall back to pick any 253 253 * online cpu. 254 254 */ 255 - cpu = cpumask_any_and(cpu_active_mask, tsk_cpus_allowed(p)); 255 + cpu = cpumask_any_and(cpu_active_mask, &p->cpus_allowed); 256 256 if (cpu >= nr_cpu_ids) { 257 257 /* 258 258 * Fail to find any suitable cpu. ··· 1235 1235 static int pick_dl_task(struct rq *rq, struct task_struct *p, int cpu) 1236 1236 { 1237 1237 if (!task_running(rq, p) && 1238 - cpumask_test_cpu(cpu, tsk_cpus_allowed(p))) 1238 + cpumask_test_cpu(cpu, &p->cpus_allowed)) 1239 1239 return 1; 1240 1240 return 0; 1241 1241 } ··· 1384 1384 /* Retry if something changed. */ 1385 1385 if (double_lock_balance(rq, later_rq)) { 1386 1386 if (unlikely(task_rq(task) != rq || 1387 - !cpumask_test_cpu(later_rq->cpu, 1388 - tsk_cpus_allowed(task)) || 1387 + !cpumask_test_cpu(later_rq->cpu, &task->cpus_allowed) || 1389 1388 task_running(rq, task) || 1390 1389 !dl_task(task) || 1391 1390 !task_on_rq_queued(task))) {
+12 -13
kernel/sched/fair.c
··· 1551 1551 */ 1552 1552 if (cur) { 1553 1553 /* Skip this swap candidate if cannot move to the source cpu */ 1554 - if (!cpumask_test_cpu(env->src_cpu, tsk_cpus_allowed(cur))) 1554 + if (!cpumask_test_cpu(env->src_cpu, &cur->cpus_allowed)) 1555 1555 goto unlock; 1556 1556 1557 1557 /* ··· 1661 1661 1662 1662 for_each_cpu(cpu, cpumask_of_node(env->dst_nid)) { 1663 1663 /* Skip this CPU if the source task cannot migrate */ 1664 - if (!cpumask_test_cpu(cpu, tsk_cpus_allowed(env->p))) 1664 + if (!cpumask_test_cpu(cpu, &env->p->cpus_allowed)) 1665 1665 continue; 1666 1666 1667 1667 env->dst_cpu = cpu; ··· 5458 5458 5459 5459 /* Skip over this group if it has no CPUs allowed */ 5460 5460 if (!cpumask_intersects(sched_group_cpus(group), 5461 - tsk_cpus_allowed(p))) 5461 + &p->cpus_allowed)) 5462 5462 continue; 5463 5463 5464 5464 local_group = cpumask_test_cpu(this_cpu, ··· 5578 5578 return cpumask_first(sched_group_cpus(group)); 5579 5579 5580 5580 /* Traverse only the allowed CPUs */ 5581 - for_each_cpu_and(i, sched_group_cpus(group), tsk_cpus_allowed(p)) { 5581 + for_each_cpu_and(i, sched_group_cpus(group), &p->cpus_allowed) { 5582 5582 if (idle_cpu(i)) { 5583 5583 struct rq *rq = cpu_rq(i); 5584 5584 struct cpuidle_state *idle = idle_get_state(rq); ··· 5717 5717 if (!test_idle_cores(target, false)) 5718 5718 return -1; 5719 5719 5720 - cpumask_and(cpus, sched_domain_span(sd), tsk_cpus_allowed(p)); 5720 + cpumask_and(cpus, sched_domain_span(sd), &p->cpus_allowed); 5721 5721 5722 5722 for_each_cpu_wrap(core, cpus, target, wrap) { 5723 5723 bool idle = true; ··· 5751 5751 return -1; 5752 5752 5753 5753 for_each_cpu(cpu, cpu_smt_mask(target)) { 5754 - if (!cpumask_test_cpu(cpu, tsk_cpus_allowed(p))) 5754 + if (!cpumask_test_cpu(cpu, &p->cpus_allowed)) 5755 5755 continue; 5756 5756 if (idle_cpu(cpu)) 5757 5757 return cpu; ··· 5803 5803 time = local_clock(); 5804 5804 5805 5805 for_each_cpu_wrap(cpu, sched_domain_span(sd), target, wrap) { 5806 - if (!cpumask_test_cpu(cpu, tsk_cpus_allowed(p))) 5806 + if (!cpumask_test_cpu(cpu, &p->cpus_allowed)) 5807 5807 continue; 5808 5808 if (idle_cpu(cpu)) 5809 5809 break; ··· 5958 5958 if (sd_flag & SD_BALANCE_WAKE) { 5959 5959 record_wakee(p); 5960 5960 want_affine = !wake_wide(p) && !wake_cap(p, cpu, prev_cpu) 5961 - && cpumask_test_cpu(cpu, tsk_cpus_allowed(p)); 5961 + && cpumask_test_cpu(cpu, &p->cpus_allowed); 5962 5962 } 5963 5963 5964 5964 rcu_read_lock(); ··· 6698 6698 if (throttled_lb_pair(task_group(p), env->src_cpu, env->dst_cpu)) 6699 6699 return 0; 6700 6700 6701 - if (!cpumask_test_cpu(env->dst_cpu, tsk_cpus_allowed(p))) { 6701 + if (!cpumask_test_cpu(env->dst_cpu, &p->cpus_allowed)) { 6702 6702 int cpu; 6703 6703 6704 6704 schedstat_inc(p->se.statistics.nr_failed_migrations_affine); ··· 6718 6718 6719 6719 /* Prevent to re-select dst_cpu via env's cpus */ 6720 6720 for_each_cpu_and(cpu, env->dst_grpmask, env->cpus) { 6721 - if (cpumask_test_cpu(cpu, tsk_cpus_allowed(p))) { 6721 + if (cpumask_test_cpu(cpu, &p->cpus_allowed)) { 6722 6722 env->flags |= LBF_DST_PINNED; 6723 6723 env->new_dst_cpu = cpu; 6724 6724 break; ··· 7252 7252 7253 7253 /* 7254 7254 * Group imbalance indicates (and tries to solve) the problem where balancing 7255 - * groups is inadequate due to tsk_cpus_allowed() constraints. 7255 + * groups is inadequate due to ->cpus_allowed constraints. 7256 7256 * 7257 7257 * Imagine a situation of two groups of 4 cpus each and 4 tasks each with a 7258 7258 * cpumask covering 1 cpu of the first group and 3 cpus of the second group. ··· 8211 8211 * if the curr task on busiest cpu can't be 8212 8212 * moved to this_cpu 8213 8213 */ 8214 - if (!cpumask_test_cpu(this_cpu, 8215 - tsk_cpus_allowed(busiest->curr))) { 8214 + if (!cpumask_test_cpu(this_cpu, &busiest->curr->cpus_allowed)) { 8216 8215 raw_spin_unlock_irqrestore(&busiest->lock, 8217 8216 flags); 8218 8217 env.flags |= LBF_ALL_PINNED;
+2 -3
kernel/sched/rt.c
··· 1591 1591 static int pick_rt_task(struct rq *rq, struct task_struct *p, int cpu) 1592 1592 { 1593 1593 if (!task_running(rq, p) && 1594 - cpumask_test_cpu(cpu, tsk_cpus_allowed(p))) 1594 + cpumask_test_cpu(cpu, &p->cpus_allowed)) 1595 1595 return 1; 1596 1596 return 0; 1597 1597 } ··· 1726 1726 * Also make sure that it wasn't scheduled on its rq. 1727 1727 */ 1728 1728 if (unlikely(task_rq(task) != rq || 1729 - !cpumask_test_cpu(lowest_rq->cpu, 1730 - tsk_cpus_allowed(task)) || 1729 + !cpumask_test_cpu(lowest_rq->cpu, &task->cpus_allowed) || 1731 1730 task_running(rq, task) || 1732 1731 !rt_task(task) || 1733 1732 !task_on_rq_queued(task))) {
+1 -1
lib/smp_processor_id.c
··· 22 22 * Kernel threads bound to a single CPU can safely use 23 23 * smp_processor_id(): 24 24 */ 25 - if (cpumask_equal(tsk_cpus_allowed(current), cpumask_of(this_cpu))) 25 + if (cpumask_equal(&current->cpus_allowed, cpumask_of(this_cpu))) 26 26 goto out; 27 27 28 28 /*
+1 -1
samples/trace_events/trace-events-sample.c
··· 33 33 34 34 /* Silly tracepoints */ 35 35 trace_foo_bar("hello", cnt, array, random_strings[len], 36 - tsk_cpus_allowed(current)); 36 + &current->cpus_allowed); 37 37 38 38 trace_foo_with_template_simple("HELLO", cnt); 39 39