Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752439AbcD3KRy (ORCPT ); Sat, 30 Apr 2016 06:17:54 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:34610 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752072AbcD3KRw (ORCPT ); Sat, 30 Apr 2016 06:17:52 -0400 Date: Sat, 30 Apr 2016 18:17:48 +0800 From: Minfei Huang To: john.stultz@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] Make clocksource insert entry more efficiently Message-ID: <20160430101748.GC27909@huangminfeis-MacBook-Pro.local> References: <1461576028-2197-1-git-send-email-mnghuan@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1461576028-2197-1-git-send-email-mnghuan@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1165 Lines: 41 Ping. Any comment is appreciate. Thanks Minfei On 04/25/16 at 05:20P, Minfei Huang wrote: > 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. > > Signed-off-by: Minfei Huang > --- > 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); > } > > -- > 2.6.3 >