linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window
@ 2020-08-04 20:57 Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 01/17] tracing: Simplify defining of the next event id Steven Rostedt
                   ` (15 more replies)
  0 siblings, 16 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next

Head SHA1: c58b46cba71750c6e969625abb1cf3ddabb15e06


Chengming Zhou (2):
      ftrace: Setup correct FTRACE_FL_REGS flags for module
      ftrace: Do not let direct or IPMODIFY ftrace_ops be added to module and set trampolines

Josef Bacik (1):
      ftrace: Fix ftrace_trace_task return value

Kevin Hao (2):
      tracing/hwlat: Drop the duplicate assignment in start_kthread()
      tracing/hwlat: Honor the tracing_cpumask

Masami Hiramatsu (4):
      kprobes: Remove show_registers() function prototype
      lib/bootconfig: Add override operator support
      tools/bootconfig: Add testcases for value override operator
      Documentation: bootconfig: Add bootconfig override operator

Muchun Song (1):
      kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler

Nick Desaulniers (2):
      tracepoint: Mark __tracepoint_string's __used
      tracepoint: Use __used attribute definitions from compiler_attributes.h

Peng Fan (1):
      tracing/uprobe: Remove dead code in trace_uprobe_register()

Vincent Whitchurch (1):
      tracing: Remove outdated comment in stack handling

Wei Yang (2):
      tracing: Simplify defining of the next event id
      tracing: Save one trace_event->type by using __TRACE_LAST_TYPE

Zhaoyang Huang (1):
      trace : Have tracing buffer info use kvzalloc instead of kzalloc

----
 Documentation/admin-guide/bootconfig.rst     | 11 ++++++++++
 include/linux/kprobes.h                      |  1 -
 include/linux/tracepoint.h                   | 11 +++++-----
 kernel/kprobes.c                             |  7 ++++++
 kernel/trace/ftrace.c                        | 22 +++++++++++++------
 kernel/trace/trace.c                         | 10 ++-------
 kernel/trace/trace.h                         |  7 +++++-
 kernel/trace/trace_hwlat.c                   |  6 ++---
 kernel/trace/trace_output.c                  | 14 ++++++------
 kernel/trace/trace_uprobe.c                  |  1 -
 lib/bootconfig.c                             | 33 +++++++++++++++++++---------
 tools/bootconfig/samples/bad-override.bconf  |  3 +++
 tools/bootconfig/samples/bad-override2.bconf |  3 +++
 tools/bootconfig/samples/good-override.bconf |  6 +++++
 tools/bootconfig/test-bootconfig.sh          | 13 +++++++++++
 15 files changed, 104 insertions(+), 44 deletions(-)
 create mode 100644 tools/bootconfig/samples/bad-override.bconf
 create mode 100644 tools/bootconfig/samples/bad-override2.bconf
 create mode 100644 tools/bootconfig/samples/good-override.bconf

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 01/17] tracing: Simplify defining of the next event id
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 02/17] tracing: Save one trace_event->type by using __TRACE_LAST_TYPE Steven Rostedt
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Wei Yang

From: Wei Yang <richard.weiyang@linux.alibaba.com>

The value to be used and compared in trace_search_list() is "last + 1".
Let's just define next to be "last + 1" instead of doing the addition
each time.

Link: https://lkml.kernel.org/r/20200703020612.12930-2-richard.weiyang@linux.alibaba.com

Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_output.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 73976de7f8cc..a35232d61601 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -675,11 +675,11 @@ static LIST_HEAD(ftrace_event_list);
 static int trace_search_list(struct list_head **list)
 {
 	struct trace_event *e;
-	int last = __TRACE_LAST_TYPE;
+	int next = __TRACE_LAST_TYPE + 1;
 
 	if (list_empty(&ftrace_event_list)) {
 		*list = &ftrace_event_list;
-		return last + 1;
+		return next;
 	}
 
 	/*
@@ -687,17 +687,17 @@ static int trace_search_list(struct list_head **list)
 	 * lets see if somebody freed one.
 	 */
 	list_for_each_entry(e, &ftrace_event_list, list) {
-		if (e->type != last + 1)
+		if (e->type != next)
 			break;
-		last++;
+		next++;
 	}
 
 	/* Did we used up all 65 thousand events??? */
-	if ((last + 1) > TRACE_EVENT_TYPE_MAX)
+	if (next > TRACE_EVENT_TYPE_MAX)
 		return 0;
 
 	*list = &e->list;
-	return last + 1;
+	return next;
 }
 
 void trace_event_read_lock(void)
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 02/17] tracing: Save one trace_event->type by using __TRACE_LAST_TYPE
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 01/17] tracing: Simplify defining of the next event id Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 03/17] tracing/hwlat: Drop the duplicate assignment in start_kthread() Steven Rostedt
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Wei Yang

From: Wei Yang <richard.weiyang@linux.alibaba.com>

Static defined trace_event->type stops at (__TRACE_LAST_TYPE - 1) and
dynamic trace_event->type starts from (__TRACE_LAST_TYPE + 1).

To save one trace_event->type index, let's use __TRACE_LAST_TYPE.

Link: https://lkml.kernel.org/r/20200703020612.12930-3-richard.weiyang@linux.alibaba.com

Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_output.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index a35232d61601..4d1893564912 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -20,7 +20,7 @@ DECLARE_RWSEM(trace_event_sem);
 
 static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly;
 
-static int next_event_type = __TRACE_LAST_TYPE + 1;
+static int next_event_type = __TRACE_LAST_TYPE;
 
 enum print_line_t trace_print_bputs_msg_only(struct trace_iterator *iter)
 {
@@ -675,7 +675,7 @@ static LIST_HEAD(ftrace_event_list);
 static int trace_search_list(struct list_head **list)
 {
 	struct trace_event *e;
-	int next = __TRACE_LAST_TYPE + 1;
+	int next = __TRACE_LAST_TYPE;
 
 	if (list_empty(&ftrace_event_list)) {
 		*list = &ftrace_event_list;
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 03/17] tracing/hwlat: Drop the duplicate assignment in start_kthread()
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 01/17] tracing: Simplify defining of the next event id Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 02/17] tracing: Save one trace_event->type by using __TRACE_LAST_TYPE Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 04/17] tracing/hwlat: Honor the tracing_cpumask Steven Rostedt
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Kevin Hao

From: Kevin Hao <haokexin@gmail.com>

We have set 'current_mask' to '&save_cpumask' in its declaration,
so there is no need to assign again.

Link: https://lkml.kernel.org/r/20200730082318.42584-1-haokexin@gmail.com

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_hwlat.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index e2be7bb7ef7e..ddb528a6cd51 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -371,7 +371,6 @@ static int start_kthread(struct trace_array *tr)
 		return 0;
 
 	/* Just pick the first CPU on first iteration */
-	current_mask = &save_cpumask;
 	get_online_cpus();
 	cpumask_and(current_mask, cpu_online_mask, tracing_buffer_mask);
 	put_online_cpus();
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 04/17] tracing/hwlat: Honor the tracing_cpumask
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (2 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 03/17] tracing/hwlat: Drop the duplicate assignment in start_kthread() Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 05/17] ftrace: Setup correct FTRACE_FL_REGS flags for module Steven Rostedt
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Ingo Molnar, stable, Kevin Hao

From: Kevin Hao <haokexin@gmail.com>

In calculation of the cpu mask for the hwlat kernel thread, the wrong
cpu mask is used instead of the tracing_cpumask, this causes the
tracing/tracing_cpumask useless for hwlat tracer. Fixes it.

Link: https://lkml.kernel.org/r/20200730082318.42584-2-haokexin@gmail.com

Cc: Ingo Molnar <mingo@redhat.com>
Cc: stable@vger.kernel.org
Fixes: 0330f7aa8ee6 ("tracing: Have hwlat trace migrate across tracing_cpumask CPUs")
Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_hwlat.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index ddb528a6cd51..17873e5d0353 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -283,6 +283,7 @@ static bool disable_migrate;
 static void move_to_next_cpu(void)
 {
 	struct cpumask *current_mask = &save_cpumask;
+	struct trace_array *tr = hwlat_trace;
 	int next_cpu;
 
 	if (disable_migrate)
@@ -296,7 +297,7 @@ static void move_to_next_cpu(void)
 		goto disable;
 
 	get_online_cpus();
-	cpumask_and(current_mask, cpu_online_mask, tracing_buffer_mask);
+	cpumask_and(current_mask, cpu_online_mask, tr->tracing_cpumask);
 	next_cpu = cpumask_next(smp_processor_id(), current_mask);
 	put_online_cpus();
 
@@ -372,7 +373,7 @@ static int start_kthread(struct trace_array *tr)
 
 	/* Just pick the first CPU on first iteration */
 	get_online_cpus();
-	cpumask_and(current_mask, cpu_online_mask, tracing_buffer_mask);
+	cpumask_and(current_mask, cpu_online_mask, tr->tracing_cpumask);
 	put_online_cpus();
 	next_cpu = cpumask_first(current_mask);
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 05/17] ftrace: Setup correct FTRACE_FL_REGS flags for module
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (3 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 04/17] tracing/hwlat: Honor the tracing_cpumask Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-09 15:53   ` Sasha Levin
  2020-08-04 20:57 ` [for-linus][PATCH 06/17] ftrace: Do not let direct or IPMODIFY ftrace_ops be added to module and set trampolines Steven Rostedt
                   ` (10 subsequent siblings)
  15 siblings, 1 reply; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, stable, Chengming Zhou, Muchun Song

