简体   繁体   中英

How to measure process migration time from one core to another on linux?

On linux we can make a cpu core offline by the command :

echo 0 > /sys/devices/system/cpu/<core num>/online. 

This causes the processes running on that core to be migrated to other cores. What I need to do is to measure the time it takes to migrate a process from one core to another. How should I do this ?

Migration time of a process from one core to another core is equal to the time needed to take the process state from one core and write this architectural state back to the new core. This is equal to the time of a context switch. You can find many samples, eg this one , to measure the context switch time of a process in Linux.

ps Changing the affinity is a better way to migrate a process to another core instead of making the core online or offline.

You can take a look to cpuid . I suppose you could pool the cpu serial number and see when it changes. The problem is that it will include not only the migration time but also the time the process has been waiting for to be executed in the new cpu it's been allocated to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM