Skip to content

Commit

Permalink
Merge branch 'tracing-fixes-for-linus' of git://git.kernel.org/pub/sc…
Browse files Browse the repository at this point in the history
…m/linux/kernel/git/tip/linux-2.6-tip

* 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  ring-buffer: Do 8 byte alignment for 64 bit that can not handle 4 byte align
  • Loading branch information
Linus Torvalds committed Mar 26, 2010
2 parents 3cacf42 + 2271048 commit 833961d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ EXPORT_SYMBOL_GPL(tracing_is_on);
#define RB_MAX_SMALL_DATA (RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX)
#define RB_EVNT_MIN_SIZE 8U /* two 32bit words */

#if !defined(CONFIG_64BIT) || defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
# define RB_FORCE_8BYTE_ALIGNMENT 0
# define RB_ARCH_ALIGNMENT RB_ALIGNMENT
#else
# define RB_FORCE_8BYTE_ALIGNMENT 1
# define RB_ARCH_ALIGNMENT 8U
#endif

/* define RINGBUF_TYPE_DATA for 'case RINGBUF_TYPE_DATA:' */
#define RINGBUF_TYPE_DATA 0 ... RINGBUF_TYPE_DATA_TYPE_LEN_MAX

Expand Down Expand Up @@ -1547,7 +1555,7 @@ rb_update_event(struct ring_buffer_event *event,

case 0:
length -= RB_EVNT_HDR_SIZE;
if (length > RB_MAX_SMALL_DATA)
if (length > RB_MAX_SMALL_DATA || RB_FORCE_8BYTE_ALIGNMENT)
event->array[0] = length;
else
event->type_len = DIV_ROUND_UP(length, RB_ALIGNMENT);
Expand Down Expand Up @@ -1722,11 +1730,11 @@ static unsigned rb_calculate_event_length(unsigned length)
if (!length)
length = 1;

if (length > RB_MAX_SMALL_DATA)
if (length > RB_MAX_SMALL_DATA || RB_FORCE_8BYTE_ALIGNMENT)
length += sizeof(event.array[0]);

length += RB_EVNT_HDR_SIZE;
length = ALIGN(length, RB_ALIGNMENT);
length = ALIGN(length, RB_ARCH_ALIGNMENT);

return length;
}
Expand Down

0 comments on commit 833961d

Please sign in to comment.