All of lore.kernel.org
 help / color / mirror / Atom feed
* kernel/timer.c: next_timer_interrupt() strange/buggy(?) code (2.6.18-rc1-mm2)
@ 2006-07-17 18:53 Andreas Mohr
  2006-07-17 19:01 ` Michael Buesch
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Andreas Mohr @ 2006-07-17 18:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: keir, Tony Lindgren, zach, Ingo Molnar, Thomas Gleixner

Hi all,

next_timer_interrupt() contains the following gem:

        /* Check tv2-tv5. */
        varray[0] = &base->tv2;
        varray[1] = &base->tv3;
        varray[2] = &base->tv4;
        varray[3] = &base->tv5;
        for (i = 0; i < 4; i++) {
                j = INDEX(i);
                do {
                        if (list_empty(varray[i]->vec + j)) {
                                j = (j + 1) & TVN_MASK;
                                continue;
                        }
                        list_for_each_entry(nte, varray[i]->vec + j, entry)
                                if (time_before(nte->expires, expires))
                                        expires = nte->expires;
                        if (j < (INDEX(i)) && i < 3)
                                list = varray[i + 1]->vec + (INDEX(i + 1));
                        goto found;
                } while (j != (INDEX(i)));
        }
found:
        if (list) {



Excuse me, but why do we have a while loop here if the last instruction in
the while loop is a straight "goto found"?
(a "continue" simply continue:s the loop without checking the loop condition
at the bottom, right?)


Few lines above there's similar code:

        /* Look for timer events in tv1. */
        j = base->timer_jiffies & TVR_MASK;
        do {
                list_for_each_entry(nte, base->tv1.vec + j, entry) {
                        expires = nte->expires;
                        if (j < (base->timer_jiffies & TVR_MASK))
                                list = base->tv2.vec + (INDEX(0));
                        goto found;
                }
                j = (j + 1) & TVR_MASK;
        } while (j != (base->timer_jiffies & TVR_MASK));


However in this case now we process *one* list only, so the "goto found"
should be ok since we don't need to iterate through the multiple tv2-tv5 lists
as in the other potentially buggy loop.

Also, is the base->tv1.vec vs. base->tv2.vec difference above ok?

Possibly I'm too dense while reading this code, though...

Andreas Mohr

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-07-18 16:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-17 18:53 kernel/timer.c: next_timer_interrupt() strange/buggy(?) code (2.6.18-rc1-mm2) Andreas Mohr
2006-07-17 19:01 ` Michael Buesch
2006-07-17 19:57 ` Valdis.Kletnieks
2006-07-18  1:50   ` Steven Rostedt
2006-07-18 14:29   ` Michael Buesch
2006-07-18 14:50     ` Valdis.Kletnieks
2006-07-18 15:04       ` Michael Buesch
2006-07-17 20:22 ` Andreas Schwab
2006-07-18  1:47 ` [PATCH] fix bad macro param in timer.c (was: kernel/timer.c: next_timer_interrupt() strange/buggy(?) code (2.6.18-rc1-mm2)) Steven Rostedt
2006-07-18  1:59   ` [PATCH] fix bad macro param in timer.c Steven Rostedt
2006-07-18 15:14 ` kernel/timer.c: next_timer_interrupt() strange/buggy(?) code (2.6.18-rc1-mm2) Prakash Punnoor
2006-07-18 16:02   ` offtopic boot parameter notsc [Was: Re: kernel/timer.c: next_timer_interrupt() strange/buggy(?) code (2.6.18-rc1-mm2)] Sergio Monteiro Basto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.