Linux multi-cpu load balancing - thread migration

  

move_tasks() is called in several places: 1. load_balance()2. migrate_thread()---migration_threadload balance at each clock beat by scheduler_tick()---> Rebalance_tick() call. Rebalance_tick begins to loop over all scheduling domains, from the base domain (the sd field of the local run queue) to the topmost domain (see page 286 to know what's the meaning "schedule feilf"). Load_balance attempts to migrate the processes of the busiest group in this scheduling domain to the run queue on the local cpu. If the move_task call in load_balance fails, wake up the migration thread to idle the cpu along the chain search of the dispatch domain (from the base domain of the busiest run queue to the topmost). In addition to the load_balance wakeup, the migration thread is called in several cases: 1. do_exec system call, find free cpu to load new process 2. change cpu affinity affinity 3. migration_call(), when cpu increases or decreases 4. When updating the cpu domain, (supporting cpu hot plugging) 5. load_balance_newidlemove_task first scans the busiest rq expiration process according to the priority, and then scans the goods to the process. When it is found, it calls pull_task to migrate. The so-called migration refers to calling dequeue_task() first. Remove from the far end), then call enqueue_task() (insert locally). If the new process has a higher priority than the current process, call reschedule_task() to preempt the local cpu. The parameter max_nr_move passed in here is used to limit the maximum number of migration processes. There are several conditions that can be migrated, see page 289 of linux kernel 3rd.sched_getaffinity() and sched_setaffinity(): Set the bitmask of the cpu that allows the process.

Copyright © Windows knowledge All Rights Reserved