Skip to content

Commit df00015

Browse files
committed
Merge tag 'trace-v5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pulltracing fixes from Steven Rostedt: - Limit mcount build time sorting to only those archs that we know it works for. - Fix memory leak in error path of histogram setup - Fix and clean up rel_loc array out of bounds issue - tools/rtla documentation fixes - Fix issues with histogram logic * tag 'trace-v5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Don't inc err_log entry count if entry allocation fails tracing: Propagate is_signed to expression tracing: Fix smatch warning for do while check in event_hist_trigger_parse() tracing: Fix smatch warning for null glob in event_hist_trigger_parse() tools/tracing: Update Makefile to build rtla rtla: Make doc build optional tracing/perf: Avoid -Warray-bounds warning for __rel_loc macro tracing: Avoid -Warray-bounds warning for __rel_loc macro tracing/histogram: Fix a potential memory leak for kstrdup() ftrace: Have architectures opt-in for mcount build time sorting
2 parents 76fcbc9 + 67ab5eb commit df00015

File tree

10 files changed

+43
-16
lines changed

10 files changed

+43
-16
lines changed

arch/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ config ARM
8383
select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32
8484
select HAVE_CONTEXT_TRACKING
8585
select HAVE_C_RECORDMCOUNT
86+
select HAVE_BUILDTIME_MCOUNT_SORT
8687
select HAVE_DEBUG_KMEMLEAK if !XIP_KERNEL
8788
select HAVE_DMA_CONTIGUOUS if MMU
8889
select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ config X86
186186
select HAVE_CONTEXT_TRACKING_OFFSTACK if HAVE_CONTEXT_TRACKING
187187
select HAVE_C_RECORDMCOUNT
188188
select HAVE_OBJTOOL_MCOUNT if STACK_VALIDATION
189+
select HAVE_BUILDTIME_MCOUNT_SORT
189190
select HAVE_DEBUG_KMEMLEAK
190191
select HAVE_DMA_CONTIGUOUS
191192
select HAVE_DYNAMIC_FTRACE

include/trace/perf.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323

