Skip to contentSkip to conversation

Time: Clocksource: finish searching when clocksource_enqueue() found the inserting place.

PATCH New ERAMOTO Masaya 1 participant 1 message Sep 16, 2013 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Time: Clocksource: finish searching when clocksource_enqueue() found the inserting place.

Hi,

clocksource_enqueue() do extra behavior in the sorted list as below:
* it compares all clocksources in the list even if found the inserting place.
* it copies to entry until finding there.

So fixed clocksource_enqueue() as below:
* it finishes to compare clocksource when found there.
* it copies to entry only when found there.

---
 kernel/time/clocksource.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/time/clocksource.c +4 -2
index 50a8736..5b340a4 100644
@@ -700,9 +700,11 @@ static void clocksource_enqueue(struct clocksource *cs)
 
 	list_for_each_entry(tmp, &clocksource_list, list)
 		/* Keep track of the place, where to insert */
-		if (tmp->rating >= cs->rating)
+		if (tmp->rating < cs->rating) {
 			entry = &tmp->list;
-	list_add(&cs->list, entry);
+			break;
+		}
+	list_add_tail(&cs->list, entry);
 }
 
 /**