From: Chengming Zhou <zhouchengming@bytedance.com>

When module loaded and enabled, we will use __ftrace_replace_code
for module if any ftrace_ops referenced it found. But we will get
wrong ftrace_addr for module rec in ftrace_get_addr_new, because
rec->flags has not been setup correctly. It can cause the callback
function of a ftrace_ops has FTRACE_OPS_FL_SAVE_REGS to be called
with pt_regs set to NULL.
So setup correct FTRACE_FL_REGS flags for rec when we call
referenced_filters to find ftrace_ops references it.

Link: https://lkml.kernel.org/r/20200728180554.65203-1-zhouchengming@bytedance.com

Cc: stable@vger.kernel.org
Fixes: 8c4f3c3fa9681 ("ftrace: Check module functions being traced on reload")
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index c141d347f71a..d052f856f1cf 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -6198,8 +6198,11 @@ static int referenced_filters(struct dyn_ftrace *rec)
 	int cnt = 0;
 
 	for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) {
-		if (ops_references_rec(ops, rec))
-		    cnt++;
+		if (ops_references_rec(ops, rec)) {
+			cnt++;
+			if (ops->flags & FTRACE_OPS_FL_SAVE_REGS)
+				rec->flags |= FTRACE_FL_REGS;
+		}
 	}
 
 	return cnt;