2424
#undef __get_rel_dynamic_array
2525
#define __get_rel_dynamic_array(field) \
26-
((void *)(&__entry->__rel_loc_##field) + \
27-
sizeof(__entry->__rel_loc_##field) + \
26+
((void *)__entry + \
27+
offsetof(typeof(*__entry), __rel_loc_##field) + \
28+
sizeof(__entry->__rel_loc_##field) + \
2829
(__entry->__rel_loc_##field & 0xffff))
2930

3031
#undef __get_rel_dynamic_array_len

include/trace/trace_events.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ TRACE_MAKE_SYSTEM_STR();
128128
struct trace_event_raw_##name { \
129129
struct trace_entry ent; \
130130
tstruct \
131-
char __data[0]; \
131+
char __data[]; \
132132
}; \
133133
\
134134
static struct trace_event_class event_class_##name;
@@ -318,9 +318,10 @@ TRACE_MAKE_SYSTEM_STR();
318318
#define __get_str(field) ((char *)__get_dynamic_array(field))
319319

320320
#undef __get_rel_dynamic_array
321-
#define __get_rel_dynamic_array(field) \
322-
((void *)(&__entry->__rel_loc_##field) + \
323-
sizeof(__entry->__rel_loc_##field) + \
321+
#define __get_rel_dynamic_array(field) \
322+
((void *)__entry + \
323+
offsetof(typeof(*__entry), __rel_loc_##field) + \
324+
sizeof(__entry->__rel_loc_##field) + \
324325
(__entry->__rel_loc_##field & 0xffff))
325326

326327
#undef __get_rel_dynamic_array_len

kernel/trace/Kconfig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,16 @@ config HAVE_C_RECORDMCOUNT
7070
help
7171
C version of recordmcount available?
7272

73+
config HAVE_BUILDTIME_MCOUNT_SORT
74+
bool
75+
help
76+
An architecture selects this if it sorts the mcount_loc section
77+
at build time.
78+
7379
config BUILDTIME_MCOUNT_SORT
7480
bool
7581
default y
76-
depends on BUILDTIME_TABLE_SORT && !S390
82+
depends on HAVE_BUILDTIME_MCOUNT_SORT && DYNAMIC_FTRACE
7783
help
7884
Sort the mcount_loc section at build time.
7985

kernel/trace/trace.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7740,7 +7740,8 @@ static struct tracing_log_err *get_tracing_log_err(struct trace_array *tr)
77407740
err = kzalloc(sizeof(*err), GFP_KERNEL);
77417741
if (!err)
77427742
err = ERR_PTR(-ENOMEM);
7743-
tr->n_err_log_entries++;
7743+
else
7744+
tr->n_err_log_entries++;
77447745

77457746
return err;
77467747
}

kernel/trace/trace_events_hist.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,6 +2503,8 @@ static struct hist_field *parse_unary(struct hist_trigger_data *hist_data,
25032503
(HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS);
25042504
expr->fn = hist_field_unary_minus;
25052505
expr->operands[0] = operand1;
2506+
expr->size = operand1->size;
2507+
expr->is_signed = operand1->is_signed;
25062508
expr->operator = FIELD_OP_UNARY_MINUS;
25072509
expr->name = expr_str(expr, 0);
25082510
expr->type = kstrdup_const(operand1->type, GFP_KERNEL);
@@ -2719,6 +2721,7 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
27192721

27202722
/* The operand sizes should be the same, so just pick one */
27212723
expr->size = operand1->size;
2724+
expr->is_signed = operand1->is_signed;
27222725

27232726
expr->operator = field_op;
27242727
expr->type = kstrdup_const(operand1->type, GFP_KERNEL);
@@ -3935,6 +3938,7 @@ static int trace_action_create(struct hist_trigger_data *hist_data,
39353938

39363939
var_ref_idx = find_var_ref_idx(hist_data, var_ref);
39373940
if (WARN_ON(var_ref_idx < 0)) {
3941+
kfree(p);
39383942
ret = var_ref_idx;
39393943
goto err;
39403944
}
@@ -6163,7 +6167,9 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,
61636167

61646168
lockdep_assert_held(&event_mutex);
61656169

6166-
if (glob && strlen(glob)) {
6170+
WARN_ON(!glob);
6171+
6172+
if (strlen(glob)) {
61676173
hist_err_clear();
61686174
last_cmd_set(file, param);
61696175
}
@@ -6196,7 +6202,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,
61966202
continue;
61976203
}
61986204
break;
6199-
} while (p);
6205+
} while (1);
62006206

62016207
if (!p)
62026208
param = NULL;

scripts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ HOSTCFLAGS_sorttable.o += -I$(srctree)/tools/arch/x86/include
2525
HOSTCFLAGS_sorttable.o += -DUNWINDER_ORC_ENABLED
2626
endif
2727

28-
ifdef CONFIG_DYNAMIC_FTRACE
28+
ifdef CONFIG_BUILDTIME_MCOUNT_SORT
2929
HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED
3030
endif
3131

tools/tracing/Makefile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# SPDX-License-Identifier: GPL-2.0
22
include ../scripts/Makefile.include
33

4-
all: latency
4+
all: latency rtla
55

6-
clean: latency_clean
6+
clean: latency_clean rtla_clean
77

8-
install: latency_install
8+
install: latency_install rtla_install
99

1010
latency:
1111
$(call descend,latency)
@@ -16,4 +16,14 @@ latency_install:
1616
latency_clean:
1717
$(call descend,latency,clean)
1818

19-
.PHONY: all install clean latency latency_install latency_clean
19+
rtla:
20+
$(call descend,rtla)
21+
22+
rtla_install:
23+
$(call descend,rtla,install)
24+
25+
rtla_clean:
26+
$(call descend,rtla,clean)
27+
28+
.PHONY: all install clean latency latency_install latency_clean \
29+
rtla rtla_install rtla_clean

tools/tracing/rtla/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ endif
5959
.PHONY: all
6060
all: rtla
6161

62-
rtla: $(OBJ) doc
62+
rtla: $(OBJ)
6363
$(CC) -o rtla $(LDFLAGS) $(OBJ) $(LIBS)
6464

6565
static: $(OBJ)

0 commit comments

Comments
 (0)