Solved emulate get_cpu()

alemoppo

New Member

Reaction score: 1
Messages: 19

Hello

I'm trying to get the current CPU number that is executing the code (in driver kernel). In linux we have get_cpu(). What's the analogue in FreeBSD?

My goal is currently execute the same function c in all the CPUs with the "smp_rendezvous()", then print the number of each CPU.
In linux I can do it with smp_call_function() + get_cpu(). How i can do this in FreeBSD?

Thank you,
Best Regards.
 
OP
alemoppo

alemoppo

New Member

Reaction score: 1
Messages: 19

No, the previous was how to read the number of cpus in the system (in linux is: num_online_cpus()). Now I'm searching to read the number of the current CPU (in linux is get_cpu()), thanks.


UPDATE:
maybe i found it, is: PCPU_GET(cpuid).

The question now is: i have 3 core in the virtual machine running FreeBSD. Why smp_rendezvous() call just 1 time the function? Shouldn't it call the same function for all CPUs?

Could the problem be since the FreeBSD installation I did it with 1 CPU, and then I added 2 CPU to the virtual machine? (after the installation).
hw.ncpu is 3, so FreeBSD has noticed the change.

Thanks.
 

W.hâ/t

New Member


Messages: 3

I'm pretty confident you'll find an answer by typing man -k cpu or man -k pcpu
Although linux can "run" in FreeBSD, FreeBSD is not linux.
 
Top