From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Mathieu Desnoyers <compudj@krystal.dyndns.org>,
Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 3/6] ring_buffer: add paranoid check for buffer page
Date: Mon, 29 Sep 2008 23:02:39 -0400 [thread overview]
Message-ID: <20080930030652.298596016@goodmis.org> (raw)
In-Reply-To: 20080930030236.230994826@goodmis.org
[-- Attachment #1: ring-buffer-paranoid-buffer-page-check.patch --]
[-- Type: text/plain, Size: 1447 bytes --]
If for some strange reason the buffer_page gets bigger, or the page struct
gets smaller, I want to know this ASAP. The best way is to not let the
kernel compile.
This patch adds code to test the size of the struct buffer_page against the
page struct and will cause compile issues if the buffer_page ever gets bigger
than the page struct.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/trace/ring_buffer.c | 11 +++++++++++
1 file changed, 11 insertions(+)
Index: linux-tip.git/kernel/trace/ring_buffer.c
===================================================================
--- linux-tip.git.orig/kernel/trace/ring_buffer.c 2008-09-29 17:31:05.000000000 -0400
+++ linux-tip.git/kernel/trace/ring_buffer.c 2008-09-29 19:59:24.000000000 -0400
@@ -289,6 +289,12 @@ static void rb_free_cpu_buffer(struct ri
kfree(cpu_buffer);
}
+/*
+ * Causes compile errors if the struct buffer_page gets bigger
+ * than the struct page.
+ */
+extern int ring_buffer_page_too_big(void);
+
/**
* ring_buffer_alloc - allocate a new ring_buffer
* @size: the size in bytes that is needed.
@@ -305,6 +311,11 @@ struct ring_buffer *ring_buffer_alloc(un
int bsize;
int cpu;
+ /* Paranoid! Optimizes out when all is well */
+ if (sizeof(struct buffer_page) > sizeof(struct page))
+ ring_buffer_page_too_big();
+
+
/* keep it in its own cache line */
buffer = kzalloc(ALIGN(sizeof(*buffer), cache_line_size()),
GFP_KERNEL);
--
next prev parent reply other threads:[~2008-09-30 3:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-30 3:02 [PATCH 0/6] ftrace: port to the new ring_buffer Steven Rostedt
2008-09-30 3:02 ` [PATCH 1/6] ftrace: give time for wakeup test to run Steven Rostedt
2008-09-30 3:02 ` [PATCH 2/6] Unified trace buffer Steven Rostedt
2008-09-30 9:45 ` Ingo Molnar
2008-09-30 11:53 ` Ingo Molnar
2008-09-30 12:06 ` Steven Rostedt
2008-09-30 3:02 ` Steven Rostedt [this message]
2008-09-30 3:02 ` [PATCH 4/6] ring_buffer: reset buffer page when freeing Steven Rostedt
2008-09-30 3:02 ` [PATCH 5/6] ftrace: make work with new ring buffer Steven Rostedt
2008-09-30 3:02 ` [PATCH 6/6] ftrace: take advantage of variable length entries Steven Rostedt
2008-09-30 17:33 ` Pekka Paalanen
2008-09-30 17:45 ` Steven Rostedt
2008-10-01 4:42 ` Steven Rostedt
2008-10-01 7:54 ` Ingo Molnar
2008-10-01 14:52 ` Steven Rostedt
2008-10-01 14:52 ` [PATCH] ftrace: type cast verifier Steven Rostedt
2008-10-01 17:42 ` Ingo Molnar
2008-10-01 17:47 ` Ingo Molnar
2008-09-30 7:45 ` [PATCH 0/6] ftrace: port to the new ring_buffer Ingo Molnar
2008-09-30 8:23 ` Ingo Molnar
2008-09-30 8:30 ` Ingo Molnar
2008-09-30 9:13 ` Ingo Molnar
2008-09-30 12:04 ` Steven Rostedt
2008-09-30 12:04 ` Steven Rostedt
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=20080930030652.298596016@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=compudj@krystal.dyndns.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=srostedt@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).