From: Minfei Huang <mnghuan@gmail.com>
To: john.stultz@linaro.org, tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, Minfei Huang <mnghuan@gmail.com>
Subject: [PATCH] Make clocksource insert entry more efficiently
Date: Mon, 25 Apr 2016 17:20:28 +0800 [thread overview]
Message-ID: <1461576028-2197-1-git-send-email-mnghuan@gmail.com> (raw)
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
next reply other threads:[~2016-04-25 9:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-25 9:20 Minfei Huang [this message]
2016-04-30 10:17 ` Minfei Huang
2016-05-02 17:39 ` John Stultz
2016-05-03 3:32 ` Minfei Huang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461576028-2197-1-git-send-email-mnghuan@gmail.com \
--to=mnghuan@gmail.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®