aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/ring_buffer.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 05a9f83b8819..d1187ef20caf 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -207,6 +207,14 @@ EXPORT_SYMBOL_GPL(tracing_is_on);
207#define RB_MAX_SMALL_DATA (RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX) 207#define RB_MAX_SMALL_DATA (RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX)
208#define RB_EVNT_MIN_SIZE 8U /* two 32bit words */ 208#define RB_EVNT_MIN_SIZE 8U /* two 32bit words */
209 209
210#if !defined(CONFIG_64BIT) || defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
211# define RB_FORCE_8BYTE_ALIGNMENT 0
212# define RB_ARCH_ALIGNMENT RB_ALIGNMENT
213#else
214# define RB_FORCE_8BYTE_ALIGNMENT 1
215# define RB_ARCH_ALIGNMENT 8U
216#endif
217
210/* define RINGBUF_TYPE_DATA for 'case RINGBUF_TYPE_DATA:' */ 218/* define RINGBUF_TYPE_DATA for 'case RINGBUF_TYPE_DATA:' */
211#define RINGBUF_TYPE_DATA 0 ... RINGBUF_TYPE_DATA_TYPE_LEN_MAX 219#define RINGBUF_TYPE_DATA 0 ... RINGBUF_TYPE_DATA_TYPE_LEN_MAX
212 220
@@ -1547,7 +1555,7 @@ rb_update_event(struct ring_buffer_event *event,
1547 1555
1548 case 0: 1556 case 0:
1549 length -= RB_EVNT_HDR_SIZE; 1557 length -= RB_EVNT_HDR_SIZE;
1550 if (length > RB_MAX_SMALL_DATA) 1558 if (length > RB_MAX_SMALL_DATA || RB_FORCE_8BYTE_ALIGNMENT)
1551 event->array[0] = length; 1559 event->array[0] = length;
1552 else 1560 else
1553 event->type_len = DIV_ROUND_UP(length, RB_ALIGNMENT); 1561 event->type_len = DIV_ROUND_UP(length, RB_ALIGNMENT);
@@ -1722,11 +1730,11 @@ static unsigned rb_calculate_event_length(unsigned length)
1722 if (!length) 1730 if (!length)
1723 length = 1; 1731 length = 1;
1724 1732
1725 if (length > RB_MAX_SMALL_DATA) 1733 if (length > RB_MAX_SMALL_DATA || RB_FORCE_8BYTE_ALIGNMENT)
1726 length += sizeof(event.array[0]); 1734 length += sizeof(event.array[0]);
1727 1735
1728 length += RB_EVNT_HDR_SIZE; 1736 length += RB_EVNT_HDR_SIZE;
1729 length = ALIGN(length, RB_ALIGNMENT); 1737 length = ALIGN(length, RB_ARCH_ALIGNMENT);
1730 1738
1731 return length; 1739 return length;
1732} 1740}