From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933326AbcFTT4w (ORCPT ); Mon, 20 Jun 2016 15:56:52 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:36481 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752452AbcFTT4h (ORCPT ); Mon, 20 Jun 2016 15:56:37 -0400 From: John Stultz To: lkml Cc: Minfei Huang , Prarit Bhargava , Richard Cochran , Thomas Gleixner , Ingo Molnar , John Stultz Subject: [PATCH 1/6] clocksource: Make clocksource insert entry more efficient Date: Mon, 20 Jun 2016 12:56:20 -0700 Message-Id: <1466452585-29379-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466452585-29379-1-git-send-email-john.stultz@linaro.org> References: <1466452585-29379-1-git-send-email-john.stultz@linaro.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Minfei Huang 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 Cc: Richard Cochran Cc: Thomas Gleixner Cc: Ingo Molnar Signed-off-by: Minfei Huang Signed-off-by: John Stultz --- kernel/time/clocksource.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 56ece14..6a5a310 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); } -- 1.9.1