aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-05-26 16:49:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-26 16:49:40 -0400
commitc5b440951a19fdd068090d38dcbe72ea28e5e0d0 (patch)
tree4078aba02a1cac17bdc9fb84238c4f2207187863
parent862f0a3227b337cea11d0488b0345dc2670fc297 (diff)
parent0c97bf863efce63d6ab7971dad811601e6171d2f (diff)
Merge tag 'trace-v5.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing warning fix from Steven Rostedt: "Make the GCC 9 warning for sub struct memset go away. GCC 9 now warns about calling memset() on partial structures when it goes across multiple fields. This adds a helper for the place in tracing that does this type of clearing of a structure" * tag 'trace-v5.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Silence GCC 9 array bounds warning
-rw-r--r--kernel/trace/trace.c6
-rw-r--r--kernel/trace/trace.h18
-rw-r--r--kernel/trace/trace_kdb.c6
3 files changed, 20 insertions, 10 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 2c92b3d9ea30..1c80521fd436 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -8910,12 +8910,8 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
8910 8910
8911 cnt++; 8911 cnt++;
8912 8912
8913 /* reset all but tr, trace, and overruns */ 8913 trace_iterator_reset(&iter);
8914 memset(&iter.seq, 0,
8915 sizeof(struct trace_iterator) -
8916 offsetof(struct trace_iterator, seq));
8917 iter.iter_flags |= TRACE_FILE_LAT_FMT; 8914 iter.iter_flags |= TRACE_FILE_LAT_FMT;
8918 iter.pos = -1;
8919 8915
8920 if (trace_find_next_entry_inc(&iter) != NULL) { 8916 if (trace_find_next_entry_inc(&iter) != NULL) {
8921 int ret; 8917 int ret;
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 82c70b63d375..005f08629b8b 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1966,4 +1966,22 @@ static inline void tracer_hardirqs_off(unsigned long a0, unsigned long a1) { }
1966 1966
1967extern struct trace_iterator *tracepoint_print_iter; 1967extern struct trace_iterator *tracepoint_print_iter;
1968 1968
1969/*
1970 * Reset the state of the trace_iterator so that it can read consumed data.
1971 * Normally, the trace_iterator is used for reading the data when it is not
1972 * consumed, and must retain state.
1973 */
1974static __always_inline void trace_iterator_reset(struct trace_iterator *iter)
1975{
1976 const size_t offset = offsetof(struct trace_iterator, seq);
1977
1978 /*
1979 * Keep gcc from complaining about overwriting more than just one
1980 * member in the structure.
1981 */
1982 memset((char *)iter + offset, 0, sizeof(struct trace_iterator) - offset);
1983
1984 iter->pos = -1;
1985}
1986
1969#endif /* _LINUX_KERNEL_TRACE_H */ 1987#endif /* _LINUX_KERNEL_TRACE_H */
diff --git a/kernel/trace/trace_kdb.c b/kernel/trace/trace_kdb.c
index 6c1ae6b752d1..cca65044c14c 100644
--- a/kernel/trace/trace_kdb.c
+++ b/kernel/trace/trace_kdb.c
@@ -37,12 +37,8 @@ static void ftrace_dump_buf(int skip_entries, long cpu_file)
37 if (skip_entries) 37 if (skip_entries)
38 kdb_printf("(skipping %d entries)\n", skip_entries); 38 kdb_printf("(skipping %d entries)\n", skip_entries);
39 39
40 /* reset all but tr, trace, and overruns */ 40 trace_iterator_reset(&iter);
41 memset(&iter.seq, 0,
42 sizeof(struct trace_iterator) -
43 offsetof(struct trace_iterator, seq));
44 iter.iter_flags |= TRACE_FILE_LAT_FMT; 41 iter.iter_flags |= TRACE_FILE_LAT_FMT;
45 iter.pos = -1;
46 42
47 if (cpu_file == RING_BUFFER_ALL_CPUS) { 43 if (cpu_file == RING_BUFFER_ALL_CPUS) {
48 for_each_tracing_cpu(cpu) { 44 for_each_tracing_cpu(cpu) {