@@ -6378,8 +6381,8 @@ void ftrace_module_enable(struct module *mod)
 		if (ftrace_start_up)
 			cnt += referenced_filters(rec);
 
-		/* This clears FTRACE_FL_DISABLED */
-		rec->flags = cnt;
+		rec->flags &= ~FTRACE_FL_DISABLED;
+		rec->flags += cnt;
 
 		if (ftrace_start_up && cnt) {
 			int failed = __ftrace_replace_code(rec, 1);
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 06/17] ftrace: Do not let direct or IPMODIFY ftrace_ops be added to module and set trampolines
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (4 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 05/17] ftrace: Setup correct FTRACE_FL_REGS flags for module Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 07/17] tracing: Remove outdated comment in stack handling Steven Rostedt
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Chengming Zhou, Muchun Song

From: Chengming Zhou <zhouchengming@bytedance.com>

When inserting a module, we find all ftrace_ops referencing it on the
ftrace_ops_list. But FTRACE_OPS_FL_DIRECT and FTRACE_OPS_FL_IPMODIFY
flags are special, and should not be set automatically. So warn and
skip ftrace_ops that have these two flags set and adding new code.
Also check if only one ftrace_ops references the module, in which case
we can use a trampoline as an optimization.

Link: https://lkml.kernel.org/r/20200728180554.65203-2-zhouchengming@bytedance.com

Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index d052f856f1cf..f433cb44300a 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -6199,9 +6199,17 @@ static int referenced_filters(struct dyn_ftrace *rec)
 
 	for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) {
 		if (ops_references_rec(ops, rec)) {
+			if (WARN_ON_ONCE(ops->flags & FTRACE_OPS_FL_DIRECT))
+				continue;
+			if (WARN_ON_ONCE(ops->flags & FTRACE_OPS_FL_IPMODIFY))
+				continue;
 			cnt++;
 			if (ops->flags & FTRACE_OPS_FL_SAVE_REGS)
 				rec->flags |= FTRACE_FL_REGS;
+			if (cnt == 1 && ops->trampoline)
+				rec->flags |= FTRACE_FL_TRAMP;
+			else
+				rec->flags &= ~FTRACE_FL_TRAMP;
 		}
 	}
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 07/17] tracing: Remove outdated comment in stack handling
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (5 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 06/17] ftrace: Do not let direct or IPMODIFY ftrace_ops be added to module and set trampolines Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 09/17] tracepoint: Mark __tracepoint_strings __used Steven Rostedt
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Vincent Whitchurch

From: Vincent Whitchurch <vincent.whitchurch@axis.com>

This comment describes the behaviour before commit 2a820bf74918
("tracing: Use percpu stack trace buffer more intelligently").  Since
that commit, interrupts and NMIs do use the per-cpu stacks so the
comment is no longer correct.  Remove it.

(Note that the FTRACE_STACK_SIZE mentioned in the comment has never
existed, it probably should have said FTRACE_STACK_ENTRIES.)

Link: https://lkml.kernel.org/r/20200727092840.18659-1-vincent.whitchurch@axis.com

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 4aab712f9567..dbcacdd56b02 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2930,12 +2930,6 @@ static void __ftrace_trace_stack(struct trace_buffer *buffer,
 		skip++;
 #endif
 
-	/*
-	 * Since events can happen in NMIs there's no safe way to
-	 * use the per cpu ftrace_stacks. We reserve it and if an interrupt
-	 * or NMI comes in, it will just have to use the default
-	 * FTRACE_STACK_SIZE.
-	 */
 	preempt_disable_notrace();
 
 	stackidx = __this_cpu_inc_return(ftrace_stack_reserve) - 1;
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 09/17] tracepoint: Mark __tracepoint_strings __used
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (6 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 07/17] tracing: Remove outdated comment in stack handling Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 10/17] tracepoint: Use __used attribute definitions from compiler_attributes.h Steven Rostedt
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Ingo Molnar, Miguel Ojeda, stable,
	Tim Murray, Simon MacMullen, Greg Hackmann, Nick Desaulniers

