]> git.karo-electronics.de Git - linux-beck.git/commitdiff
clocksource: Make clocksource insert entry more efficient
authorMinfei Huang <mnghuan@gmail.com>
Mon, 25 Apr 2016 09:20:28 +0000 (17:20 +0800)
committerJohn Stultz <john.stultz@linaro.org>
Mon, 20 Jun 2016 19:46:34 +0000 (12:46 -0700)
In clocksource_enqueue(), it is unnecessary to continue looping
the list, if we find there is an entry that the value of rating
is smaller than the new one. It is safe to be out the loop,
because all of entry are inserted in descending order.

Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Minfei Huang <mnghuan@gmail.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
kernel/time/clocksource.c

index 56ece145a814a87ce172d96f32c17bf9d119b2f8..6a5a310a1a5351205ef9bd633a39efa427897556 100644 (file)
@@ -669,10 +669,12 @@ static void clocksource_enqueue(struct clocksource *cs)
        struct list_head *entry = &clocksource_list;
        struct clocksource *tmp;
 
-       list_for_each_entry(tmp, &clocksource_list, list)
+       list_for_each_entry(tmp, &clocksource_list, list) {
                /* Keep track of the place, where to insert */
-               if (tmp->rating >= cs->rating)
-                       entry = &tmp->list;
+               if (tmp->rating < cs->rating)
+                       break;
+               entry = &tmp->list;
+       }
        list_add(&cs->list, entry);
 }