linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Make clocksource insert entry more efficiently
@ 2016-04-25  9:20 Minfei Huang
  2016-04-30 10:17 ` Minfei Huang
  2016-05-02 17:39 ` John Stultz
  0 siblings, 2 replies; 4+ messages in thread
From: Minfei Huang @ 2016-04-25  9:20 UTC (permalink / raw)
  To: john.stultz, tglx; +Cc: linux-kernel, Minfei Huang

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 <mnghuan@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make clocksource insert entry more efficiently
  2016-04-25  9:20 [PATCH] Make clocksource insert entry more efficiently Minfei Huang
@ 2016-04-30 10:17 ` Minfei Huang
  2016-05-02 17:39 ` John Stultz
  1 sibling, 0 replies; 4+ messages in thread
From: Minfei Huang @ 2016-04-30 10:17 UTC (permalink / raw)
  To: john.stultz, tglx; +Cc: linux-kernel

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 <mnghuan@gmail.com>
> ---
>  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
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make clocksource insert entry more efficiently
  2016-04-25  9:20 [PATCH] Make clocksource insert entry more efficiently Minfei Huang
  2016-04-30 10:17 ` Minfei Huang
@ 2016-05-02 17:39 ` John Stultz
  2016-05-03  3:32   ` Minfei Huang
  1 sibling, 1 reply; 4+ messages in thread
From: John Stultz @ 2016-05-02 17:39 UTC (permalink / raw)
  To: Minfei Huang; +Cc: Thomas Gleixner, lkml

On Mon, Apr 25, 2016 at 2:20 AM, Minfei Huang <mnghuan@gmail.com> 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 <mnghuan@gmail.com>
> ---

Thanks for sending this in. It looks reasonable to me, though not
likely to gain a ton, as these are usually short lists, and we only
really tinker with them at bootup. But yea. I'll put it on my toqueue
list for testing.

Its maybe a little close to make it for 4.7, but we'll see.

Thanks again!
-john

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make clocksource insert entry more efficiently
  2016-05-02 17:39 ` John Stultz
@ 2016-05-03  3:32   ` Minfei Huang
  0 siblings, 0 replies; 4+ messages in thread
From: Minfei Huang @ 2016-05-03  3:32 UTC (permalink / raw)
  To: John Stultz; +Cc: Thomas Gleixner, lkml

On 05/02/16 at 10:39P, John Stultz wrote:
> On Mon, Apr 25, 2016 at 2:20 AM, Minfei Huang <mnghuan@gmail.com> 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 <mnghuan@gmail.com>
> > ---
> 
> Thanks for sending this in. It looks reasonable to me, though not
> likely to gain a ton, as these are usually short lists, and we only
> really tinker with them at bootup. But yea. I'll put it on my toqueue
> list for testing.
> 
> Its maybe a little close to make it for 4.7, but we'll see.
> 
> Thanks again!
> -john

Thanks

Minfei

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-05-03  3:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-25  9:20 [PATCH] Make clocksource insert entry more efficiently Minfei Huang
2016-04-30 10:17 ` Minfei Huang
2016-05-02 17:39 ` John Stultz
2016-05-03  3:32   ` Minfei Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).