From: Nick Desaulniers <ndesaulniers@google.com>

__tracepoint_string's have their string data stored in .rodata, and an
address to that data stored in the "__tracepoint_str" section. Functions
that refer to those strings refer to the symbol of the address. Compiler
optimization can replace those address references with references
directly to the string data. If the address doesn't appear to have other
uses, then it appears dead to the compiler and is removed. This can
break the /tracing/printk_formats sysfs node which iterates the
addresses stored in the "__tracepoint_str" section.

Like other strings stored in custom sections in this header, mark these
__used to inform the compiler that there are other non-obvious users of
the address, so they should still be emitted.

Link: https://lkml.kernel.org/r/20200730224555.2142154-2-ndesaulniers@google.com

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: stable@vger.kernel.org
Fixes: 102c9323c35a8 ("tracing: Add __tracepoint_string() to export string pointers")
Reported-by: Tim Murray <timmurray@google.com>
Reported-by: Simon MacMullen <simonmacm@google.com>
Suggested-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 include/linux/tracepoint.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index a1fecf311621..3a5b717d92e8 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -361,7 +361,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
 		static const char *___tp_str __tracepoint_string = str; \
 		___tp_str;						\
 	})
-#define __tracepoint_string	__attribute__((section("__tracepoint_str")))
+#define __tracepoint_string	__attribute__((section("__tracepoint_str"), used))
 #else
 /*
  * tracepoint_string() is used to save the string address for userspace
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 10/17] tracepoint: Use __used attribute definitions from compiler_attributes.h
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (7 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 09/17] tracepoint: Mark __tracepoint_strings __used Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 11/17] ftrace: Fix ftrace_trace_task return value Steven Rostedt
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Miguel Ojeda, Nick Desaulniers

From: Nick Desaulniers <ndesaulniers@google.com>

Just a small cleanup while I was touching this header.
compiler_attributes.h does feature detection of these __attributes__(())
and provides more concise ways to invoke them.

Link: https://lkml.kernel.org/r/20200730224555.2142154-3-ndesaulniers@google.com

Acked-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 include/linux/tracepoint.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 3a5b717d92e8..598fec9f9dbf 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -116,8 +116,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
 
 #define __TRACEPOINT_ENTRY(name)					 \
 	static tracepoint_ptr_t __tracepoint_ptr_##name __used		 \
-	__attribute__((section("__tracepoints_ptrs"))) =		 \
-		&__tracepoint_##name
+	__section(__tracepoints_ptrs) = &__tracepoint_##name
 #endif
 
 #endif /* _LINUX_TRACEPOINT_H */
@@ -280,9 +279,9 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
  */
 #define DEFINE_TRACE_FN(name, reg, unreg)				 \
 	static const char __tpstrtab_##name[]				 \
-	__attribute__((section("__tracepoints_strings"))) = #name;	 \
-	struct tracepoint __tracepoint_##name				 \
-	__attribute__((section("__tracepoints"), used)) =		 \
+	__section(__tracepoints_strings) = #name;			 \
+	struct tracepoint __tracepoint_##name __used			 \
+	__section(__tracepoints) =					 \
 		{ __tpstrtab_##name, STATIC_KEY_INIT_FALSE, reg, unreg, NULL };\
 	__TRACEPOINT_ENTRY(name);
 
@@ -361,7 +360,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
 		static const char *___tp_str __tracepoint_string = str; \
 		___tp_str;						\
 	})
