Community
cancel
Showing results for 
Search instead for 
Did you mean: 
xt_knight
Beginner
98 Views

Sending instructions to one core

I was wondering how to send a specific instruction to one core in a dual-core CPU. For example, I want to read the thermal status of the second core. I can't find out how to send a rdmsr instruction to the second core.

Is there another way by which I am supposed to be able to retrieve the temperature from the DTS (digital temperature sensor) of one core?
0 Kudos
5 Replies
James_M_Intel1
Employee
98 Views

A common way of doing this is to create a thread that is forced to run on the target core. If using Windows, for example, look at the SetThreadAffinityMask() function.

xt_knight
Beginner
98 Views

Thanks. I had thought of setting affinity but wasn't sure whether or not the RDMSR would just be sent to the first core anyway. So I will get the temperature of the second core by sending IA32_THERM_STATUS on a thread that's bound to the second core? Or are you not certain of that?
James_M_Intel1
Employee
98 Views

I've not tested it, but I believe that is correct.
prasadae
Beginner
98 Views

if you are on Linux, you can write a kernel module with the following: int temperature[NR_CPUS]; void get_temp(int cpu) { int this_cpu = smp_processor_id(); if(this_cpu == cpu) __temp_read(NULL); else smp_call_function_single(cpu,__temp_read,NULL,1,1); return temperature[cpu]; } void __temp_read(void *info) { u32 low,high; int cpu = get_cpu(); rdmsr(IA32_THERM_STATUS,low,high) temperature[cpu] = low | MASK; // get temp }
Dmitry_Vyukov
Valued Contributor I
98 Views

Quoting - prasadae
if you are on Linux, you can write a kernel module with the following: int temperature[NR_CPUS]; void get_temp(int cpu) { int this_cpu = smp_processor_id(); if(this_cpu == cpu) __temp_read(NULL); else smp_call_function_single(cpu,__temp_read,NULL,1,1); return temperature[cpu]; } void __temp_read(void *info) { u32 low,high; int cpu = get_cpu(); rdmsr(IA32_THERM_STATUS,low,high) temperature[cpu] = low | MASK; // get temp }

Or just use Linux NUMA API:

http://linux.die.net/man/3/numa_run_on_node

numa_run_on_node_mask() runs the current thread and its children only on nodes specified in nodemask. They will not migrate to CPUs of other nodes until the node affinity is reset with a new call to numa_run_on_node_mask(). Passing numa_all_nodes permits the kernel to schedule on all nodes again.


Reply