Run the "add_timer_on" and "apiadd_timer_on" commands in the kernel timer mechanism.
Add_timer_on
Add_timer_on is used to start a timer on the cpu specified by the parameter. the source code analysis is as follows: From this function, we can know that every cpu has a list of timer. if you do not specify the cpu when calling add_timer, it is actually running on the current cpu. Void add_timer_on (struct timer_list * timer, int cpu) {struct timer_base * new_base, * base; unsigned long flags; # If the callback function after the timer has been pending or timer expires is null, the current callstackBUG_ON (timer_pending (timer) is printed through BUG_ON |! Timer-> function); # obtain the timer_base pointer new_base = get_timer_cpu_base (timer-> flags, cpu) on the cpu specified by the parameter./** If @ timer was on a different CPU, it shoshould be migrated with the * old base locked to prevent other operations proceeding with the * wrong base locked. see lock_timer_base (). */# Lock base = lock_timer_base (timer, & flags); if (base! = New_base) {timer-> flags | = TIMER_MIGRATING; raw_spin_unlock (& base-> lock); base = new_base; raw_spin_lock (& base-> lock ); WRITE_ONCE (timer-> flags, (timer-> flags &~ TIMER_BASEMASK) | cpu) ;}# the base time may not be accurate if the cpu is in idle due to NOHZ or has just been out of idle, therefore, the system checks whether to adjust forward_timer_base (base); debug_activate (timer, timer-> expires); # Add the timeinternal_add_timer (base, timer) to the timer_base of the cpu specified by the parameter ); # unlock raw_spin_unlock_irqrestore (& base-> lock, flags );}