-#define __tracepoint_string	__attribute__((section("__tracepoint_str"), used))
+#define __tracepoint_string	__used __section(__tracepoint_str)
 #else
 /*
  * tracepoint_string() is used to save the string address for userspace
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 11/17] ftrace: Fix ftrace_trace_task return value
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (8 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 10/17] tracepoint: Use __used attribute definitions from compiler_attributes.h Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 12/17] kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler Steven Rostedt
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Josef Bacik

From: Josef Bacik <josef@toxicpanda.com>

I was attempting to use pid filtering with function_graph, but it wasn't
allowing anything to make it through.  Turns out ftrace_trace_task
returns false if ftrace_ignore_pid is not-empty, which isn't correct
anymore.  We're now setting it to FTRACE_PID_IGNORE if we need to ignore
that pid, otherwise it's set to the pid (which is weird considering the
name) or to FTRACE_PID_TRACE.  Fix the check to check for !=
FTRACE_PID_IGNORE.  With this we can now use function_graph with pid
filtering.

Link: https://lkml.kernel.org/r/20200725005048.1790-1-josef@toxicpanda.com

Fixes: 717e3f5ebc82 ("ftrace: Make function trace pid filtering a bit more exact")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c | 3 ---
 kernel/trace/trace.h  | 7 ++++++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index f433cb44300a..4e3a5d79c078 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -139,9 +139,6 @@ static inline void ftrace_ops_init(struct ftrace_ops *ops)
 #endif
 }
 
-#define FTRACE_PID_IGNORE	-1
-#define FTRACE_PID_TRACE	-2
-
 static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip,
 			    struct ftrace_ops *op, struct pt_regs *regs)
 {
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index f21607f87189..610d21355526 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1103,6 +1103,10 @@ print_graph_function_flags(struct trace_iterator *iter, u32 flags)
 extern struct list_head ftrace_pids;
 
 #ifdef CONFIG_FUNCTION_TRACER
+
+#define FTRACE_PID_IGNORE	-1
+#define FTRACE_PID_TRACE	-2
+
 struct ftrace_func_command {
 	struct list_head	list;
 	char			*name;
@@ -1114,7 +1118,8 @@ struct ftrace_func_command {
 extern bool ftrace_filter_param __initdata;
 static inline int ftrace_trace_task(struct trace_array *tr)
 {
-	return !this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid);
+	return this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid) !=
+		FTRACE_PID_IGNORE;
 }
 extern int ftrace_is_dead(void);
 int ftrace_create_function_files(struct trace_array *tr,
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 12/17] kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (9 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 11/17] ftrace: Fix ftrace_trace_task return value Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 13/17] tracing/uprobe: Remove dead code in trace_uprobe_register() Steven Rostedt
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, stable, Masami Hiramatsu,
	Muchun Song, Chengming Zhou

From: Muchun Song <songmuchun@bytedance.com>

We found a case of kernel panic on our server. The stack trace is as
follows(omit some irrelevant information):

  BUG: kernel NULL pointer dereference, address: 0000000000000080
  RIP: 0010:kprobe_ftrace_handler+0x5e/0xe0
  RSP: 0018:ffffb512c6550998 EFLAGS: 00010282
  RAX: 0000000000000000 RBX: ffff8e9d16eea018 RCX: 0000000000000000
  RDX: ffffffffbe1179c0 RSI: ffffffffc0535564 RDI: ffffffffc0534ec0
  RBP: ffffffffc0534ec1 R08: ffff8e9d1bbb0f00 R09: 0000000000000004
  R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
  R13: ffff8e9d1f797060 R14: 000000000000bacc R15: ffff8e9ce13eca00
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 0000000000000080 CR3: 00000008453d0005 CR4: 00000000003606e0
  DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
  DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
  Call Trace:
   <IRQ>
   ftrace_ops_assist_func+0x56/0xe0
   ftrace_call+0x5/0x34
   tcpa_statistic_send+0x5/0x130 [ttcp_engine]

The tcpa_statistic_send is the function being kprobed. After analysis,
the root cause is that the fourth parameter regs of kprobe_ftrace_handler
is NULL. Why regs is NULL? We use the crash tool to analyze the kdump.

  crash> dis tcpa_statistic_send -r
         <tcpa_statistic_send>: callq 0xffffffffbd8018c0 <ftrace_caller>

The tcpa_statistic_send calls ftrace_caller instead of ftrace_regs_caller.
So it is reasonable that the fourth parameter regs of kprobe_ftrace_handler
is NULL. In theory, we should call the ftrace_regs_caller instead of the
ftrace_caller. After in-depth analysis, we found a reproducible path.

  Writing a simple kernel module which starts a periodic timer. The
  timer's handler is named 'kprobe_test_timer_handler'. The module
  name is kprobe_test.ko.

  1) insmod kprobe_test.ko
  2) bpftrace -e 'kretprobe:kprobe_test_timer_handler {}'
  3) echo 0 > /proc/sys/kernel/ftrace_enabled
  4) rmmod kprobe_test
  5) stop step 2) kprobe
  6) insmod kprobe_test.ko
  7) bpftrace -e 'kretprobe:kprobe_test_timer_handler {}'

We mark the kprobe as GONE but not disarm the kprobe in the step 4).
The step 5) also do not disarm the kprobe when unregister kprobe. So
we do not remove the ip from the filter. In this case, when the module
loads again in the step 6), we will replace the code to ftrace_caller
via the ftrace_module_enable(). When we register kprobe again, we will
not replace ftrace_caller to ftrace_regs_caller because the ftrace is
disabled in the step 3). So the step 7) will trigger kernel panic. Fix
this problem by disarming the kprobe when the module is going away.

Link: https://lkml.kernel.org/r/20200728064536.24405-1-songmuchun@bytedance.com

Cc: stable@vger.kernel.org
Fixes: ae6aa16fdc16 ("kprobes: introduce ftrace based optimization")
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Co-developed-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/kprobes.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 4a904cc56d68..07bf03fcf574 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2113,6 +2113,13 @@ static void kill_kprobe(struct kprobe *p)
 	 * the original probed function (which will be freed soon) any more.
 	 */
 	arch_remove_kprobe(p);
