public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 7/8] ring-buffer: fix alignment problem
Date: Mon, 19 Jan 2009 19:15:49 -0500	[thread overview]
Message-ID: <20090120001733.836881476@goodmis.org> (raw)
In-Reply-To: 20090120001542.687427797@goodmis.org

[-- Attachment #1: 0007-ring-buffer-fix-alignment-problem.patch --]
[-- Type: text/plain, Size: 1396 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: fix to allow some archs to use the ring buffer

Commits in the ring buffer are checked by pointer arithmetic.
If the calculation is incorrect, then the commits will never take
place and the buffer will simply fill up and report an error.

Each page in the ring buffer has a small header:

struct buffer_data_page {
	u64		time_stamp;
	local_t		commit;
	unsigned char	data[];
};

Unfortuntely, some of the calculations used sizeof(struct buffer_data_page)
to know the size of the header. But this is incorrect on some archs,
where sizeof(struct buffer_data_page) does not equal
offsetof(struct buffer_data_page, data), and on those archs, the commits
are never processed.

This patch replaces the sizeof with offsetof.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/ring_buffer.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 0b9de5a..8de026d 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -244,7 +244,7 @@ static inline int test_time_stamp(u64 delta)
 	return 0;
 }
 
-#define BUF_PAGE_SIZE (PAGE_SIZE - sizeof(struct buffer_data_page))
+#define BUF_PAGE_SIZE (PAGE_SIZE - offsetof(struct buffer_data_page, data))
 
 /*
  * head_page == tail_page && head == tail then buffer is empty.
-- 
1.5.6.5

-- 

  parent reply	other threads:[~2009-01-20  0:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-20  0:15 [PATCH 0/8] ftrace: updates to tip Steven Rostedt
2009-01-20  0:15 ` [PATCH 1/8] x86, ftrace, hw-branch-tracer: support hotplug cpus Steven Rostedt
2009-01-20  0:15 ` [PATCH 2/8] x86, ftrace, hw-branch-tracer: dump trace on oops Steven Rostedt
2009-01-20  0:15 ` [PATCH 3/8] x86, ftrace, hw-branch-tracer: reset trace buffer on close Steven Rostedt
2009-01-20  0:15 ` [PATCH 4/8] x86, ftrace, hw-branch-tracer: change trace format Steven Rostedt
2009-01-20  0:15 ` [PATCH 5/8] x86, ftrace, hw-branch-tracer: documentation Steven Rostedt
2009-01-20  0:15 ` [PATCH 6/8] x86, ds, bts: cleanup DS configuration Steven Rostedt
2009-01-20  0:15 ` Steven Rostedt [this message]
2009-01-20  0:15 ` [PATCH 8/8] trace_workqueue: use percpu data for workqueue stat Steven Rostedt
2009-01-20  0:41 ` [PATCH 0/8] ftrace: updates to tip Steven Rostedt
2009-01-20  0:42   ` Steven Rostedt
2009-01-20 12:05 ` Ingo Molnar

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=20090120001733.836881476@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=srostedt@redhat.com \
    /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