unsigned int smp_processor_id(void)
{
unsigned long preempt_count = preempt_count();
int this_cpu = __smp_processor_id();
cpumask_t this_mask;
if (likely(preempt_count))
goto out;
if (irqs_disabled())
goto out;
根据处理器编号cpu,将处理器位图的相应位置置为1(其它位为0)
|-----------------------------------------|
| this_mask = cpumask_of_cpu(this_cpu); |
|-----------------------------------------|
检测该当前进程所在处理器是否可以执行该进程,如果可以则返回1,否则返回0
|-----------------------------------------------------|
| if ( cpus_equal(current->cpus_allowed, this_mask)) |
| goto out; |
|-----------------------------------------------------|
if (system_state != SYSTEM_RUNNING)
goto out;
preempt_disable();
if (!printk_ratelimit())
goto out_enable;
printk(KERN_ERR "BUG: using smp_processor_id() in preemptible [%08x] code: %s/%d/n", preempt_count(), current->comm, current->pid);
print_symbol("caller is %s/n", (long)__builtin_return_address(0));
dump_stack();
out_enable:
preempt_enable_no_resched();
out:
return this_cpu;
}
#define __smp_processor_id() (current_thread_info()->cpu)
task_struct.cpus_allowed Bitmask of the CPUs that can execute the process
可以执行该进程的CPU掩码集
{
unsigned long preempt_count = preempt_count();
int this_cpu = __smp_processor_id();
cpumask_t this_mask;
if (likely(preempt_count))
goto out;
if (irqs_disabled())
goto out;
根据处理器编号cpu,将处理器位图的相应位置置为1(其它位为0)
|-----------------------------------------|
| this_mask = cpumask_of_cpu(this_cpu); |
|-----------------------------------------|
检测该当前进程所在处理器是否可以执行该进程,如果可以则返回1,否则返回0
|-----------------------------------------------------|
| if ( cpus_equal(current->cpus_allowed, this_mask)) |
| goto out; |
|-----------------------------------------------------|
if (system_state != SYSTEM_RUNNING)
goto out;
preempt_disable();
if (!printk_ratelimit())
goto out_enable;
printk(KERN_ERR "BUG: using smp_processor_id() in preemptible [%08x] code: %s/%d/n", preempt_count(), current->comm, current->pid);
print_symbol("caller is %s/n", (long)__builtin_return_address(0));
dump_stack();
out_enable:
preempt_enable_no_resched();
out:
return this_cpu;
}
#define __smp_processor_id() (current_thread_info()->cpu)
task_struct.cpus_allowed Bitmask of the CPUs that can execute the process
可以执行该进程的CPU掩码集