From: Frederic Weisbecker <fweisbec@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Mike Galbraith <efault@gmx.de>, Paul Mackerras <paulus@samba.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [RFC PATCH 2/4] perf/core: Optimize a bit rotate_ctx()
Date: Sun, 8 Nov 2009 21:13:24 +0100 [thread overview]
Message-ID: <1257711206-12243-3-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1257711206-12243-1-git-send-email-fweisbec@gmail.com>
Don't use list_for_each_entry() just to swap the first and
last entry in the list.
Instead, use a direct list->next derefencing. This saves up a
useless prefetch.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
kernel/perf_event.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index b3a31c8..0432c1c 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1432,7 +1432,7 @@ static void perf_ctx_adjust_freq(struct perf_event_context *ctx)
*/
static void rotate_ctx(struct perf_event_context *ctx)
{
- struct perf_event *event;
+ struct list_head *list;
if (!ctx->nr_events)
return;
@@ -1442,15 +1442,17 @@ static void rotate_ctx(struct perf_event_context *ctx)
* Rotate the first entry last (works just fine for group events too):
*/
perf_disable();
- list_for_each_entry(event, &ctx->pinned_grp_list, group_entry) {
- list_move_tail(&event->group_entry, &ctx->pinned_grp_list);
- break;
+
+ if (!list_empty(&ctx->pinned_grp_list)) {
+ list = ctx->pinned_grp_list.next;
+ list_move_tail(list, &ctx->pinned_grp_list);
}
- list_for_each_entry(event, &ctx->volatile_grp_list, group_entry) {
- list_move_tail(&event->group_entry, &ctx->volatile_grp_list);
- break;
+ if (!list_empty(&ctx->volatile_grp_list)) {
+ list = ctx->volatile_grp_list.next;
+ list_move_tail(list, &ctx->volatile_grp_list);
}
+
perf_enable();
spin_unlock(&ctx->lock);
--
1.6.2.3
next prev parent reply other threads:[~2009-11-08 20:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-08 20:13 [RFC PATCH 0/4] perf/core: Small event scheduling changes Frederic Weisbecker
2009-11-08 20:13 ` [RFC PATCH 1/4] perf/core: split context's event group list into pinned and non-pinned lists Frederic Weisbecker
2009-11-08 20:13 ` Frederic Weisbecker [this message]
2009-11-08 20:13 ` [RFC PATCH 3/4] perf/core: Split up pinned and non pinned processing Frederic Weisbecker
2009-11-10 5:11 ` Ingo Molnar
2009-11-10 9:32 ` Frederic Weisbecker
2009-11-08 20:13 ` [RFC PATCH 4/4] perf/core: Schedule every pinned events before the the non-pinned Frederic Weisbecker
2009-11-10 10:10 ` Peter Zijlstra
2009-11-10 10:34 ` Frederic Weisbecker
2009-11-10 5:13 ` [RFC PATCH 0/4] perf/core: Small event scheduling changes Ingo Molnar
2009-11-10 9:41 ` Frederic Weisbecker
2009-11-10 9:47 ` Frederic Weisbecker
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=1257711206-12243-3-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=acme@redhat.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=peterz@infradead.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®