lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tip-3trb2n2henb9m27tncef3ag7@git.kernel.org>
Date:	Wed, 6 Nov 2013 05:19:05 -0800
From:	tip-bot for Peter Zijlstra <tipbot@...or.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	linux-kernel@...r.kernel.org, anton@...ba.org,
	mathieu.desnoyers@...ymtl.ca, hpa@...or.com, mingo@...nel.org,
	michael@...erman.id.au, peterz@...radead.org, vince@...ter.net,
	paulmck@...ux.vnet.ibm.com, benh@...nel.crashing.org,
	fweisbec@...il.com, oleg@...hat.com, VICTORK@...ibm.com,
	tglx@...utronix.de, mikey@...ling.org
Subject: [tip:perf/core] perf: Optimize perf_output_begin()
  -- address calculation

Commit-ID:  524feca5e9da9e5f9e5aa5d5613b1d762db9509e
Gitweb:     http://git.kernel.org/tip/524feca5e9da9e5f9e5aa5d5613b1d762db9509e
Author:     Peter Zijlstra <peterz@...radead.org>
AuthorDate: Thu, 31 Oct 2013 17:36:25 +0100
Committer:  Ingo Molnar <mingo@...nel.org>
CommitDate: Wed, 6 Nov 2013 12:34:22 +0100

perf: Optimize perf_output_begin() -- address calculation

Rewrite the handle address calculation code to be clearer.

Saves 8 bytes on x86_64-defconfig.

Signed-off-by: Peter Zijlstra <peterz@...radead.org>
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
Cc: Michael Ellerman <michael@...erman.id.au>
Cc: Michael Neuling <mikey@...ling.org>
Cc: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
Cc: james.hogan@...tec.com
Cc: Vince Weaver <vince@...ter.net>
Cc: Victor Kaplansky <VICTORK@...ibm.com>
Cc: Oleg Nesterov <oleg@...hat.com>
Cc: Anton Blanchard <anton@...ba.org>
Link: http://lkml.kernel.org/n/tip-3trb2n2henb9m27tncef3ag7@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
 kernel/events/ring_buffer.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index e4d70f3..c52a32f 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -105,7 +105,7 @@ int perf_output_begin(struct perf_output_handle *handle,
 {
 	struct ring_buffer *rb;
 	unsigned long tail, offset, head;
-	int have_lost;
+	int have_lost, page_shift;
 	struct {
 		struct perf_event_header header;
 		u64			 id;
@@ -159,12 +159,12 @@ int perf_output_begin(struct perf_output_handle *handle,
 	if (unlikely(head - local_read(&rb->wakeup) > rb->watermark))
 		local_add(rb->watermark, &rb->wakeup);
 
-	handle->page = offset >> (PAGE_SHIFT + page_order(rb));
-	handle->page &= rb->nr_pages - 1;
-	handle->size = offset & ((PAGE_SIZE << page_order(rb)) - 1);
-	handle->addr = rb->data_pages[handle->page];
-	handle->addr += handle->size;
-	handle->size = (PAGE_SIZE << page_order(rb)) - handle->size;
+	page_shift = PAGE_SHIFT + page_order(rb);
+
+	handle->page = (offset >> page_shift) & (rb->nr_pages - 1);
+	offset &= (1UL << page_shift) - 1;
+	handle->addr = rb->data_pages[handle->page] + offset;
+	handle->size = (1UL << page_shift) - offset;
 
 	if (unlikely(have_lost)) {
 		struct perf_sample_data sample_data;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