Skip to content

Commit

Permalink
Merge tag 'trace-v5.17-rc1' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/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
  • Loading branch information
torvalds committed Jan 28, 2022
2 parents 76fcbc9 + 67ab5eb commit df00015
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 16 deletions.
1 change: 1 addition & 0 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ config ARM
select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32
select HAVE_CONTEXT_TRACKING
select HAVE_C_RECORDMCOUNT
select HAVE_BUILDTIME_MCOUNT_SORT
select HAVE_DEBUG_KMEMLEAK if !XIP_KERNEL
select HAVE_DMA_CONTIGUOUS if MMU
select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU
Expand Down
1 change: 1 addition & 0 deletions arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ config X86
select HAVE_CONTEXT_TRACKING_OFFSTACK if HAVE_CONTEXT_TRACKING
select HAVE_C_RECORDMCOUNT
select HAVE_OBJTOOL_MCOUNT if STACK_VALIDATION
select HAVE_BUILDTIME_MCOUNT_SORT
select HAVE_DEBUG_KMEMLEAK
select HAVE_DMA_CONTIGUOUS
select HAVE_DYNAMIC_FTRACE
Expand Down
5 changes: 3 additions & 2 deletions include/trace/perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@

#undef __get_rel_dynamic_array
#define __get_rel_dynamic_array(field) \
((void *)(&__entry->__rel_loc_##field) + \
sizeof(__entry->__rel_loc_##field) + \
((void *)__entry + \
offsetof(typeof(*__entry), __rel_loc_##field) + \
sizeof(__entry->__rel_loc_##field) + \
(__entry->__rel_loc_##field & 0xffff))

#undef __get_rel_dynamic_array_len
Expand Down
9 changes: 5 additions & 4 deletions include/trace/trace_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ TRACE_MAKE_SYSTEM_STR();
struct trace_event_raw_##name { \
struct trace_entry ent; \
tstruct \
char __data[0]; \
char __data[]; \
}; \
\
static struct trace_event_class event_class_##name;
Expand Down Expand Up @@ -318,9 +318,10 @@ TRACE_MAKE_SYSTEM_STR();
#define __get_str(field) ((char *)__get_dynamic_array(field))

#undef __get_rel_dynamic_array
#define __get_rel_dynamic_array(field) \
((void *)(&__entry->__rel_loc_##field) + \
sizeof(__entry->__rel_loc_##field) + \
#define __get_rel_dynamic_array(field) \
((void *)__entry + \
offsetof(typeof(*__entry), __rel_loc_##field) + \
sizeof(__entry->__rel_loc_##field) + \
(__entry->__rel_loc_##field & 0xffff))

#undef __get_rel_dynamic_array_len
Expand Down
8 changes: 7 additions & 1 deletion kernel/trace/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ config HAVE_C_RECORDMCOUNT
help
C version of recordmcount available?

config HAVE_BUILDTIME_MCOUNT_SORT
bool
help
An architecture selects this if it sorts the mcount_loc section
at build time.

config BUILDTIME_MCOUNT_SORT
bool
default y
depends on BUILDTIME_TABLE_SORT && !S390
depends on HAVE_BUILDTIME_MCOUNT_SORT && DYNAMIC_FTRACE
help
Sort the mcount_loc section at build time.

Expand Down
3 changes: 2 additions & 1 deletion kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -7740,7 +7740,8 @@ static struct tracing_log_err *get_tracing_log_err(struct trace_array *tr)
err = kzalloc(sizeof(*err), GFP_KERNEL);
if (!err)
err = ERR_PTR(-ENOMEM);
tr->n_err_log_entries++;
else
tr->n_err_log_entries++;

return err;
}
Expand Down
10 changes: 8 additions & 2 deletions kernel/trace/trace_events_hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2503,6 +2503,8 @@ static struct hist_field *parse_unary(struct hist_trigger_data *hist_data,
(HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS);
expr->fn = hist_field_unary_minus;
expr->operands[0] = operand1;
expr->size = operand1->size;
expr->is_signed = operand1->is_signed;
expr->operator = FIELD_OP_UNARY_MINUS;
expr->name = expr_str(expr, 0);
expr->type = kstrdup_const(operand1->type, GFP_KERNEL);
Expand Down Expand Up @@ -2719,6 +2721,7 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,

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

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

var_ref_idx = find_var_ref_idx(hist_data, var_ref);
if (WARN_ON(var_ref_idx < 0)) {
kfree(p);
ret = var_ref_idx;
goto err;
}
Expand Down Expand Up @@ -6163,7 +6167,9 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,

lockdep_assert_held(&event_mutex);

if (glob && strlen(glob)) {
WARN_ON(!glob);

if (strlen(glob)) {
hist_err_clear();
last_cmd_set(file, param);
}
Expand Down Expand Up @@ -6196,7 +6202,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,
continue;
}
break;
} while (p);
} while (1);

if (!p)
param = NULL;
Expand Down
2 changes: 1 addition & 1 deletion scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ HOSTCFLAGS_sorttable.o += -I$(srctree)/tools/arch/x86/include
HOSTCFLAGS_sorttable.o += -DUNWINDER_ORC_ENABLED
endif

ifdef CONFIG_DYNAMIC_FTRACE
ifdef CONFIG_BUILDTIME_MCOUNT_SORT
HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED
endif

Expand Down
18 changes: 14 additions & 4 deletions tools/tracing/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# SPDX-License-Identifier: GPL-2.0
include ../scripts/Makefile.include

all: latency
all: latency rtla

clean: latency_clean
clean: latency_clean rtla_clean

install: latency_install
install: latency_install rtla_install

latency:
$(call descend,latency)
Expand All @@ -16,4 +16,14 @@ latency_install:
latency_clean:
$(call descend,latency,clean)

.PHONY: all install clean latency latency_install latency_clean
rtla:
$(call descend,rtla)

rtla_install:
$(call descend,rtla,install)

rtla_clean:
$(call descend,rtla,clean)

.PHONY: all install clean latency latency_install latency_clean \
rtla rtla_install rtla_clean
2 changes: 1 addition & 1 deletion tools/tracing/rtla/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ endif
.PHONY: all
all: rtla

rtla: $(OBJ) doc
rtla: $(OBJ)
$(CC) -o rtla $(LDFLAGS) $(OBJ) $(LIBS)

static: $(OBJ)
Expand Down

0 comments on commit df00015

Please sign in to comment.