+
+	/*
+	 * The module is going away. We should disarm the kprobe which
+	 * is using ftrace.
+	 */
+	if (kprobe_ftrace(p))
+		disarm_kprobe_ftrace(p);
 }
 
 /* Disable one kprobe */
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 13/17] tracing/uprobe: Remove dead code in trace_uprobe_register()
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (10 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 12/17] kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 14/17] kprobes: Remove show_registers() function prototype Steven Rostedt
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Peng Fan

From: Peng Fan <fanpeng@loongson.cn>

In the function trace_uprobe_register(), the statement "return 0;"
out of switch case is dead code, remove it.

Link: https://lkml.kernel.org/r/1595561064-29186-1-git-send-email-fanpeng@loongson.cn

Signed-off-by: Peng Fan <fanpeng@loongson.cn>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_uprobe.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index fdd47f99b18f..f4286c9bdeb4 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -1456,7 +1456,6 @@ trace_uprobe_register(struct trace_event_call *event, enum trace_reg type,
 	default:
 		return 0;
 	}
-	return 0;
 }
 
 static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs)
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 14/17] kprobes: Remove show_registers() function prototype
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (11 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 13/17] tracing/uprobe: Remove dead code in trace_uprobe_register() Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 15/17] lib/bootconfig: Add override operator support Steven Rostedt
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Masami Hiramatsu

From: Masami Hiramatsu <mhiramat@kernel.org>

Remove show_registers() function prototype because this function
has been renamed by commit 57da8b960b9a ("x86: Avoid double stack
traces with show_regs()"), and commit 80006dbee674 ("kprobes/x86:
Remove jprobe implementation") has removed the caller in kprobes.
So this doesn't exist anymore.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 include/linux/kprobes.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 6adf90f248d7..81cb7e00ccdc 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -227,7 +227,6 @@ extern int arch_prepare_kprobe(struct kprobe *p);
 extern void arch_arm_kprobe(struct kprobe *p);
 extern void arch_disarm_kprobe(struct kprobe *p);
 extern int arch_init_kprobes(void);
-extern void show_registers(struct pt_regs *regs);
 extern void kprobes_inc_nmissed_count(struct kprobe *p);
 extern bool arch_within_kprobe_blacklist(unsigned long addr);
 extern int arch_populate_kprobe_blacklist(void);
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 15/17] lib/bootconfig: Add override operator support
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (12 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 14/17] kprobes: Remove show_registers() function prototype Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:57 ` [for-linus][PATCH 16/17] tools/bootconfig: Add testcases for value override operator Steven Rostedt
  2020-08-04 20:58 ` [for-linus][PATCH 17/17] Documentation: bootconfig: Add bootconfig " Steven Rostedt
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Masami Hiramatsu

From: Masami Hiramatsu <mhiramat@kernel.org>

Add the value override operator (":=") support to the bootconfig.

This value override operator will be useful for the bootloaders
which will only update the existing bootconfig according to the
bootloader boot options.

Without this override operator, the bootloader needs to parse
the existing bootconfig and update it. However, with this
assignment, it can just append the updated (partial) bootconfig
text at the tail of existing one without parsing it.
(Of course, it must update the size, checksum and magic,
 but that will be done easily)

Link: https://lkml.kernel.org/r/159482882954.126704.16209517125614438640.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/bootconfig.c | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index 912ef4921398..a5f701161f6b 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -329,22 +329,30 @@ const char * __init xbc_node_find_next_key_value(struct xbc_node *root,
 
 /* XBC parse and tree build */
 
+static int __init xbc_init_node(struct xbc_node *node, char *data, u32 flag)
+{
+	unsigned long offset = data - xbc_data;
+
+	if (WARN_ON(offset >= XBC_DATA_MAX))
+		return -EINVAL;
+
+	node->data = (u16)offset | flag;
+	node->child = 0;
+	node->next = 0;
+
+	return 0;
+}
+
 static struct xbc_node * __init xbc_add_node(char *data, u32 flag)
 {
 	struct xbc_node *node;
-	unsigned long offset;
 
 	if (xbc_node_num == XBC_NODE_MAX)
 		return NULL;
 
 	node = &xbc_nodes[xbc_node_num++];
-	offset = data - xbc_data;
-	node->data = (u16)offset;
-	if (WARN_ON(offset >= XBC_DATA_MAX))
+	if (xbc_init_node(node, data, flag) < 0)
 		return NULL;
-	node->data |= flag;
-	node->child = 0;
-	node->next = 0;
 
 	return node;
 }
