On Sat, Jan 3, 2009 at 12:35 AM, Peter Teoh <htmldeveloper@xxxxxxxxx> wrote: > On Fri, Jan 2, 2009 at 5:55 PM, Shyam Burkule <shyam.burkule@xxxxxxxxx> wrote: >> Hi All, >> >> In Understanding The Linux Kernel, 3rd edition I read that >> *scheduler_tick()* is invoked once every tick to perform some operations > > Yes, it is still valid and happens. Looking into /proc/sched_debug: > CFS is confirmed. > > Next: > > Looking into kernel/timer.c:update_process_times(): > > /* > * Called from the timer interrupt handler to charge one tick to the current > * process. user_tick is 1 if the tick is user time, 0 for system. > */ > void update_process_times(int user_tick) > { > scheduler_tick(); > > From above we know that timer tick triggered the function, and > scheduler_tick() is called. > > Then using ftrace to analyse dynamically: > > <idle>-0 [000] 4154504419.814143: scheduler_tick > <-update_process_times > gedit-26702 [001] 4154504419.814146: scheduler_tick > <-update_process_times > <idle>-0 [000] 4154504419.815139: scheduler_tick > <-update_process_times > gedit-26702 [001] 4154504419.815142: scheduler_tick > <-update_process_times > > So yes, it is still called in the context of my gedit application. > >> related to scheduling. I am confused here, how costly it would be to call >> the function after every tick? Does it really happened? If not, then how >> indication of process time slice exhausted(if any) comes to know?? >> >> > > In the past, preemption is triggered by the timer. But nowadays, > preemption is voluntary. > > http://lwn.net/Articles/95334/ > > So why is it that we can still see timer based scheduling API like > scheduler_tick() called from timer interrupt? > > I am confused too. > Sorry, I think I was wrong. The word "tickless" is more appropriate understood as dynamic ticks. Timer do still get triggered periodically, contrary to my previous understanding: http://lwn.net/Articles/138969/ http://lkml.org/lkml/2008/1/14/42 And shown below through systemtap: 0xc043219d : do_timer+0x1/0xb4 [kernel] 0xc04444db : tick_sched_timer+0x48/0xa1 [kernel] 0xc043d4f5 : __run_hrtimer+0x54/0x8b [kernel] 0xc043de25 : hrtimer_interrupt+0xe8/0x147 [kernel] 0xc041463b : smp_apic_timer_interrupt+0x71/0x84 [kernel] 0xc04046cd : apic_timer_interrupt+0x2d/0x34 [kernel] do_timer And from below, scheduler_tick() can execute in different process context, not just the idle as indicated in http://lwn.net/Articles/95334/ and the patch by Scott Wood http://lwn.net/Articles/95387/): <idle>-0 [000] 575.341179: scheduler_tick <-update_process_times ping-5571 [001] 575.341181: update_process_times <-tick_periodic ping-5571 [001] 575.341183: scheduler_tick <-update_process_times <idle>-0 [000] 575.342176: update_process_times <-tick_periodic <idle>-0 [000] 575.342177: scheduler_tick <-update_process_times ksoftirqd/1-7 [001] 575.342179: update_process_times <-tick_periodic ksoftirqd/1-7 [001] 575.342181: scheduler_tick <-update_process_times Comments? -- Regards, Peter Teoh -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