Set control registers on all cores
I need to enable cr4-bit 8 (PCE) on all cores of a given system. I currently have a working module that sets this bit on the core it runs on when loading the module. I’m stuck here and haven’t found much documentation on how to parallelize it to run on all cores :
1) It seems that unloading doesn’t always happen on the core where the load occurs, so I can’t clean up properly
2) I can’t think of any way to force module initialization to be performed on a specific kernel – I can simply call a module individually for each core to set up all cores if I can. There doesn’t seem to be an sched_setaffinity equivalent available for modules.
Is there any way to force the module to run on all cores by parallelizing or traversing all cores? I can’t modify the kernel itself or make the module load at startup, so I can’t just change the initial settings of the registers.
Thanks for any tips, I’m frantically trying to fix this!
Figured it out – smp_call_function() calls a function on all cores of the system. Getting a search result with this problem is tricky (little/no documentation) :-/
This works very well, and you can verify that each kernel is running code by printing smp_processor_id() in the called function.
EDIT: This function only calls other cores, so you still need to call the function once separately to get the core that the module is currently running!