Re: access to jiffies_64 atomic or not?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 29, 2009 at 9:15 PM, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote:
>
>  from kernel/timer.c:
>
> /*
>  * The 64-bit jiffies value is not atomic - you MUST NOT read it
>  * without sampling the sequence number in xtime_lock.
>  * jiffies is defined in the linker script...
>  */
>
> void do_timer(unsigned long ticks)
> {
>        jiffies_64 += ticks;
>        update_wall_time();
>        calc_global_load();
> }
>
>  i'm not sure how to interpret that comment since it clearly suggests
> that you can't simply access jiffies_64, but that's exactly what
> do_timer() is doing in that first line by incrementing it by a certain
> value.  can anyone clarify whether the above makes any sense?

with the help of cscope, you could see that its callers: tick_periodic
and tick_do_update_jiffies64 defined in tick-common.c and tick-sched.c
respectively, already grab the seqlock before calling the do_timer and
release it after do_timer is done.

/*
 * Periodic tick
 */
static void tick_periodic(int cpu)
{
    if (tick_do_timer_cpu == cpu) {
        write_seqlock(&xtime_lock); // here....

        /* Keep track of the next tick event */
        tick_next_period = ktime_add(tick_next_period, tick_period);

        do_timer(1);
        write_sequnlock(&xtime_lock); // and here....
    }

    update_process_times(user_mode(get_irq_regs()));
    profile_tick(CPU_PROFILING);
}

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux