diff options
author | Minfei Huang <mnghuan@gmail.com> | 2016-04-25 11:20:28 +0200 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2016-06-20 21:46:34 +0200 |
commit | 0fb71d340d355156818bb53eb36ae79a3f88bda9 (patch) | |
tree | 5f4c0147a75e4a7f97a7c0bde6ebf5d50e4c0ff2 /kernel/time | |
parent | Linux 4.7-rc2 (diff) | |
download | linux-0fb71d340d355156818bb53eb36ae79a3f88bda9.tar.xz linux-0fb71d340d355156818bb53eb36ae79a3f88bda9.zip |
clocksource: Make clocksource insert entry more efficient
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>
Diffstat (limited to 'kernel/time')
-rw-r--r-- | kernel/time/clocksource.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 56ece145a814..6a5a310a1a53 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -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); } |