I need to enable cr4 bit 8 (PCE) on all cores of a given system. I currently have a working module which sets this bit on the core it runs on when the module is loaded. I am stuck here and haven't found much documentation on how to parallelize this to run on all cores:
1) It appears that the unload doesn't always happen on the core the load happened on, so I can't clean up correctly
2) I can't figure out any way to force the module initialization to be executed on a particular core - if I could, I could simply have have a module can be called separately for each core to set all cores. There doesn't seem to be a sched_setaffinity equivalent available for modules.
Is there any way to force this module to run on all cores, either through parallelization or iterating across all cores? I can't modify the kernel itself or make the module load at boot, so I can't just change what the register is initially set to.
Thanks for any hints, I'm going crazy here trying to figure this out!
Figured it out - smp_call_function() calls a function on all cores of the system. It's just very tricky to get a search result that brings this up (little / no documentation) :-/
This works perfectly, and you can verify each core runs the code by printing smp_processor_id() within the called function.
EDIT: This function only calls other cores, so you still have to call the function once separately to get the core the module is currently running on!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With