@@ -603,7 +611,9 @@ static int __init xbc_parse_kv(char **k, char *v, int op)
 	if (c < 0)
 		return c;
 
-	if (!xbc_add_sibling(v, XBC_VALUE))
+	if (op == ':' && child) {
+		xbc_init_node(child, v, XBC_VALUE);
+	} else if (!xbc_add_sibling(v, XBC_VALUE))
 		return -ENOMEM;
 
 	if (c == ',') {	/* Array */
@@ -787,7 +797,7 @@ int __init xbc_init(char *buf, const char **emsg, int *epos)
 
 	p = buf;
 	do {
-		q = strpbrk(p, "{}=+;\n#");
+		q = strpbrk(p, "{}=+;:\n#");
 		if (!q) {
 			p = skip_spaces(p);
 			if (*p != '\0')
@@ -798,9 +808,12 @@ int __init xbc_init(char *buf, const char **emsg, int *epos)
 		c = *q;
 		*q++ = '\0';
 		switch (c) {
+		case ':':
 		case '+':
 			if (*q++ != '=') {
-				ret = xbc_parse_error("Wrong '+' operator",
+				ret = xbc_parse_error(c == '+' ?
+						"Wrong '+' operator" :
+						"Wrong ':' operator",
 							q - 2);
 				break;
 			}
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 16/17] tools/bootconfig: Add testcases for value override operator
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (13 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 15/17] lib/bootconfig: Add override operator support Steven Rostedt
@ 2020-08-04 20:57 ` Steven Rostedt
  2020-08-04 20:58 ` [for-linus][PATCH 17/17] Documentation: bootconfig: Add bootconfig " Steven Rostedt
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Masami Hiramatsu

From: Masami Hiramatsu <mhiramat@kernel.org>

Add some testcases and examples for value override operator.

Link: https://lkml.kernel.org/r/159482883824.126704.2166030493721357163.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tools/bootconfig/samples/bad-override.bconf  |  3 +++
 tools/bootconfig/samples/bad-override2.bconf |  3 +++
 tools/bootconfig/samples/good-override.bconf |  6 ++++++
 tools/bootconfig/test-bootconfig.sh          | 13 +++++++++++++
 4 files changed, 25 insertions(+)
 create mode 100644 tools/bootconfig/samples/bad-override.bconf
 create mode 100644 tools/bootconfig/samples/bad-override2.bconf
 create mode 100644 tools/bootconfig/samples/good-override.bconf

diff --git a/tools/bootconfig/samples/bad-override.bconf b/tools/bootconfig/samples/bad-override.bconf
new file mode 100644
index 000000000000..fde6c561512e
--- /dev/null
+++ b/tools/bootconfig/samples/bad-override.bconf
@@ -0,0 +1,3 @@
+key.subkey = value
+# We can not override pre-defined subkeys with value
+key := value
diff --git a/tools/bootconfig/samples/bad-override2.bconf b/tools/bootconfig/samples/bad-override2.bconf
new file mode 100644
index 000000000000..688587cb023c
--- /dev/null
+++ b/tools/bootconfig/samples/bad-override2.bconf
@@ -0,0 +1,3 @@
+key = value
+# We can not override pre-defined value with subkey
+key.subkey := value
diff --git a/tools/bootconfig/samples/good-override.bconf b/tools/bootconfig/samples/good-override.bconf
new file mode 100644
index 000000000000..7d31d5f8fbd8
--- /dev/null
+++ b/tools/bootconfig/samples/good-override.bconf
@@ -0,0 +1,6 @@
+# Override the value
+key.word = 1,2,4
+key.word := 2,3
+
+# No pre-defined key
+key.new.word := "new"
diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bootconfig.sh
index 3c2ab9e75730..56284b98d8f0 100755
--- a/tools/bootconfig/test-bootconfig.sh
+++ b/tools/bootconfig/test-bootconfig.sh
@@ -117,6 +117,19 @@ xpass grep -q "bar" $OUTFILE
 xpass grep -q "baz" $OUTFILE
 xpass grep -q "qux" $OUTFILE
 
+echo "Override same-key values"
+cat > $TEMPCONF << EOF
+key = bar, baz
+key := qux
+EOF
+echo > $INITRD
+
+xpass $BOOTCONF -a $TEMPCONF $INITRD
+$BOOTCONF $INITRD > $OUTFILE
+xfail grep -q "bar" $OUTFILE
+xfail grep -q "baz" $OUTFILE
+xpass grep -q "qux" $OUTFILE
+
 echo "Double/single quotes test"
 echo "key = '\"string\"';" > $TEMPCONF
 $BOOTCONF -a $TEMPCONF $INITRD
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [for-linus][PATCH 17/17] Documentation: bootconfig: Add bootconfig override operator
  2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
                   ` (14 preceding siblings ...)
  2020-08-04 20:57 ` [for-linus][PATCH 16/17] tools/bootconfig: Add testcases for value override operator Steven Rostedt
@ 2020-08-04 20:58 ` Steven Rostedt
  15 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2020-08-04 20:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Masami Hiramatsu

From: Masami Hiramatsu <mhiramat@kernel.org>

Add a sentence about bootconfig override operator (":=") to
bootconfig.rst.

Link: https://lkml.kernel.org/r/159482884682.126704.7198860675721719878.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Documentation/admin-guide/bootconfig.rst | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/admin-guide/bootconfig.rst b/Documentation/admin-guide/bootconfig.rst
index d6b3b77a4129..a22024f9175e 100644
--- a/Documentation/admin-guide/bootconfig.rst
+++ b/Documentation/admin-guide/bootconfig.rst
@@ -71,6 +71,16 @@ For example,::
  foo = bar, baz
  foo = qux  # !ERROR! we can not re-define same key
 
+If you want to update the value, you must use the override operator
+``:=`` explicitly. For example::
+
+ foo = bar, baz
+ foo := qux
+
+then, the ``qux`` is assigned to ``foo`` key. This is useful for
+overriding the default value by adding (partial) custom bootconfigs
+without parsing the default bootconfig.
+
 If you want to append the value to existing key as an array member,
 you can use ``+=`` operator. For example::
 
@@ -84,6 +94,7 @@ For example, following config is NOT allowed.::
 
  foo = value1
  foo.bar = value2 # !ERROR! subkey "bar" and value "value1" can NOT co-exist
+ foo.bar := value2 # !ERROR! even with the override operator, this is NOT allowed.
 
 
 Comments
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [for-linus][PATCH 05/17] ftrace: Setup correct FTRACE_FL_REGS flags for module
  2020-08-04 20:57 ` [for-linus][PATCH 05/17] ftrace: Setup correct FTRACE_FL_REGS flags for module Steven Rostedt
@ 2020-08-09 15:53   ` Sasha Levin
  0 siblings, 0 replies; 18+ messages in thread
From: Sasha Levin @ 2020-08-09 15:53 UTC (permalink / raw)
  To: Sasha Levin, Steven Rostedt, Chengming Zhou, linux-kernel
  Cc: Ingo Molnar, stable, stable

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 8c4f3c3fa968 ("ftrace: Check module functions being traced on reload").

The bot has tested the following trees: v5.8, v5.7.13, v5.4.56, v4.19.137, v4.14.192, v4.9.232, v4.4.232.

v5.8: Build OK!
v5.7.13: Build OK!
v5.4.56: Build OK!
v4.19.137: Build OK!
v4.14.192: Build OK!
v4.9.232: Build OK!
v4.4.232: Failed to apply! Possible dependencies:
    02a392a0439f ("ftrace: Add new type to distinguish what kind of ftrace_bug()")
    97e9b4fca52b ("ftrace: Clean up ftrace_module_init() code")
    b6b71f66a16a ("ftrace: Join functions ftrace_module_init() and ftrace_init_module()")
    b7ffffbb46f2 ("ftrace: Add infrastructure for delayed enabling of module functions")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-08-09 15:53 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 20:57 [for-linus][PATCH 00/17] tracing: Last minute fixes for this merge window Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 01/17] tracing: Simplify defining of the next event id Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 02/17] tracing: Save one trace_event->type by using __TRACE_LAST_TYPE Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 03/17] tracing/hwlat: Drop the duplicate assignment in start_kthread() Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 04/17] tracing/hwlat: Honor the tracing_cpumask Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 05/17] ftrace: Setup correct FTRACE_FL_REGS flags for module Steven Rostedt
2020-08-09 15:53   ` Sasha Levin
2020-08-04 20:57 ` [for-linus][PATCH 06/17] ftrace: Do not let direct or IPMODIFY ftrace_ops be added to module and set trampolines Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 07/17] tracing: Remove outdated comment in stack handling Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 09/17] tracepoint: Mark __tracepoint_strings __used Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 10/17] tracepoint: Use __used attribute definitions from compiler_attributes.h Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 11/17] ftrace: Fix ftrace_trace_task return value Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 12/17] kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 13/17] tracing/uprobe: Remove dead code in trace_uprobe_register() Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 14/17] kprobes: Remove show_registers() function prototype Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 15/17] lib/bootconfig: Add override operator support Steven Rostedt
2020-08-04 20:57 ` [for-linus][PATCH 16/17] tools/bootconfig: Add testcases for value override operator Steven Rostedt
2020-08-04 20:58 ` [for-linus][PATCH 17/17] Documentation: bootconfig: Add bootconfig " Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).