Skip to contentSkip to conversation

tracing: Updates for 5.6

PATCH In review Steven Rostedt 6 participants 65 messages Jan 14, 2020 – Feb 19, 2020

Subsystems (11)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: Updates for 5.6

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

Head SHA1: 3b42a4c83a31d8f1d8a7cb7eb2f4ee809d42c69d

Masami Hiramatsu (23):
bootconfig: Add Extra Boot Config support
bootconfig: Load boot config from the tail of initrd
tools: bootconfig: Add bootconfig command
tools: bootconfig: Add bootconfig test script
proc: bootconfig: Add /proc/bootconfig to show boot config list init/main.c: Alloc initcall_command_line in do_initcall() and free it
bootconfig: init: Allow admin to use bootconfig for kernel command line
bootconfig: init: Allow admin to use bootconfig for init command line
Documentation: bootconfig: Add a doc for extended boot config
tracing: Apply soft-disabled and filter to tracepoints printk
tracing: kprobes: Output kprobe event to printk buffer
tracing: kprobes: Register to dynevent earlier stage
tracing: Accept different type for synthetic event fields
tracing: Add NULL trace-array check in print_synth_event() tracing/boot: Add boot-time tracing
tracing/boot: Add per-event settings
tracing/boot Add kprobe event support
tracing/boot: Add synthetic event support
tracing/boot: Add instance node support
tracing/boot: Add cpu_mask option support
tracing/boot: Add function tracer filter options
Documentation: tracing: Add boot-time tracing document
tracing: trigger: Replace unneeded RCU-list traversals

Steven Rostedt (VMware) (3):
perf: Make struct ring_buffer less ambiguous
tracing: Rename trace_buffer to array_buffer
tracing: Make struct ring_buffer less ambiguous

----

 Documentation/admin-guide/bootconfig.rst           | 186 +++++
 Documentation/admin-guide/index.rst                |   1 +
 Documentation/trace/boottime-trace.rst             | 184 +++++
 Documentation/trace/index.rst                      |   1 +
 MAINTAINERS                                        |   9 +
 drivers/oprofile/cpu_buffer.c                      |   2 +-
 fs/proc/Makefile                                   |   1 +
 fs/proc/bootconfig.c                               |  89 +++
 include/linux/bootconfig.h                         | 224 ++++++
 include/linux/perf_event.h                         |   6 +-
 include/linux/ring_buffer.h                        | 110 +--
 include/linux/trace_events.h                       |   9 +-
 include/trace/trace_events.h                       |   2 +-
 init/Kconfig                                       |  12 +
 init/main.c                                        | 213 +++++-
 kernel/events/core.c                               |  42 +-
 kernel/events/internal.h                           |  34 +-
 kernel/events/ring_buffer.c                        |  54 +-
 kernel/trace/Kconfig                               |   9 +
 kernel/trace/Makefile                              |   1 +
 kernel/trace/blktrace.c                            |   8 +-
 kernel/trace/ftrace.c                              |   8 +-
 kernel/trace/ring_buffer.c                         | 124 ++--
 kernel/trace/ring_buffer_benchmark.c               |   2 +-
 kernel/trace/trace.c                               | 355 ++++-----
 kernel/trace/trace.h                               |  38 +-
 kernel/trace/trace_boot.c                          | 353 +++++++++
 kernel/trace/trace_branch.c                        |   6 +-
 kernel/trace/trace_events.c                        |  21 +-
 kernel/trace/trace_events_hist.c                   |  59 +-
 kernel/trace/trace_events_trigger.c                |  22 +-
 kernel/trace/trace_functions.c                     |   8 +-
 kernel/trace/trace_functions_graph.c               |  14 +-
 kernel/trace/trace_hwlat.c                         |   2 +-
 kernel/trace/trace_irqsoff.c                       |   8 +-
 kernel/trace/trace_kdb.c                           |   8 +-
 kernel/trace/trace_kprobe.c                        |  81 ++-
 kernel/trace/trace_mmiotrace.c                     |  12 +-
 kernel/trace/trace_output.c                        |   2 +-
 kernel/trace/trace_sched_wakeup.c                  |  20 +-
 kernel/trace/trace_selftest.c                      |  26 +-
 kernel/trace/trace_syscalls.c                      |   8 +-
 kernel/trace/trace_uprobe.c                        |   2 +-
 lib/Kconfig                                        |   3 +
 lib/Makefile                                       |   2 +
 lib/bootconfig.c                                   | 803 +++++++++++++++++++++
 tools/Makefile                                     |  11 +-
 tools/bootconfig/.gitignore                        |   1 +
 tools/bootconfig/Makefile                          |  23 +
 tools/bootconfig/include/linux/bootconfig.h        |   7 +
 tools/bootconfig/include/linux/bug.h               |  12 +
 tools/bootconfig/include/linux/ctype.h             |   7 +
 tools/bootconfig/include/linux/errno.h             |   7 +
 tools/bootconfig/include/linux/kernel.h            |  18 +
 tools/bootconfig/include/linux/printk.h            |  17 +
 tools/bootconfig/include/linux/string.h            |  32 +
 tools/bootconfig/main.c                            | 353 +++++++++
 .../samples/bad-array-space-comment.bconf          |   5 +
 tools/bootconfig/samples/bad-array.bconf           |   2 +
 tools/bootconfig/samples/bad-dotword.bconf         |   4 +
 tools/bootconfig/samples/bad-empty.bconf           |   1 +
 tools/bootconfig/samples/bad-keyerror.bconf        |   2 +
 tools/bootconfig/samples/bad-longkey.bconf         |   1 +
 tools/bootconfig/samples/bad-manywords.bconf       |   1 +
 tools/bootconfig/samples/bad-no-keyword.bconf      |   2 +
 tools/bootconfig/samples/bad-nonprintable.bconf    |   2 +
 tools/bootconfig/samples/bad-spaceword.bconf       |   2 +
 tools/bootconfig/samples/bad-tree.bconf            |   5 +
 tools/bootconfig/samples/bad-value.bconf           |   3 +
 tools/bootconfig/samples/escaped.bconf             |   3 +
 .../samples/good-array-space-comment.bconf         |   4 +
 .../samples/good-comment-after-value.bconf         |   1 +
 tools/bootconfig/samples/good-printables.bconf     |   2 +
 tools/bootconfig/samples/good-simple.bconf         |  11 +
 tools/bootconfig/samples/good-single.bconf         |   4 +
 .../samples/good-space-after-value.bconf           |   1 +
 tools/bootconfig/samples/good-tree.bconf           |  12 +
 tools/bootconfig/test-bootconfig.sh                | 105 +++
 78 files changed, 3315 insertions(+), 530 deletions(-)
 create mode 100644 Documentation/admin-guide/bootconfig.rst
 create mode 100644 Documentation/trace/boottime-trace.rst
 create mode 100644 fs/proc/bootconfig.c
 create mode 100644 include/linux/bootconfig.h
 create mode 100644 kernel/trace/trace_boot.c
 create mode 100644 lib/bootconfig.c
 create mode 100644 tools/bootconfig/.gitignore
 create mode 100644 tools/bootconfig/Makefile
 create mode 100644 tools/bootconfig/include/linux/bootconfig.h
 create mode 100644 tools/bootconfig/include/linux/bug.h
 create mode 100644 tools/bootconfig/include/linux/ctype.h
 create mode 100644 tools/bootconfig/include/linux/errno.h
 create mode 100644 tools/bootconfig/include/linux/kernel.h
 create mode 100644 tools/bootconfig/include/linux/printk.h
 create mode 100644 tools/bootconfig/include/linux/string.h
 create mode 100644 tools/bootconfig/main.c
 create mode 100644 tools/bootconfig/samples/bad-array-space-comment.bconf
 create mode 100644 tools/bootconfig/samples/bad-array.bconf
 create mode 100644 tools/bootconfig/samples/bad-dotword.bconf
 create mode 100644 tools/bootconfig/samples/bad-empty.bconf
 create mode 100644 tools/bootconfig/samples/bad-keyerror.bconf
 create mode 100644 tools/bootconfig/samples/bad-longkey.bconf
 create mode 100644 tools/bootconfig/samples/bad-manywords.bconf
 create mode 100644 tools/bootconfig/samples/bad-no-keyword.bconf
 create mode 100644 tools/bootconfig/samples/bad-nonprintable.bconf
 create mode 100644 tools/bootconfig/samples/bad-spaceword.bconf
 create mode 100644 tools/bootconfig/samples/bad-tree.bconf
 create mode 100644 tools/bootconfig/samples/bad-value.bconf
 create mode 100644 tools/bootconfig/samples/escaped.bconf
 create mode 100644 tools/bootconfig/samples/good-array-space-comment.bconf
 create mode 100644 tools/bootconfig/samples/good-comment-after-value.bconf
 create mode 100644 tools/bootconfig/samples/good-printables.bconf
 create mode 100644 tools/bootconfig/samples/good-simple.bconf
 create mode 100644 tools/bootconfig/samples/good-single.bconf
 create mode 100644 tools/bootconfig/samples/good-space-after-value.bconf
 create mode 100644 tools/bootconfig/samples/good-tree.bconf
 create mode 100755 tools/bootconfig/test-bootconfig.sh
author maintainer
#1 lore raw

PATCH 1/26 perf: Make struct ring_buffer less ambiguous

From: "Steven Rostedt (VMware)" <[email protected]>

eBPF requires needing to know the size of the perf ring buffer structure. But it unfortunately has the same name as the generic ring buffer used by tracing and oprofile. To make it less ambiguous, rename the perf ring buffer structure to "perf_buffer".

As other parts of the ring buffer code has "perf_" as the prefix, it only makes sense to give the ring buffer the "perf_" prefix as well.

---
 include/linux/perf_event.h  |  6 ++---
 kernel/events/core.c        | 42 ++++++++++++++---------------
 kernel/events/internal.h    | 34 +++++++++++------------
 kernel/events/ring_buffer.c | 54 ++++++++++++++++++-------------------
 4 files changed, 68 insertions(+), 68 deletions(-)
include/linux/perf_event.h +3 -3
index 6d4c22aee384..cf65763af0cb 100644
@@ -582,7 +582,7 @@ struct swevent_hlist {
 #define PERF_ATTACH_ITRACE	0x10
 
 struct perf_cgroup;
-struct ring_buffer;
+struct perf_buffer;
 
 struct pmu_event_list {
 	raw_spinlock_t		lock;
@@ -694,7 +694,7 @@ struct perf_event {
 	struct mutex			mmap_mutex;
 	atomic_t			mmap_count;
 
-	struct ring_buffer		*rb;
+	struct perf_buffer		*rb;
 	struct list_head		rb_entry;
 	unsigned long			rcu_batches;
 	int				rcu_pending;
@@ -854,7 +854,7 @@ struct perf_cpu_context {
 
 struct perf_output_handle {
 	struct perf_event		*event;
-	struct ring_buffer		*rb;
+	struct perf_buffer		*rb;
 	unsigned long			wakeup;
 	unsigned long			size;
 	u64				aux_flags;
kernel/events/core.c +21 -21

160 lines not on this page · raw message

kernel/events/internal.h +17 -17
index 747d67f130cb..f16f66b6b655 100644
@@ -10,7 +10,7 @@
 
 #define RING_BUFFER_WRITABLE		0x01
 
-struct ring_buffer {
+struct perf_buffer {
 	refcount_t			refcount;
 	struct rcu_head			rcu_head;
 #ifdef CONFIG_PERF_USE_VMALLOC
@@ -58,17 +58,17 @@ struct ring_buffer {
 	void				*data_pages[0];
 };
 
-extern void rb_free(struct ring_buffer *rb);
+extern void rb_free(struct perf_buffer *rb);
 
 static inline void rb_free_rcu(struct rcu_head *rcu_head)
 {
-	struct ring_buffer *rb;
+	struct perf_buffer *rb;
 
-	rb = container_of(rcu_head, struct ring_buffer, rcu_head);
+	rb = container_of(rcu_head, struct perf_buffer, rcu_head);
 	rb_free(rb);
 }
 
-static inline void rb_toggle_paused(struct ring_buffer *rb, bool pause)
+static inline void rb_toggle_paused(struct perf_buffer *rb, bool pause)
 {
 	if (!pause && rb->nr_pages)
 		rb->paused = 0;
@@ -76,16 +76,16 @@ static inline void rb_toggle_paused(struct ring_buffer *rb, bool pause)
 		rb->paused = 1;
 }
 
-extern struct ring_buffer *
+extern struct perf_buffer *
 rb_alloc(int nr_pages, long watermark, int cpu, int flags);
 extern void perf_event_wakeup(struct perf_event *event);
-extern int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
+extern int rb_alloc_aux(struct perf_buffer *rb, struct perf_event *event,
 			pgoff_t pgoff, int nr_pages, long watermark, int flags);
-extern void rb_free_aux(struct ring_buffer *rb);
-extern struct ring_buffer *ring_buffer_get(struct perf_event *event);
-extern void ring_buffer_put(struct ring_buffer *rb);
+extern void rb_free_aux(struct perf_buffer *rb);
+extern struct perf_buffer *ring_buffer_get(struct perf_event *event);
+extern void ring_buffer_put(struct perf_buffer *rb);
 
-static inline bool rb_has_aux(struct ring_buffer *rb)
+static inline bool rb_has_aux(struct perf_buffer *rb)
 {
 	return !!rb->aux_nr_pages;
 }
@@ -94,7 +94,7 @@ void perf_event_aux_event(struct perf_event *event, unsigned long head,
 			  unsigned long size, u64 flags);
 
 extern struct page *
-perf_mmap_to_page(struct ring_buffer *rb, unsigned long pgoff);
+perf_mmap_to_page(struct perf_buffer *rb, unsigned long pgoff);
 
 #ifdef CONFIG_PERF_USE_VMALLOC
 /*
@@ -103,25 +103,25 @@ perf_mmap_to_page(struct ring_buffer *rb, unsigned long pgoff);
  * Required for architectures that have d-cache aliasing issues.
  */
 
-static inline int page_order(struct ring_buffer *rb)
+static inline int page_order(struct perf_buffer *rb)
 {
 	return rb->page_order;
 }
 
 #else
 
-static inline int page_order(struct ring_buffer *rb)
+static inline int page_order(struct perf_buffer *rb)
 {
 	return 0;
 }
 #endif
 
-static inline unsigned long perf_data_size(struct ring_buffer *rb)
+static inline unsigned long perf_data_size(struct perf_buffer *rb)
 {
 	return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
 }
 
-static inline unsigned long perf_aux_size(struct ring_buffer *rb)
+static inline unsigned long perf_aux_size(struct perf_buffer *rb)
 {
 	return rb->aux_nr_pages << PAGE_SHIFT;
 }
@@ -141,7 +141,7 @@ static inline unsigned long perf_aux_size(struct ring_buffer *rb)
 			buf += written;					\
 		handle->size -= written;				\
 		if (!handle->size) {					\
-			struct ring_buffer *rb = handle->rb;		\
+			struct perf_buffer *rb = handle->rb;	\
 									\
 			handle->page++;					\
 			handle->page &= rb->nr_pages - 1;		\
kernel/events/ring_buffer.c +27 -27

195 lines not on this page · raw message

Signature · 1 line
2.24.1
author maintainer
#2 lore raw

PATCH 2/26 tracing: Rename trace_buffer to array_buffer

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

As we are working to remove the generic "ring_buffer" name that is used by both tracing and perf, the ring_buffer name for tracing will be renamed to trace_buffer, and perf's ring buffer will be renamed to perf_buffer.

As there already exists a trace_buffer that is used by the trace_arrays, it needs to be first renamed to array_buffer.

---
 include/linux/trace_events.h         |   4 +-
 kernel/trace/blktrace.c              |   4 +-
 kernel/trace/ftrace.c                |   8 +-
 kernel/trace/trace.c                 | 230 +++++++++++++--------------
 kernel/trace/trace.h                 |  16 +-
 kernel/trace/trace_branch.c          |   4 +-
 kernel/trace/trace_events.c          |  18 +--
 kernel/trace/trace_events_hist.c     |   2 +-
 kernel/trace/trace_functions.c       |   8 +-
 kernel/trace/trace_functions_graph.c |  14 +-
 kernel/trace/trace_hwlat.c           |   2 +-
 kernel/trace/trace_irqsoff.c         |   8 +-
 kernel/trace/trace_kdb.c             |   8 +-
 kernel/trace/trace_mmiotrace.c       |  12 +-
 kernel/trace/trace_output.c          |   2 +-
 kernel/trace/trace_sched_wakeup.c    |  20 +--
 kernel/trace/trace_selftest.c        |  26 +--
 kernel/trace/trace_syscalls.c        |   4 +-
 18 files changed, 195 insertions(+), 195 deletions(-)
include/linux/trace_events.h +2 -2
index 4c6e15605766..f70e5bc7e8db 100644
@@ -11,7 +11,7 @@
 #include <linux/tracepoint.h>
 
 struct trace_array;
-struct trace_buffer;
+struct array_buffer;
 struct tracer;
 struct dentry;
 struct bpf_prog;
@@ -79,7 +79,7 @@ struct trace_entry {
 struct trace_iterator {
 	struct trace_array	*tr;
 	struct tracer		*trace;
-	struct trace_buffer	*trace_buffer;
+	struct array_buffer	*array_buffer;
 	void			*private;
 	int			cpu_file;
 	struct mutex		mutex;
kernel/trace/blktrace.c +2 -2
index 475e29498bca..3b926f62ed83 100644
@@ -75,7 +75,7 @@ static void trace_note(struct blk_trace *bt, pid_t pid, int action,
 	ssize_t cgid_len = cgid ? sizeof(cgid) : 0;
 
 	if (blk_tracer) {
-		buffer = blk_tr->trace_buffer.buffer;
+		buffer = blk_tr->array_buffer.buffer;
 		pc = preempt_count();
 		event = trace_buffer_lock_reserve(buffer, TRACE_BLK,
 						  sizeof(*t) + len + cgid_len,
@@ -248,7 +248,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
 	if (blk_tracer) {
 		tracing_record_cmdline(current);
 
-		buffer = blk_tr->trace_buffer.buffer;
+		buffer = blk_tr->array_buffer.buffer;
 		pc = preempt_count();
 		event = trace_buffer_lock_reserve(buffer, TRACE_BLK,
 						  sizeof(*t) + pdu_len + cgid_len,
kernel/trace/ftrace.c +4 -4
index 9bf1f2cd515e..3f0ae07e72ef 100644
@@ -146,7 +146,7 @@ static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip,
 {
 	struct trace_array *tr = op->private;
 
-	if (tr && this_cpu_read(tr->trace_buffer.data->ftrace_ignore_pid))
+	if (tr && this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid))
 		return;
 
 	op->saved_func(ip, parent_ip, op, regs);
@@ -6922,7 +6922,7 @@ ftrace_filter_pid_sched_switch_probe(void *data, bool preempt,
 
 	pid_list = rcu_dereference_sched(tr->function_pids);
 
-	this_cpu_write(tr->trace_buffer.data->ftrace_ignore_pid,
+	this_cpu_write(tr->array_buffer.data->ftrace_ignore_pid,
 		       trace_ignore_this_task(pid_list, next));
 }
 
@@ -6976,7 +6976,7 @@ static void clear_ftrace_pids(struct trace_array *tr)
 	unregister_trace_sched_switch(ftrace_filter_pid_sched_switch_probe, tr);
 
 	for_each_possible_cpu(cpu)
-		per_cpu_ptr(tr->trace_buffer.data, cpu)->ftrace_ignore_pid = false;
+		per_cpu_ptr(tr->array_buffer.data, cpu)->ftrace_ignore_pid = false;
 
 	rcu_assign_pointer(tr->function_pids, NULL);
 
@@ -7100,7 +7100,7 @@ static void ignore_task_cpu(void *data)
 	pid_list = rcu_dereference_protected(tr->function_pids,
 					     mutex_is_locked(&ftrace_lock));
 
-	this_cpu_write(tr->trace_buffer.data->ftrace_ignore_pid,
+	this_cpu_write(tr->array_buffer.data->ftrace_ignore_pid,
 		       trace_ignore_this_task(pid_list, current));
 }
 
kernel/trace/trace.c +115 -115

798 lines not on this page · raw message

kernel/trace/trace.h +8 -8
index 63bf60f79398..fd679fe92c1f 100644
@@ -176,7 +176,7 @@ struct trace_array_cpu {
 struct tracer;
 struct trace_option_dentry;
 
-struct trace_buffer {
+struct array_buffer {
 	struct trace_array		*tr;
 	struct ring_buffer		*buffer;
 	struct trace_array_cpu __percpu	*data;
@@ -249,7 +249,7 @@ struct cond_snapshot {
 struct trace_array {
 	struct list_head	list;
 	char			*name;
-	struct trace_buffer	trace_buffer;
+	struct array_buffer	array_buffer;
 #ifdef CONFIG_TRACER_MAX_TRACE
 	/*
 	 * The max_buffer is used to snapshot the trace when a maximum
@@ -257,12 +257,12 @@ struct trace_array {
 	 * Some tracers will use this to store a maximum trace while
 	 * it continues examining live traces.
 	 *
-	 * The buffers for the max_buffer are set up the same as the trace_buffer
+	 * The buffers for the max_buffer are set up the same as the array_buffer
 	 * When a snapshot is taken, the buffer of the max_buffer is swapped
-	 * with the buffer of the trace_buffer and the buffers are reset for
-	 * the trace_buffer so the tracing can continue.
+	 * with the buffer of the array_buffer and the buffers are reset for
+	 * the array_buffer so the tracing can continue.
 	 */
-	struct trace_buffer	max_buffer;
+	struct array_buffer	max_buffer;
 	bool			allocated_snapshot;
 #endif
 #if defined(CONFIG_TRACER_MAX_TRACE) || defined(CONFIG_HWLAT_TRACER)
@@ -685,7 +685,7 @@ trace_buffer_iter(struct trace_iterator *iter, int cpu)
 
 int tracer_init(struct tracer *t, struct trace_array *tr);
 int tracing_is_enabled(void);
-void tracing_reset_online_cpus(struct trace_buffer *buf);
+void tracing_reset_online_cpus(struct array_buffer *buf);
 void tracing_reset_current(int cpu);
 void tracing_reset_all_online_cpus(void);
 int tracing_open_generic(struct inode *inode, struct file *filp);
@@ -1057,7 +1057,7 @@ 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->trace_buffer.data->ftrace_ignore_pid);
+	return !this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid);
 }
 extern int ftrace_is_dead(void);
 int ftrace_create_function_files(struct trace_array *tr,
kernel/trace/trace_branch.c +2 -2
index 88e158d27965..d5989284a99a 100644
@@ -55,12 +55,12 @@ probe_likely_condition(struct ftrace_likely_data *f, int val, int expect)
 
 	raw_local_irq_save(flags);
 	current->trace_recursion |= TRACE_BRANCH_BIT;
-	data = this_cpu_ptr(tr->trace_buffer.data);
+	data = this_cpu_ptr(tr->array_buffer.data);
 	if (atomic_read(&data->disabled))
 		goto out;
 
 	pc = preempt_count();
-	buffer = tr->trace_buffer.buffer;
+	buffer = tr->array_buffer.buffer;
 	event = trace_buffer_lock_reserve(buffer, TRACE_BRANCH,
 					  sizeof(*entry), flags, pc);
 	if (!event)
kernel/trace/trace_events.c +9 -9
index a5b614cc3887..ac557f685f0b 100644
@@ -237,7 +237,7 @@ bool trace_event_ignore_this_pid(struct trace_event_file *trace_file)
 	if (!pid_list)
 		return false;
 
-	data = this_cpu_ptr(tr->trace_buffer.data);
+	data = this_cpu_ptr(tr->array_buffer.data);
 
 	return data->ignore_pid;
 }
@@ -546,7 +546,7 @@ event_filter_pid_sched_switch_probe_pre(void *data, bool preempt,
 
 	pid_list = rcu_dereference_sched(tr->filtered_pids);
 
-	this_cpu_write(tr->trace_buffer.data->ignore_pid,
+	this_cpu_write(tr->array_buffer.data->ignore_pid,
 		       trace_ignore_this_task(pid_list, prev) &&
 		       trace_ignore_this_task(pid_list, next));
 }
@@ -560,7 +560,7 @@ event_filter_pid_sched_switch_probe_post(void *data, bool preempt,
 
 	pid_list = rcu_dereference_sched(tr->filtered_pids);
 
-	this_cpu_write(tr->trace_buffer.data->ignore_pid,
+	this_cpu_write(tr->array_buffer.data->ignore_pid,
 		       trace_ignore_this_task(pid_list, next));
 }
 
@@ -571,12 +571,12 @@ event_filter_pid_sched_wakeup_probe_pre(void *data, struct task_struct *task)
 	struct trace_pid_list *pid_list;
 
 	/* Nothing to do if we are already tracing */
-	if (!this_cpu_read(tr->trace_buffer.data->ignore_pid))
+	if (!this_cpu_read(tr->array_buffer.data->ignore_pid))
 		return;
 
 	pid_list = rcu_dereference_sched(tr->filtered_pids);
 
-	this_cpu_write(tr->trace_buffer.data->ignore_pid,
+	this_cpu_write(tr->array_buffer.data->ignore_pid,
 		       trace_ignore_this_task(pid_list, task));
 }
 
@@ -587,13 +587,13 @@ event_filter_pid_sched_wakeup_probe_post(void *data, struct task_struct *task)
 	struct trace_pid_list *pid_list;
 
 	/* Nothing to do if we are not tracing */
-	if (this_cpu_read(tr->trace_buffer.data->ignore_pid))
+	if (this_cpu_read(tr->array_buffer.data->ignore_pid))
 		return;
 
 	pid_list = rcu_dereference_sched(tr->filtered_pids);
 
 	/* Set tracing if current is enabled */
-	this_cpu_write(tr->trace_buffer.data->ignore_pid,
+	this_cpu_write(tr->array_buffer.data->ignore_pid,
 		       trace_ignore_this_task(pid_list, current));
 }
 
@@ -625,7 +625,7 @@ static void __ftrace_clear_event_pids(struct trace_array *tr)
 	}
 
 	for_each_possible_cpu(cpu)
-		per_cpu_ptr(tr->trace_buffer.data, cpu)->ignore_pid = false;
+		per_cpu_ptr(tr->array_buffer.data, cpu)->ignore_pid = false;
 
 	rcu_assign_pointer(tr->filtered_pids, NULL);
 
@@ -1594,7 +1594,7 @@ static void ignore_task_cpu(void *data)
 	pid_list = rcu_dereference_protected(tr->filtered_pids,
 					     mutex_is_locked(&event_mutex));
 
-	this_cpu_write(tr->trace_buffer.data->ignore_pid,
+	this_cpu_write(tr->array_buffer.data->ignore_pid,
 		       trace_ignore_this_task(pid_list, current));
 }
 
kernel/trace/trace_events_hist.c +1 -1
index f62de5f43e79..94c581c1a897 100644
@@ -895,7 +895,7 @@ static notrace void trace_event_raw_event_synth(void *__data,
 	 * Avoid ring buffer recursion detection, as this event
 	 * is being performed within another event.
 	 */
-	buffer = trace_file->tr->trace_buffer.buffer;
+	buffer = trace_file->tr->array_buffer.buffer;
 	ring_buffer_nest_start(buffer);
 
 	entry = trace_event_buffer_reserve(&fbuffer, trace_file,
kernel/trace/trace_functions.c +4 -4
index b611cd36e22d..8a4c8d5c2c98 100644
@@ -101,7 +101,7 @@ static int function_trace_init(struct trace_array *tr)
 
 	ftrace_init_array_ops(tr, func);
 
-	tr->trace_buffer.cpu = get_cpu();
+	tr->array_buffer.cpu = get_cpu();
 	put_cpu();
 
 	tracing_start_cmdline_record();
@@ -118,7 +118,7 @@ static void function_trace_reset(struct trace_array *tr)
 
 static void function_trace_start(struct trace_array *tr)
 {
-	tracing_reset_online_cpus(&tr->trace_buffer);
+	tracing_reset_online_cpus(&tr->array_buffer);
 }
 
 static void
@@ -143,7 +143,7 @@ function_trace_call(unsigned long ip, unsigned long parent_ip,
 		goto out;
 
 	cpu = smp_processor_id();
-	data = per_cpu_ptr(tr->trace_buffer.data, cpu);
+	data = per_cpu_ptr(tr->array_buffer.data, cpu);
 	if (!atomic_read(&data->disabled)) {
 		local_save_flags(flags);
 		trace_function(tr, ip, parent_ip, flags, pc);
@@ -192,7 +192,7 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
 	 */
 	local_irq_save(flags);
 	cpu = raw_smp_processor_id();
-	data = per_cpu_ptr(tr->trace_buffer.data, cpu);
+	data = per_cpu_ptr(tr->array_buffer.data, cpu);
 	disabled = atomic_inc_return(&data->disabled);
 
 	if (likely(disabled == 1)) {
kernel/trace/trace_functions_graph.c +7 -7
index 78af97163147..79b2c2df00c5 100644
@@ -101,7 +101,7 @@ int __trace_graph_entry(struct trace_array *tr,
 {
 	struct trace_event_call *call = &event_funcgraph_entry;
 	struct ring_buffer_event *event;
-	struct ring_buffer *buffer = tr->trace_buffer.buffer;
+	struct ring_buffer *buffer = tr->array_buffer.buffer;
 	struct ftrace_graph_ent_entry *entry;
 
 	event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_ENT,
@@ -171,7 +171,7 @@ int trace_graph_entry(struct ftrace_graph_ent *trace)
 
 	local_irq_save(flags);
 	cpu = raw_smp_processor_id();
-	data = per_cpu_ptr(tr->trace_buffer.data, cpu);
+	data = per_cpu_ptr(tr->array_buffer.data, cpu);
 	disabled = atomic_inc_return(&data->disabled);
 	if (likely(disabled == 1)) {
 		pc = preempt_count();
@@ -221,7 +221,7 @@ void __trace_graph_return(struct trace_array *tr,
 {
 	struct trace_event_call *call = &event_funcgraph_exit;
 	struct ring_buffer_event *event;
-	struct ring_buffer *buffer = tr->trace_buffer.buffer;
+	struct ring_buffer *buffer = tr->array_buffer.buffer;
 	struct ftrace_graph_ret_entry *entry;
 
 	event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_RET,
@@ -252,7 +252,7 @@ void trace_graph_return(struct ftrace_graph_ret *trace)
 
 	local_irq_save(flags);
 	cpu = raw_smp_processor_id();
-	data = per_cpu_ptr(tr->trace_buffer.data, cpu);
+	data = per_cpu_ptr(tr->array_buffer.data, cpu);
 	disabled = atomic_inc_return(&data->disabled);
 	if (likely(disabled == 1)) {
 		pc = preempt_count();
@@ -444,9 +444,9 @@ get_return_for_leaf(struct trace_iterator *iter,
 			 * We need to consume the current entry to see
 			 * the next one.
 			 */
-			ring_buffer_consume(iter->trace_buffer->buffer, iter->cpu,
+			ring_buffer_consume(iter->array_buffer->buffer, iter->cpu,
 					    NULL, NULL);
-			event = ring_buffer_peek(iter->trace_buffer->buffer, iter->cpu,
+			event = ring_buffer_peek(iter->array_buffer->buffer, iter->cpu,
 						 NULL, NULL);
 		}
 
@@ -503,7 +503,7 @@ print_graph_rel_time(struct trace_iterator *iter, struct trace_seq *s)
 {
 	unsigned long long usecs;
 
-	usecs = iter->ts - iter->trace_buffer->time_start;
+	usecs = iter->ts - iter->array_buffer->time_start;
 	do_div(usecs, NSEC_PER_USEC);
 
 	trace_seq_printf(s, "%9llu us |  ", usecs);
kernel/trace/trace_hwlat.c +1 -1
index 6638d63f0921..fc62a6049bd3 100644
@@ -104,7 +104,7 @@ static void trace_hwlat_sample(struct hwlat_sample *sample)
 {
 	struct trace_array *tr = hwlat_trace;
 	struct trace_event_call *call = &event_hwlat;
-	struct ring_buffer *buffer = tr->trace_buffer.buffer;
+	struct ring_buffer *buffer = tr->array_buffer.buffer;
 	struct ring_buffer_event *event;
 	struct hwlat_entry *entry;
 	unsigned long flags;
kernel/trace/trace_irqsoff.c +4 -4
index a745b0cee5d3..10bbb0f381d5 100644
@@ -122,7 +122,7 @@ static int func_prolog_dec(struct trace_array *tr,
 	if (!irqs_disabled_flags(*flags) && !preempt_count())
 		return 0;
 
-	*data = per_cpu_ptr(tr->trace_buffer.data, cpu);
+	*data = per_cpu_ptr(tr->array_buffer.data, cpu);
 	disabled = atomic_inc_return(&(*data)->disabled);
 
 	if (likely(disabled == 1))
@@ -167,7 +167,7 @@ static int irqsoff_display_graph(struct trace_array *tr, int set)
 		per_cpu(tracing_cpu, cpu) = 0;
 
 	tr->max_latency = 0;
-	tracing_reset_online_cpus(&irqsoff_trace->trace_buffer);
+	tracing_reset_online_cpus(&irqsoff_trace->array_buffer);
 
 	return start_irqsoff_tracer(irqsoff_trace, set);
 }
@@ -382,7 +382,7 @@ start_critical_timing(unsigned long ip, unsigned long parent_ip, int pc)
 	if (per_cpu(tracing_cpu, cpu))
 		return;
 
-	data = per_cpu_ptr(tr->trace_buffer.data, cpu);
+	data = per_cpu_ptr(tr->array_buffer.data, cpu);
 
 	if (unlikely(!data) || atomic_read(&data->disabled))
 		return;
@@ -420,7 +420,7 @@ stop_critical_timing(unsigned long ip, unsigned long parent_ip, int pc)
 	if (!tracer_enabled || !tracing_is_enabled())
 		return;
 
-	data = per_cpu_ptr(tr->trace_buffer.data, cpu);
+	data = per_cpu_ptr(tr->array_buffer.data, cpu);
 
 	if (unlikely(!data) ||
 	    !data->critical_start || atomic_read(&data->disabled))
kernel/trace/trace_kdb.c +4 -4
index cca65044c14c..9da76104f7a2 100644
@@ -43,7 +43,7 @@ static void ftrace_dump_buf(int skip_entries, long cpu_file)
 	if (cpu_file == RING_BUFFER_ALL_CPUS) {
 		for_each_tracing_cpu(cpu) {
 			iter.buffer_iter[cpu] =
-			ring_buffer_read_prepare(iter.trace_buffer->buffer,
+			ring_buffer_read_prepare(iter.array_buffer->buffer,
 						 cpu, GFP_ATOMIC);
 			ring_buffer_read_start(iter.buffer_iter[cpu]);
 			tracing_iter_reset(&iter, cpu);
@@ -51,7 +51,7 @@ static void ftrace_dump_buf(int skip_entries, long cpu_file)
 	} else {
 		iter.cpu_file = cpu_file;
 		iter.buffer_iter[cpu_file] =
-			ring_buffer_read_prepare(iter.trace_buffer->buffer,
+			ring_buffer_read_prepare(iter.array_buffer->buffer,
 						 cpu_file, GFP_ATOMIC);
 		ring_buffer_read_start(iter.buffer_iter[cpu_file]);
 		tracing_iter_reset(&iter, cpu_file);
@@ -124,7 +124,7 @@ static int kdb_ftdump(int argc, const char **argv)
 	iter.buffer_iter = buffer_iter;
 
 	for_each_tracing_cpu(cpu) {
-		atomic_inc(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled);
+		atomic_inc(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled);
 	}
 
 	/* A negative skip_entries means skip all but the last entries */
@@ -139,7 +139,7 @@ static int kdb_ftdump(int argc, const char **argv)
 	ftrace_dump_buf(skip_entries, cpu_file);
 
 	for_each_tracing_cpu(cpu) {
-		atomic_dec(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled);
+		atomic_dec(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled);
 	}
 
 	kdb_trap_printk--;
kernel/trace/trace_mmiotrace.c +6 -6
index b0388016b687..c30137148759 100644
@@ -32,7 +32,7 @@ static void mmio_reset_data(struct trace_array *tr)
 	overrun_detected = false;
 	prev_overruns = 0;
 
-	tracing_reset_online_cpus(&tr->trace_buffer);
+	tracing_reset_online_cpus(&tr->array_buffer);
 }
 
 static int mmio_trace_init(struct trace_array *tr)
@@ -122,7 +122,7 @@ static void mmio_close(struct trace_iterator *iter)
 static unsigned long count_overruns(struct trace_iterator *iter)
 {
 	unsigned long cnt = atomic_xchg(&dropped_count, 0);
-	unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
+	unsigned long over = ring_buffer_overruns(iter->array_buffer->buffer);
 
 	if (over > prev_overruns)
 		cnt += over - prev_overruns;
@@ -297,7 +297,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
 				struct mmiotrace_rw *rw)
 {
 	struct trace_event_call *call = &event_mmiotrace_rw;
-	struct ring_buffer *buffer = tr->trace_buffer.buffer;
+	struct ring_buffer *buffer = tr->array_buffer.buffer;
 	struct ring_buffer_event *event;
 	struct trace_mmiotrace_rw *entry;
 	int pc = preempt_count();
@@ -318,7 +318,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
 void mmio_trace_rw(struct mmiotrace_rw *rw)
 {
 	struct trace_array *tr = mmio_trace_array;
-	struct trace_array_cpu *data = per_cpu_ptr(tr->trace_buffer.data, smp_processor_id());
+	struct trace_array_cpu *data = per_cpu_ptr(tr->array_buffer.data, smp_processor_id());
 	__trace_mmiotrace_rw(tr, data, rw);
 }
 
@@ -327,7 +327,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
 				struct mmiotrace_map *map)
 {
 	struct trace_event_call *call = &event_mmiotrace_map;
-	struct ring_buffer *buffer = tr->trace_buffer.buffer;
+	struct ring_buffer *buffer = tr->array_buffer.buffer;
 	struct ring_buffer_event *event;
 	struct trace_mmiotrace_map *entry;
 	int pc = preempt_count();
@@ -351,7 +351,7 @@ void mmio_trace_mapping(struct mmiotrace_map *map)
 	struct trace_array_cpu *data;
 
 	preempt_disable();
-	data = per_cpu_ptr(tr->trace_buffer.data, smp_processor_id());
+	data = per_cpu_ptr(tr->array_buffer.data, smp_processor_id());
 	__trace_mmiotrace_map(tr, data, map);
 	preempt_enable();
 }
kernel/trace/trace_output.c +1 -1
index d9b4b7c22db4..b4909082f6a4 100644
@@ -538,7 +538,7 @@ lat_print_timestamp(struct trace_iterator *iter, u64 next_ts)
 	struct trace_array *tr = iter->tr;
 	unsigned long verbose = tr->trace_flags & TRACE_ITER_VERBOSE;
 	unsigned long in_ns = iter->iter_flags & TRACE_FILE_TIME_IN_NS;
-	unsigned long long abs_ts = iter->ts - iter->trace_buffer->time_start;
+	unsigned long long abs_ts = iter->ts - iter->array_buffer->time_start;
 	unsigned long long rel_ts = next_ts - iter->ts;
 	struct trace_seq *s = &iter->seq;
 
kernel/trace/trace_sched_wakeup.c +10 -10
index 617e297f46dc..510fda2fcd24 100644
@@ -82,7 +82,7 @@ func_prolog_preempt_disable(struct trace_array *tr,
 	if (cpu != wakeup_current_cpu)
 		goto out_enable;
 
-	*data = per_cpu_ptr(tr->trace_buffer.data, cpu);
+	*data = per_cpu_ptr(tr->array_buffer.data, cpu);
 	disabled = atomic_inc_return(&(*data)->disabled);
 	if (unlikely(disabled != 1))
 		goto out;
@@ -378,7 +378,7 @@ tracing_sched_switch_trace(struct trace_array *tr,
 			   unsigned long flags, int pc)
 {
 	struct trace_event_call *call = &event_context_switch;
-	struct ring_buffer *buffer = tr->trace_buffer.buffer;
+	struct ring_buffer *buffer = tr->array_buffer.buffer;
 	struct ring_buffer_event *event;
 	struct ctx_switch_entry *entry;
 
@@ -408,7 +408,7 @@ tracing_sched_wakeup_trace(struct trace_array *tr,
 	struct trace_event_call *call = &event_wakeup;
 	struct ring_buffer_event *event;
 	struct ctx_switch_entry *entry;
-	struct ring_buffer *buffer = tr->trace_buffer.buffer;
+	struct ring_buffer *buffer = tr->array_buffer.buffer;
 
 	event = trace_buffer_lock_reserve(buffer, TRACE_WAKE,
 					  sizeof(*entry), flags, pc);
@@ -459,7 +459,7 @@ probe_wakeup_sched_switch(void *ignore, bool preempt,
 
 	/* disable local data, not wakeup_cpu data */
 	cpu = raw_smp_processor_id();
-	disabled = atomic_inc_return(&per_cpu_ptr(wakeup_trace->trace_buffer.data, cpu)->disabled);
+	disabled = atomic_inc_return(&per_cpu_ptr(wakeup_trace->array_buffer.data, cpu)->disabled);
 	if (likely(disabled != 1))
 		goto out;
 
@@ -471,7 +471,7 @@ probe_wakeup_sched_switch(void *ignore, bool preempt,
 		goto out_unlock;
 
 	/* The task we are waiting for is waking up */
-	data = per_cpu_ptr(wakeup_trace->trace_buffer.data, wakeup_cpu);
+	data = per_cpu_ptr(wakeup_trace->array_buffer.data, wakeup_cpu);
 
 	__trace_function(wakeup_trace, CALLER_ADDR0, CALLER_ADDR1, flags, pc);
 	tracing_sched_switch_trace(wakeup_trace, prev, next, flags, pc);
@@ -494,7 +494,7 @@ probe_wakeup_sched_switch(void *ignore, bool preempt,
 	arch_spin_unlock(&wakeup_lock);
 	local_irq_restore(flags);
 out:
-	atomic_dec(&per_cpu_ptr(wakeup_trace->trace_buffer.data, cpu)->disabled);
+	atomic_dec(&per_cpu_ptr(wakeup_trace->array_buffer.data, cpu)->disabled);
 }
 
 static void __wakeup_reset(struct trace_array *tr)
@@ -513,7 +513,7 @@ static void wakeup_reset(struct trace_array *tr)
 {
 	unsigned long flags;
 
-	tracing_reset_online_cpus(&tr->trace_buffer);
+	tracing_reset_online_cpus(&tr->array_buffer);
 
 	local_irq_save(flags);
 	arch_spin_lock(&wakeup_lock);
@@ -551,7 +551,7 @@ probe_wakeup(void *ignore, struct task_struct *p)
 		return;
 
 	pc = preempt_count();
-	disabled = atomic_inc_return(&per_cpu_ptr(wakeup_trace->trace_buffer.data, cpu)->disabled);
+	disabled = atomic_inc_return(&per_cpu_ptr(wakeup_trace->array_buffer.data, cpu)->disabled);
 	if (unlikely(disabled != 1))
 		goto out;
 
@@ -583,7 +583,7 @@ probe_wakeup(void *ignore, struct task_struct *p)
 
 	local_save_flags(flags);
 
-	data = per_cpu_ptr(wakeup_trace->trace_buffer.data, wakeup_cpu);
+	data = per_cpu_ptr(wakeup_trace->array_buffer.data, wakeup_cpu);
 	data->preempt_timestamp = ftrace_now(cpu);
 	tracing_sched_wakeup_trace(wakeup_trace, p, current, flags, pc);
 	__trace_stack(wakeup_trace, flags, 0, pc);
@@ -598,7 +598,7 @@ probe_wakeup(void *ignore, struct task_struct *p)
 out_locked:
 	arch_spin_unlock(&wakeup_lock);
 out:
-	atomic_dec(&per_cpu_ptr(wakeup_trace->trace_buffer.data, cpu)->disabled);
+	atomic_dec(&per_cpu_ptr(wakeup_trace->array_buffer.data, cpu)->disabled);
 }
 
 static void start_wakeup_tracer(struct trace_array *tr)
kernel/trace/trace_selftest.c +13 -13
index 69ee8ef12cee..b5e3496cf803 100644
@@ -23,7 +23,7 @@ static inline int trace_valid_entry(struct trace_entry *entry)
 	return 0;
 }
 
-static int trace_test_buffer_cpu(struct trace_buffer *buf, int cpu)
+static int trace_test_buffer_cpu(struct array_buffer *buf, int cpu)
 {
 	struct ring_buffer_event *event;
 	struct trace_entry *entry;
@@ -60,7 +60,7 @@ static int trace_test_buffer_cpu(struct trace_buffer *buf, int cpu)
  * Test the trace buffer to see if all the elements
  * are still sane.
  */
-static int __maybe_unused trace_test_buffer(struct trace_buffer *buf, unsigned long *count)
+static int __maybe_unused trace_test_buffer(struct array_buffer *buf, unsigned long *count)
 {
 	unsigned long flags, cnt = 0;
 	int cpu, ret = 0;
@@ -362,7 +362,7 @@ static int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
 	msleep(100);
 
 	/* we should have nothing in the buffer */
-	ret = trace_test_buffer(&tr->trace_buffer, &count);
+	ret = trace_test_buffer(&tr->array_buffer, &count);
 	if (ret)
 		goto out;
 
@@ -383,7 +383,7 @@ static int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
 	ftrace_enabled = 0;
 
 	/* check the trace buffer */
-	ret = trace_test_buffer(&tr->trace_buffer, &count);
+	ret = trace_test_buffer(&tr->array_buffer, &count);
 
 	ftrace_enabled = 1;
 	tracing_start();
@@ -682,7 +682,7 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
 	ftrace_enabled = 0;
 
 	/* check the trace buffer */
-	ret = trace_test_buffer(&tr->trace_buffer, &count);
+	ret = trace_test_buffer(&tr->array_buffer, &count);
 
 	ftrace_enabled = 1;
 	trace->reset(tr);
@@ -768,7 +768,7 @@ trace_selftest_startup_function_graph(struct tracer *trace,
 	 * Simulate the init() callback but we attach a watchdog callback
 	 * to detect and recover from possible hangs
 	 */
-	tracing_reset_online_cpus(&tr->trace_buffer);
+	tracing_reset_online_cpus(&tr->array_buffer);
 	set_graph_array(tr);
 	ret = register_ftrace_graph(&fgraph_ops);
 	if (ret) {
@@ -790,7 +790,7 @@ trace_selftest_startup_function_graph(struct tracer *trace,
 	tracing_stop();
 
 	/* check the trace buffer */
-	ret = trace_test_buffer(&tr->trace_buffer, &count);
+	ret = trace_test_buffer(&tr->array_buffer, &count);
 
 	/* Need to also simulate the tr->reset to remove this fgraph_ops */
 	tracing_stop_cmdline_record();
@@ -848,7 +848,7 @@ trace_selftest_startup_irqsoff(struct tracer *trace, struct trace_array *tr)
 	/* stop the tracing. */
 	tracing_stop();
 	/* check both trace buffers */
-	ret = trace_test_buffer(&tr->trace_buffer, NULL);
+	ret = trace_test_buffer(&tr->array_buffer, NULL);
 	if (!ret)
 		ret = trace_test_buffer(&tr->max_buffer, &count);
 	trace->reset(tr);
@@ -910,7 +910,7 @@ trace_selftest_startup_preemptoff(struct tracer *trace, struct trace_array *tr)
 	/* stop the tracing. */
 	tracing_stop();
 	/* check both trace buffers */
-	ret = trace_test_buffer(&tr->trace_buffer, NULL);
+	ret = trace_test_buffer(&tr->array_buffer, NULL);
 	if (!ret)
 		ret = trace_test_buffer(&tr->max_buffer, &count);
 	trace->reset(tr);
@@ -976,7 +976,7 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *
 	/* stop the tracing. */
 	tracing_stop();
 	/* check both trace buffers */
-	ret = trace_test_buffer(&tr->trace_buffer, NULL);
+	ret = trace_test_buffer(&tr->array_buffer, NULL);
 	if (ret)
 		goto out;
 
@@ -1006,7 +1006,7 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *
 	/* stop the tracing. */
 	tracing_stop();
 	/* check both trace buffers */
-	ret = trace_test_buffer(&tr->trace_buffer, NULL);
+	ret = trace_test_buffer(&tr->array_buffer, NULL);
 	if (ret)
 		goto out;
 
@@ -1136,7 +1136,7 @@ trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
 	/* stop the tracing. */
 	tracing_stop();
 	/* check both trace buffers */
-	ret = trace_test_buffer(&tr->trace_buffer, NULL);
+	ret = trace_test_buffer(&tr->array_buffer, NULL);
 	if (!ret)
 		ret = trace_test_buffer(&tr->max_buffer, &count);
 
@@ -1177,7 +1177,7 @@ trace_selftest_startup_branch(struct tracer *trace, struct trace_array *tr)
 	/* stop the tracing. */
 	tracing_stop();
 	/* check the trace buffer */
-	ret = trace_test_buffer(&tr->trace_buffer, &count);
+	ret = trace_test_buffer(&tr->array_buffer, &count);
 	trace->reset(tr);
 	tracing_start();
 
kernel/trace/trace_syscalls.c +2 -2
index 16fa218556fa..bd92843c2b0e 100644
@@ -345,7 +345,7 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
 	local_save_flags(irq_flags);
 	pc = preempt_count();
 
-	buffer = tr->trace_buffer.buffer;
+	buffer = tr->array_buffer.buffer;
 	event = trace_buffer_lock_reserve(buffer,
 			sys_data->enter_event->event.type, size, irq_flags, pc);
 	if (!event)
@@ -391,7 +391,7 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
 	local_save_flags(irq_flags);
 	pc = preempt_count();
 
-	buffer = tr->trace_buffer.buffer;
+	buffer = tr->array_buffer.buffer;
 	event = trace_buffer_lock_reserve(buffer,
 			sys_data->exit_event->event.type, sizeof(*entry),
 			irq_flags, pc);
Signature · 1 line
2.24.1
author maintainer
#3 lore raw

PATCH 3/26 tracing: Make struct ring_buffer less ambiguous

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

As there's two struct ring_buffers in the kernel, it causes some confusion. The other one being the perf ring buffer. It was agreed upon that as neither of the ring buffers are generic enough to be used globally, they should be renamed as:

perf's ring_buffer -> perf_buffer
ftrace's ring_buffer -> trace_buffer

This implements the changes to the ring buffer that ftrace uses.

---
 drivers/oprofile/cpu_buffer.c        |   2 +-
 include/linux/ring_buffer.h          | 110 ++++++++++++------------
 include/linux/trace_events.h         |   4 +-
 include/trace/trace_events.h         |   2 +-
 kernel/trace/blktrace.c              |   4 +-
 kernel/trace/ring_buffer.c           | 124 +++++++++++++--------------
 kernel/trace/ring_buffer_benchmark.c |   2 +-
 kernel/trace/trace.c                 |  70 +++++++--------
 kernel/trace/trace.h                 |  22 ++---
 kernel/trace/trace_branch.c          |   2 +-
 kernel/trace/trace_events.c          |   2 +-
 kernel/trace/trace_events_hist.c     |   2 +-
 kernel/trace/trace_functions_graph.c |   4 +-
 kernel/trace/trace_hwlat.c           |   2 +-
 kernel/trace/trace_kprobe.c          |   4 +-
 kernel/trace/trace_mmiotrace.c       |   4 +-
 kernel/trace/trace_sched_wakeup.c    |   4 +-
 kernel/trace/trace_syscalls.c        |   4 +-
 kernel/trace/trace_uprobe.c          |   2 +-
 19 files changed, 185 insertions(+), 185 deletions(-)
drivers/oprofile/cpu_buffer.c +1 -1
index eda2633a393d..9210a95cb4e6 100644
@@ -32,7 +32,7 @@
 
 #define OP_BUFFER_FLAGS	0
 
-static struct ring_buffer *op_ring_buffer;
+static struct trace_buffer *op_ring_buffer;
 DEFINE_PER_CPU(struct oprofile_cpu_buffer, op_cpu_buffer);
 
 static void wq_sync_buffer(struct work_struct *work);
include/linux/ring_buffer.h +55 -55

172 lines not on this page · raw message

include/linux/trace_events.h +2 -2
index f70e5bc7e8db..5f7b2b1fce24 100644
@@ -153,7 +153,7 @@ void tracing_generic_entry_update(struct trace_entry *entry,
 struct trace_event_file;
 
 struct ring_buffer_event *
-trace_event_buffer_lock_reserve(struct ring_buffer **current_buffer,
+trace_event_buffer_lock_reserve(struct trace_buffer **current_buffer,
 				struct trace_event_file *trace_file,
 				int type, unsigned long len,
 				unsigned long flags, int pc);
@@ -210,7 +210,7 @@ extern int trace_event_reg(struct trace_event_call *event,
 			    enum trace_reg type, void *data);
 
 struct trace_event_buffer {
-	struct ring_buffer		*buffer;
+	struct trace_buffer		*buffer;
 	struct ring_buffer_event	*event;
 	struct trace_event_file		*trace_file;
 	void				*entry;
include/trace/trace_events.h +1 -1
index 472b33d23a10..13a58d453992 100644
@@ -570,7 +570,7 @@ static inline notrace int trace_event_get_offsets_##call(		\
  *	enum event_trigger_type __tt = ETT_NONE;
  *	struct ring_buffer_event *event;
  *	struct trace_event_raw_<call> *entry; <-- defined in stage 1
- *	struct ring_buffer *buffer;
+ *	struct trace_buffer *buffer;
  *	unsigned long irq_flags;
  *	int __data_size;
  *	int pc;
kernel/trace/blktrace.c +2 -2
index 3b926f62ed83..0735ae8545d8 100644
@@ -68,7 +68,7 @@ static void trace_note(struct blk_trace *bt, pid_t pid, int action,
 {
 	struct blk_io_trace *t;
 	struct ring_buffer_event *event = NULL;
-	struct ring_buffer *buffer = NULL;
+	struct trace_buffer *buffer = NULL;
 	int pc = 0;
 	int cpu = smp_processor_id();
 	bool blk_tracer = blk_tracer_enabled;
@@ -215,7 +215,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
 {
 	struct task_struct *tsk = current;
 	struct ring_buffer_event *event = NULL;
-	struct ring_buffer *buffer = NULL;
+	struct trace_buffer *buffer = NULL;
 	struct blk_io_trace *t;
 	unsigned long flags = 0;
 	unsigned long *sequence;
kernel/trace/ring_buffer.c +62 -62

480 lines not on this page · raw message

kernel/trace/ring_buffer_benchmark.c +1 -1
index 32149e46551c..8df0aa810950 100644
@@ -29,7 +29,7 @@ static int reader_finish;
 static DECLARE_COMPLETION(read_start);
 static DECLARE_COMPLETION(read_done);
 
-static struct ring_buffer *buffer;
+static struct trace_buffer *buffer;
 static struct task_struct *producer;
 static struct task_struct *consumer;
 static unsigned long read;
kernel/trace/trace.c +35 -35

270 lines not on this page · raw message

kernel/trace/trace.h +11 -11
index fd679fe92c1f..4812a36affac 100644
@@ -178,7 +178,7 @@ struct trace_option_dentry;
 
 struct array_buffer {
 	struct trace_array		*tr;
-	struct ring_buffer		*buffer;
+	struct trace_buffer		*buffer;
 	struct trace_array_cpu __percpu	*data;
 	u64				time_start;
 	int				cpu;
@@ -705,7 +705,7 @@ struct dentry *tracing_init_dentry(void);
 struct ring_buffer_event;
 
 struct ring_buffer_event *
-trace_buffer_lock_reserve(struct ring_buffer *buffer,
+trace_buffer_lock_reserve(struct trace_buffer *buffer,
 			  int type,
 			  unsigned long len,
 			  unsigned long flags,
@@ -717,7 +717,7 @@ struct trace_entry *tracing_get_trace_entry(struct trace_array *tr,
 struct trace_entry *trace_find_next_entry(struct trace_iterator *iter,
 					  int *ent_cpu, u64 *ent_ts);
 
-void trace_buffer_unlock_commit_nostack(struct ring_buffer *buffer,
+void trace_buffer_unlock_commit_nostack(struct trace_buffer *buffer,
 					struct ring_buffer_event *event);
 
 int trace_empty(struct trace_iterator *iter);
@@ -873,7 +873,7 @@ trace_vprintk(unsigned long ip, const char *fmt, va_list args);
 extern int
 trace_array_vprintk(struct trace_array *tr,
 		    unsigned long ip, const char *fmt, va_list args);
-int trace_array_printk_buf(struct ring_buffer *buffer,
+int trace_array_printk_buf(struct trace_buffer *buffer,
 			   unsigned long ip, const char *fmt, ...);
 void trace_printk_seq(struct trace_seq *s);
 enum print_line_t print_trace_line(struct trace_iterator *iter);
@@ -1367,17 +1367,17 @@ struct trace_subsystem_dir {
 };
 
 extern int call_filter_check_discard(struct trace_event_call *call, void *rec,
-				     struct ring_buffer *buffer,
+				     struct trace_buffer *buffer,
 				     struct ring_buffer_event *event);
 
 void trace_buffer_unlock_commit_regs(struct trace_array *tr,
-				     struct ring_buffer *buffer,
+				     struct trace_buffer *buffer,
 				     struct ring_buffer_event *event,
 				     unsigned long flags, int pc,
 				     struct pt_regs *regs);
 
 static inline void trace_buffer_unlock_commit(struct trace_array *tr,
-					      struct ring_buffer *buffer,
+					      struct trace_buffer *buffer,
 					      struct ring_buffer_event *event,
 					      unsigned long flags, int pc)
 {
@@ -1390,7 +1390,7 @@ void trace_buffered_event_disable(void);
 void trace_buffered_event_enable(void);
 
 static inline void
-__trace_event_discard_commit(struct ring_buffer *buffer,
+__trace_event_discard_commit(struct trace_buffer *buffer,
 			     struct ring_buffer_event *event)
 {
 	if (this_cpu_read(trace_buffered_event) == event) {
@@ -1416,7 +1416,7 @@ __trace_event_discard_commit(struct ring_buffer *buffer,
  */
 static inline bool
 __event_trigger_test_discard(struct trace_event_file *file,
-			     struct ring_buffer *buffer,
+			     struct trace_buffer *buffer,
 			     struct ring_buffer_event *event,
 			     void *entry,
 			     enum event_trigger_type *tt)
@@ -1451,7 +1451,7 @@ __event_trigger_test_discard(struct trace_event_file *file,
  */
 static inline void
 event_trigger_unlock_commit(struct trace_event_file *file,
-			    struct ring_buffer *buffer,
+			    struct trace_buffer *buffer,
 			    struct ring_buffer_event *event,
 			    void *entry, unsigned long irq_flags, int pc)
 {
@@ -1482,7 +1482,7 @@ event_trigger_unlock_commit(struct trace_event_file *file,
  */
 static inline void
 event_trigger_unlock_commit_regs(struct trace_event_file *file,
-				 struct ring_buffer *buffer,
+				 struct trace_buffer *buffer,
 				 struct ring_buffer_event *event,
 				 void *entry, unsigned long irq_flags, int pc,
 				 struct pt_regs *regs)
kernel/trace/trace_branch.c +1 -1
index d5989284a99a..eff099123aa2 100644
@@ -32,10 +32,10 @@ probe_likely_condition(struct ftrace_likely_data *f, int val, int expect)
 {
 	struct trace_event_call *call = &event_branch;
 	struct trace_array *tr = branch_tracer;
+	struct trace_buffer *buffer;
 	struct trace_array_cpu *data;
 	struct ring_buffer_event *event;
 	struct trace_branch *entry;
-	struct ring_buffer *buffer;
 	unsigned long flags;
 	int pc;
 	const char *p;
kernel/trace/trace_events.c +1 -1
index ac557f685f0b..a16d1b601c5c 100644
@@ -3391,8 +3391,8 @@ static void __init
 function_test_events_call(unsigned long ip, unsigned long parent_ip,
 			  struct ftrace_ops *op, struct pt_regs *pt_regs)
 {
+	struct trace_buffer *buffer;
 	struct ring_buffer_event *event;
-	struct ring_buffer *buffer;
 	struct ftrace_entry *entry;
 	unsigned long flags;
 	long disabled;
kernel/trace/trace_events_hist.c +1 -1
index 94c581c1a897..0454abaeb486 100644
@@ -879,7 +879,7 @@ static notrace void trace_event_raw_event_synth(void *__data,
 	struct trace_event_file *trace_file = __data;
 	struct synth_trace_event *entry;
 	struct trace_event_buffer fbuffer;
-	struct ring_buffer *buffer;
+	struct trace_buffer *buffer;
 	struct synth_event *event;
 	unsigned int i, n_u64;
 	int fields_size = 0;
kernel/trace/trace_functions_graph.c +2 -2
index 79b2c2df00c5..7d71546ba00a 100644
@@ -101,7 +101,7 @@ int __trace_graph_entry(struct trace_array *tr,
 {
 	struct trace_event_call *call = &event_funcgraph_entry;
 	struct ring_buffer_event *event;
-	struct ring_buffer *buffer = tr->array_buffer.buffer;
+	struct trace_buffer *buffer = tr->array_buffer.buffer;
 	struct ftrace_graph_ent_entry *entry;
 
 	event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_ENT,
@@ -221,7 +221,7 @@ void __trace_graph_return(struct trace_array *tr,
 {
 	struct trace_event_call *call = &event_funcgraph_exit;
 	struct ring_buffer_event *event;
-	struct ring_buffer *buffer = tr->array_buffer.buffer;
+	struct trace_buffer *buffer = tr->array_buffer.buffer;
 	struct ftrace_graph_ret_entry *entry;
 
 	event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_RET,
kernel/trace/trace_hwlat.c +1 -1
index fc62a6049bd3..b44446bf0872 100644
@@ -104,7 +104,7 @@ static void trace_hwlat_sample(struct hwlat_sample *sample)
 {
 	struct trace_array *tr = hwlat_trace;
 	struct trace_event_call *call = &event_hwlat;
-	struct ring_buffer *buffer = tr->array_buffer.buffer;
+	struct trace_buffer *buffer = tr->array_buffer.buffer;
 	struct ring_buffer_event *event;
 	struct hwlat_entry *entry;
 	unsigned long flags;
kernel/trace/trace_kprobe.c +2 -2
index 7f890262c8a3..477b6b011e7d 100644
@@ -1175,8 +1175,8 @@ __kprobe_trace_func(struct trace_kprobe *tk, struct pt_regs *regs,
 		    struct trace_event_file *trace_file)
 {
 	struct kprobe_trace_entry_head *entry;
+	struct trace_buffer *buffer;
 	struct ring_buffer_event *event;
-	struct ring_buffer *buffer;
 	int size, dsize, pc;
 	unsigned long irq_flags;
 	struct trace_event_call *call = trace_probe_event_call(&tk->tp);
@@ -1223,8 +1223,8 @@ __kretprobe_trace_func(struct trace_kprobe *tk, struct kretprobe_instance *ri,
 		       struct trace_event_file *trace_file)
 {
 	struct kretprobe_trace_entry_head *entry;
+	struct trace_buffer *buffer;
 	struct ring_buffer_event *event;
-	struct ring_buffer *buffer;
 	int size, pc, dsize;
 	unsigned long irq_flags;
 	struct trace_event_call *call = trace_probe_event_call(&tk->tp);
kernel/trace/trace_mmiotrace.c +2 -2
index c30137148759..84582bf1ed5f 100644
@@ -297,7 +297,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
 				struct mmiotrace_rw *rw)
 {
 	struct trace_event_call *call = &event_mmiotrace_rw;
-	struct ring_buffer *buffer = tr->array_buffer.buffer;
+	struct trace_buffer *buffer = tr->array_buffer.buffer;
 	struct ring_buffer_event *event;
 	struct trace_mmiotrace_rw *entry;
 	int pc = preempt_count();
@@ -327,7 +327,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
 				struct mmiotrace_map *map)
 {
 	struct trace_event_call *call = &event_mmiotrace_map;
-	struct ring_buffer *buffer = tr->array_buffer.buffer;
+	struct trace_buffer *buffer = tr->array_buffer.buffer;
 	struct ring_buffer_event *event;
 	struct trace_mmiotrace_map *entry;
 	int pc = preempt_count();
kernel/trace/trace_sched_wakeup.c +2 -2
index 510fda2fcd24..97b10bb31a1f 100644
@@ -378,7 +378,7 @@ tracing_sched_switch_trace(struct trace_array *tr,
 			   unsigned long flags, int pc)
 {
 	struct trace_event_call *call = &event_context_switch;
-	struct ring_buffer *buffer = tr->array_buffer.buffer;
+	struct trace_buffer *buffer = tr->array_buffer.buffer;
 	struct ring_buffer_event *event;
 	struct ctx_switch_entry *entry;
 
@@ -408,7 +408,7 @@ tracing_sched_wakeup_trace(struct trace_array *tr,
 	struct trace_event_call *call = &event_wakeup;
 	struct ring_buffer_event *event;
 	struct ctx_switch_entry *entry;
-	struct ring_buffer *buffer = tr->array_buffer.buffer;
+	struct trace_buffer *buffer = tr->array_buffer.buffer;
 
 	event = trace_buffer_lock_reserve(buffer, TRACE_WAKE,
 					  sizeof(*entry), flags, pc);
kernel/trace/trace_syscalls.c +2 -2
index bd92843c2b0e..837ad4818bb4 100644
@@ -317,7 +317,7 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
 	struct syscall_trace_enter *entry;
 	struct syscall_metadata *sys_data;
 	struct ring_buffer_event *event;
-	struct ring_buffer *buffer;
+	struct trace_buffer *buffer;
 	unsigned long irq_flags;
 	unsigned long args[6];
 	int pc;
@@ -367,7 +367,7 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
 	struct syscall_trace_exit *entry;
 	struct syscall_metadata *sys_data;
 	struct ring_buffer_event *event;
-	struct ring_buffer *buffer;
+	struct trace_buffer *buffer;
 	unsigned long irq_flags;
 	int pc;
 	int syscall_nr;
kernel/trace/trace_uprobe.c +1 -1
index 352073d36585..6c75d94f5c2f 100644
@@ -938,8 +938,8 @@ static void __uprobe_trace_func(struct trace_uprobe *tu,
 				struct trace_event_file *trace_file)
 {
 	struct uprobe_trace_entry_head *entry;
+	struct trace_buffer *buffer;
 	struct ring_buffer_event *event;
-	struct ring_buffer *buffer;
 	void *data;
 	int size, esize;
 	struct trace_event_call *call = trace_probe_event_call(&tu->tp);
Signature · 1 line
2.24.1
author maintainer
#4 lore raw

PATCH 4/26 bootconfig: Add Extra Boot Config support

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Extra Boot Config (XBC) allows admin to pass a tree-structured boot configuration file when boot up the kernel. This extends the kernel command line in an efficient way.

Boot config will contain some key-value commands, e.g.

key.word = value1
another.key.word = value2

It can fold same keys with braces, also you can write array data. For example,

key {
word1 {
setting1 = data
setting2
}
word2.array = "val1", "val2"
}

User can access these key-value pair and tree structure via SKC APIs.

---
 MAINTAINERS                |   6 +
 include/linux/bootconfig.h | 224 +++++++++++
 init/Kconfig               |  11 +
 lib/Kconfig                |   3 +
 lib/Makefile               |   2 +
 lib/bootconfig.c           | 803 +++++++++++++++++++++++++++++++++++++
 6 files changed, 1049 insertions(+)
 create mode 100644 include/linux/bootconfig.h
 create mode 100644 lib/bootconfig.c
MAINTAINERS +6 -0
index 4017e6b760be..8597285eb7c8 100644
@@ -15770,6 +15770,12 @@ W:	http://www.stlinux.com
 S:	Supported
 F:	drivers/net/ethernet/stmicro/stmmac/
 
+EXTRA BOOT CONFIG
+M:	Masami Hiramatsu <[email protected]>
+S:	Maintained
+F:	lib/bootconfig.c
+F:	include/linux/bootconfig.h
+
 SUN3/3X
 M:	Sam Creasey <[email protected]>
 W:	http://sammy.net/sun3/
include/linux/bootconfig.h new file +224 -0

224 lines not on this page · raw message

init/Kconfig +11 -0
index a34064a031a5..63450d3bbf12 100644
@@ -1215,6 +1215,17 @@ source "usr/Kconfig"
 
 endif
 
+config BOOT_CONFIG
+	bool "Boot config support"
+	select LIBXBC
+	default y
+	help
+	  Extra boot config allows system admin to pass a config file as
+	  complemental extension of kernel cmdline when booting.
+	  The boot config file is usually attached at the end of initramfs.
+
+	  If unsure, say Y.
+
 choice
 	prompt "Compiler optimization level"
 	default CC_OPTIMIZE_FOR_PERFORMANCE
lib/Kconfig +3 -0
index 6e790dc55c5b..10012b646009 100644
@@ -566,6 +566,9 @@ config DIMLIB
 config LIBFDT
 	bool
 
+config LIBXBC
+	bool
+
 config OID_REGISTRY
 	tristate
 	help
lib/Makefile +2 -0
index 93217d44237f..75a64d2552a2 100644
@@ -228,6 +228,8 @@ $(foreach file, $(libfdt_files), \
 	$(eval CFLAGS_$(file) = -I $(srctree)/scripts/dtc/libfdt))
 lib-$(CONFIG_LIBFDT) += $(libfdt_files)
 
+lib-$(CONFIG_LIBXBC) += bootconfig.o
+
 obj-$(CONFIG_RBTREE_TEST) += rbtree_test.o
 obj-$(CONFIG_INTERVAL_TREE_TEST) += interval_tree_test.o
 
lib/bootconfig.c new file +803 -0

803 lines not on this page · raw message

Signature · 1 line
2.24.1
#5 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

init/Kconfig source "usr/Kconfig" · line 1221

Quoted 12 lines · Steven Rostedt
init/Kconfig +4 -0
index a34064a031a5..63450d3bbf12 100644
@@ -1215,6 +1215,17 @@ source "usr/Kconfig"
 
 endif
 
+config BOOT_CONFIG
+	bool "Boot config support"
+	select LIBXBC
+	default y

Any particular reason this is default y? Why should it be enabled by default on all boxes?

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#6 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Hi,

Quoted 9 lines · On Thu, 6 Feb 2020 12:54:05 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 8 lines · Steven Rostedt
init/Kconfig +0 -0
index a34064a031a5..63450d3bbf12 100644
@@ -1215,6 +1215,17 @@ source "usr/Kconfig"
 
 endif
 
Quoted 7 lines

init/Kconfig source "usr/Kconfig" · line 1221

Quoted 4 lines
init/Kconfig +4 -0
+config BOOT_CONFIG
+	bool "Boot config support"
+	select LIBXBC
+	default y

Any particular reason this is default y? Why should it be enabled by default on all boxes?

Oh, you are not the first person asked that :)

https://lkml.org/lkml/2019/12/9/563

And yes, I think this is important that will useful for most developers and admins. Since the bootconfig already covers kernel and init options, this can be a new standard way to pass args to kernel boot.

And as I reported above thread, the memory footpoint of view, most code and working memory are released after boot. Also, as Linus's suggested, now this feature is enabled only if user gives "bootconfig" on the kernel command line. So the side effect is minimized.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
#7 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Hi Hiramatsu-san,

Quoted 23 lines · Masami Hiramatsu
Quoted 9 lines · On Thu, 6 Feb 2020 12:54:05 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 8 lines · Steven Rostedt
init/Kconfig +0 -0
index a34064a031a5..63450d3bbf12 100644
@@ -1215,6 +1215,17 @@ source "usr/Kconfig"
 
 endif
 
Quoted 7 lines

init/Kconfig source "usr/Kconfig" · line 1221

Quoted 4 lines
init/Kconfig +4 -0
+config BOOT_CONFIG
+   bool "Boot config support"
+   select LIBXBC
+   default y

Any particular reason this is default y? Why should it be enabled by default on all boxes?

Oh, you are not the first person asked that :)

https://lkml.org/lkml/2019/12/9/563

Quoted 8 lines

And yes, I think this is important that will useful for most developers and admins. Since the bootconfig already covers kernel and init options, this can be a new standard way to pass args to kernel boot.

And as I reported above thread, the memory footpoint of view, most code and working memory are released after boot. Also, as Linus's suggested, now this feature is enabled only if user gives "bootconfig" on the kernel command line. So the side effect is minimized.

With m68k/atari_defconfig, bloat-o-meter says:

    add/remove: 39/0 grow/shrink: 2/0 up/down: 13086/0 (13086)

which is IMHO not that small for a "default y" option that may or may not be used.

Especially:

Function old new delta
xbc_nodes - 8192 +8192

Any chance xbc_nodes can be allocated dynamically, and only when needed?

Yes, there are industrial products running Linux on a current ARM SoC using the builtin 8 or 10 MiB of SRAM (+ XIP for the kernel), so these definitely want to say CONFIG_BOOT_CONFIG=n.

Thanks!

add/remove: 39/0 grow/shrink: 2/0 up/down: 13086/0 (13086)
Function old new delta
xbc_nodes - 8192 +8192

xbc_init                                       -     854    +854
start_kernel                                1020    1580    +560
copy_xbc_key_value_list                        -     362    +362
__xbc_parse_value                              -     324    +324
xbc_snprint_cmdline                            -     294    +294
xbc_node_compose_key_after                     -     266    +266
xbc_namebuf                                    -     256    +256
xbc_add_sibling                                -     254    +254
xbc_node_find_next_leaf                        -     186    +186
xbc_node_find_child                            -     176    +176
__xbc_add_key                                  -     162    +162
proc_boot_config_init                          -     124    +124
xbc_make_cmdline                               -     122    +122
xbc_node_find_value                            -     104    +104
xbc_node_find_next_key_value                   -     102    +102
__xbc_close_brace                              -      92     +92
find_match_node                                -      80     +80
__xbc_parse_keys                               -      78     +78
xbc_node_get_data                              -      64     +64
xbc_parse_key                                  -      60     +60
skip_comment                                   -      48     +48
xbc_destroy_all                                -      42     +42
xbc_node_get_parent                            -      38     +38
xbc_parse_error                                -      36     +36
xbc_node_get_child                             -      34     +34
xbc_node_get_next                              -      32     +32
boot_config_checksum                           -      30     +30
boot_config_proc_show                          -      26     +26
xbc_root_node                                  -      20     +20
kzalloc.constprop                            810     830     +20
xbc_node_index                                 -      14     +14
xbc_node_num                                   -       4      +4
xbc_data_size                                  -       4      +4
xbc_data                                       -       4      +4
saved_boot_config                              -       4      +4
last_parent                                    -       4      +4
extra_init_args                                -       4      +4
extra_command_line                             -       4      +4
__initcall_proc_boot_config_init5              -       4      +4
xbc_debug_dump                                 -       2      +2

Total: Before=3688860, After=3701946, chg +0.35%

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer
#8 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 42 lines · On Thu, 6 Feb 2020 18:20:15 +0100 Geert Uytterhoeven <[email protected]>…

Hi Hiramatsu-san,

Quoted 23 lines · Masami Hiramatsu
Quoted 9 lines · On Thu, 6 Feb 2020 12:54:05 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 8 lines · Steven Rostedt
init/Kconfig +0 -0
index a34064a031a5..63450d3bbf12 100644
@@ -1215,6 +1215,17 @@ source "usr/Kconfig"
 
 endif
 
Quoted 7 lines

init/Kconfig source "usr/Kconfig" · line 1221

Quoted 4 lines
init/Kconfig +4 -0
+config BOOT_CONFIG
+   bool "Boot config support"
+   select LIBXBC
+   default y

Any particular reason this is default y? Why should it be enabled by default on all boxes?

Oh, you are not the first person asked that :)

https://lkml.org/lkml/2019/12/9/563

Quoted 8 lines

And yes, I think this is important that will useful for most developers and admins. Since the bootconfig already covers kernel and init options, this can be a new standard way to pass args to kernel boot.

And as I reported above thread, the memory footpoint of view, most code and working memory are released after boot. Also, as Linus's suggested, now this feature is enabled only if user gives "bootconfig" on the kernel command line. So the side effect is minimized.

With m68k/atari_defconfig, bloat-o-meter says:

    add/remove: 39/0 grow/shrink: 2/0 up/down: 13086/0 (13086)

which is IMHO not that small for a "default y" option that may or may not be used.

Quoted 6 lines

Especially:

Function old new delta
xbc_nodes - 8192 +8192

Any chance xbc_nodes can be allocated dynamically, and only when needed?

Yes, I think we can use memblock to allocate it. However, this xbc_nodes is __init_data, which is released right after boot. So I think it should be OK except for your system doesn't have user space...

Quoted 3 lines

Yes, there are industrial products running Linux on a current ARM SoC using the builtin 8 or 10 MiB of SRAM (+ XIP for the kernel), so these definitely want to say CONFIG_BOOT_CONFIG=n.

I think for such products the kernel must be tuned with custom config, and you can say CONFIG_BOOT_CONFIG=n. That is a configurable feature.

Thank you,

Quoted 58 lines

Thanks!

add/remove: 39/0 grow/shrink: 2/0 up/down: 13086/0 (13086)
Function old new delta
xbc_nodes - 8192 +8192

xbc_init                                       -     854    +854
start_kernel                                1020    1580    +560
copy_xbc_key_value_list                        -     362    +362
__xbc_parse_value                              -     324    +324
xbc_snprint_cmdline                            -     294    +294
xbc_node_compose_key_after                     -     266    +266
xbc_namebuf                                    -     256    +256
xbc_add_sibling                                -     254    +254
xbc_node_find_next_leaf                        -     186    +186
xbc_node_find_child                            -     176    +176
__xbc_add_key                                  -     162    +162
proc_boot_config_init                          -     124    +124
xbc_make_cmdline                               -     122    +122
xbc_node_find_value                            -     104    +104
xbc_node_find_next_key_value                   -     102    +102
__xbc_close_brace                              -      92     +92
find_match_node                                -      80     +80
__xbc_parse_keys                               -      78     +78
xbc_node_get_data                              -      64     +64
xbc_parse_key                                  -      60     +60
skip_comment                                   -      48     +48
xbc_destroy_all                                -      42     +42
xbc_node_get_parent                            -      38     +38
xbc_parse_error                                -      36     +36
xbc_node_get_child                             -      34     +34
xbc_node_get_next                              -      32     +32
boot_config_checksum                           -      30     +30
boot_config_proc_show                          -      26     +26
xbc_root_node                                  -      20     +20
kzalloc.constprop                            810     830     +20
xbc_node_index                                 -      14     +14
xbc_node_num                                   -       4      +4
xbc_data_size                                  -       4      +4
xbc_data                                       -       4      +4
saved_boot_config                              -       4      +4
last_parent                                    -       4      +4
extra_init_args                                -       4      +4
extra_command_line                             -       4      +4
__initcall_proc_boot_config_init5              -       4      +4
xbc_debug_dump                                 -       2      +2

Total: Before=3688860, After=3701946, chg +0.35%

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Signature · 1 line
Masami Hiramatsu <[email protected]>
#9 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Hi Hiramatsu-san,

Quoted 42 lines · Masami Hiramatsu
Quoted 40 lines · On Thu, 6 Feb 2020 18:20:15 +0100 Geert Uytterhoeven <[email protected]>…
Quoted 23 lines · Masami Hiramatsu
Quoted 9 lines · On Thu, 6 Feb 2020 12:54:05 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 8 lines · Steven Rostedt
init/Kconfig +0 -0
index a34064a031a5..63450d3bbf12 100644
@@ -1215,6 +1215,17 @@ source "usr/Kconfig"
 
 endif
 
Quoted 7 lines

init/Kconfig source "usr/Kconfig" · line 1221

Quoted 4 lines
init/Kconfig +4 -0
+config BOOT_CONFIG
+   bool "Boot config support"
+   select LIBXBC
+   default y

Any particular reason this is default y? Why should it be enabled by default on all boxes?

Oh, you are not the first person asked that :)

https://lkml.org/lkml/2019/12/9/563

Quoted 8 lines

And yes, I think this is important that will useful for most developers and admins. Since the bootconfig already covers kernel and init options, this can be a new standard way to pass args to kernel boot.

And as I reported above thread, the memory footpoint of view, most code and working memory are released after boot. Also, as Linus's suggested, now this feature is enabled only if user gives "bootconfig" on the kernel command line. So the side effect is minimized.

With m68k/atari_defconfig, bloat-o-meter says:

    add/remove: 39/0 grow/shrink: 2/0 up/down: 13086/0 (13086)

which is IMHO not that small for a "default y" option that may or may not be used.

Quoted 8 lines
Quoted 6 lines

Especially:

Function old new delta
xbc_nodes - 8192 +8192

Any chance xbc_nodes can be allocated dynamically, and only when needed?

Yes, I think we can use memblock to allocate it. However, this xbc_nodes is

Good.

Quoted 2 lines

__init_data, which is released right after boot. So I think it should be OK except for your system doesn't have user space...

__initdata is still part of the kernel image (note that we no longer have __initbss) and consumes RAM early on, and is thus subject to e.g. bootloader[1] and platform limitations (e.g. the kernel must fit in the first block of physical memory).
So trying to avoid large static arrays is useful.

Quoted 6 lines
Quoted 3 lines

Yes, there are industrial products running Linux on a current ARM SoC using the builtin 8 or 10 MiB of SRAM (+ XIP for the kernel), so these definitely want to say CONFIG_BOOT_CONFIG=n.

I think for such products the kernel must be tuned with custom config, and you can say CONFIG_BOOT_CONFIG=n. That is a configurable feature.

I do not dispute that.

[1] Re: [PATCH] dma-debug: dynamic allocation of hash table
https://lore.kernel.org/lkml/CAMuHMdVSyD62nvRmN-v6CbJ2UyqH=d7xdVeCD8_X5us+mvCXUQ@mail.gmail.com/

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer
#10 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Hi Geert,

Quoted 56 lines · On Fri, 7 Feb 2020 09:49:02 +0100 Geert Uytterhoeven <[email protected]>…

Hi Hiramatsu-san,

Quoted 42 lines · Masami Hiramatsu
Quoted 40 lines · On Thu, 6 Feb 2020 18:20:15 +0100 Geert Uytterhoeven <[email protected]>…
Quoted 23 lines · Masami Hiramatsu
Quoted 9 lines · On Thu, 6 Feb 2020 12:54:05 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 8 lines · Steven Rostedt
init/Kconfig +0 -0
index a34064a031a5..63450d3bbf12 100644
@@ -1215,6 +1215,17 @@ source "usr/Kconfig"
 
 endif
 
Quoted 7 lines

init/Kconfig source "usr/Kconfig" · line 1221

Quoted 4 lines
init/Kconfig +4 -0
+config BOOT_CONFIG
+   bool "Boot config support"
+   select LIBXBC
+   default y

Any particular reason this is default y? Why should it be enabled by default on all boxes?

Oh, you are not the first person asked that :)

https://lkml.org/lkml/2019/12/9/563

Quoted 8 lines

And yes, I think this is important that will useful for most developers and admins. Since the bootconfig already covers kernel and init options, this can be a new standard way to pass args to kernel boot.

And as I reported above thread, the memory footpoint of view, most code and working memory are released after boot. Also, as Linus's suggested, now this feature is enabled only if user gives "bootconfig" on the kernel command line. So the side effect is minimized.

With m68k/atari_defconfig, bloat-o-meter says:

    add/remove: 39/0 grow/shrink: 2/0 up/down: 13086/0 (13086)

which is IMHO not that small for a "default y" option that may or may not be used.

Quoted 8 lines
Quoted 6 lines

Especially:

Function old new delta
xbc_nodes - 8192 +8192

Any chance xbc_nodes can be allocated dynamically, and only when needed?

Yes, I think we can use memblock to allocate it. However, this xbc_nodes is

Good.

Quoted 8 lines
Quoted 2 lines

__init_data, which is released right after boot. So I think it should be OK except for your system doesn't have user space...

__initdata is still part of the kernel image (note that we no longer have __initbss) and consumes RAM early on, and is thus subject to e.g. bootloader[1] and platform limitations (e.g. the kernel must fit in the first block of physical memory).
So trying to avoid large static arrays is useful.

OK, I'll replace it with memblock. Then it will be 5 - 6KB in total.

Thank you!

Signature · 1 line
Masami Hiramatsu <[email protected]>
maintainer
#11 lore raw

PATCH 1/1 bootconfig: Allocate xbc_nodes array dynamically

To reduce the large static array from kernel data, allocate xbc_nodes array dynamically only if the kernel loads a bootconfig.

Note that this also add dummy memblock.h for user-spacae bootconfig tool.

---
 lib/bootconfig.c                          |   15 ++++++++++++---
 tools/bootconfig/include/linux/memblock.h |   12 ++++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 tools/bootconfig/include/linux/memblock.h
lib/bootconfig.c +12 -3
index afb2e767e6fe..3ea601a2eba5 100644
@@ -6,12 +6,13 @@
 
 #define pr_fmt(fmt)    "bootconfig: " fmt
 
+#include <linux/bootconfig.h>
 #include <linux/bug.h>
 #include <linux/ctype.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
+#include <linux/memblock.h>
 #include <linux/printk.h>
-#include <linux/bootconfig.h>
 #include <linux/string.h>
 
 /*
@@ -23,7 +24,7 @@
  * node (for array).
  */
 
-static struct xbc_node xbc_nodes[XBC_NODE_MAX] __initdata;
+static struct xbc_node *xbc_nodes __initdata;
 static int xbc_node_num __initdata;
 static char *xbc_data __initdata;
 static size_t xbc_data_size __initdata;
@@ -719,7 +720,8 @@ void __init xbc_destroy_all(void)
 	xbc_data = NULL;
 	xbc_data_size = 0;
 	xbc_node_num = 0;
-	memset(xbc_nodes, 0, sizeof(xbc_nodes));
+	memblock_free(__pa(xbc_nodes), sizeof(struct xbc_node) * XBC_NODE_MAX);
+	xbc_nodes = NULL;
 }
 
 /**
@@ -748,6 +750,13 @@ int __init xbc_init(char *buf)
 		return -ERANGE;
 	}
 
+	xbc_nodes = memblock_alloc(sizeof(struct xbc_node) * XBC_NODE_MAX,
+				   SMP_CACHE_BYTES);
+	if (!xbc_nodes) {
+		pr_err("Failed to allocate memory for bootconfig nodes.\n");
+		return -ENOMEM;
+	}
+	memset(xbc_nodes, 0, sizeof(struct xbc_node) * XBC_NODE_MAX);
 	xbc_data = buf;
 	xbc_data_size = ret + 1;
 	last_parent = NULL;
tools/bootconfig/include/linux/memblock.h new file +12 -0
new file mode 100644
index 000000000000..7862f217d85d
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _XBC_LINUX_MEMBLOCK_H
+#define _XBC_LINUX_MEMBLOCK_H
+
+#include <stdlib.h>
+
+#define __pa(addr)	(addr)
+#define SMP_CACHE_BYTES	0
+#define memblock_alloc(size, align)	malloc(size)
+#define memblock_free(paddr, size)	free(paddr)
+
+#endif
#12 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

In reply to Masami Hiramatsu
Quoted 7 lines · Masami Hiramatsu

Oh, you are not the first person asked that :)

https://lkml.org/lkml/2019/12/9/563

And yes, I think this is important that will useful for most developers and admins. Since the bootconfig already covers kernel and init options, this can be a new standard way to pass args to kernel boot.

Aha, so Steve and you believe this will become the next great thing after sliced bread. Sorry but I remain sceptical. :)

I would've done it differently: have it default 'n' and once it turns out that the major distros have enabled it and *actually* use it, *then* simply remove the config option. Like we usually do with functionality. Not the other way around.

In any case, I've disabled it on my machines and will wait for it missing to come back and bite me. :-P

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
reviewer
#13 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 2 lines · Borislav Petkov
Quoted 1 line · Masami Hiramatsu

Oh, you are not the first person asked that :)

(that would be me AFAIK)

Quoted 9 lines
Quoted 6 lines

https://lkml.org/lkml/2019/12/9/563

And yes, I think this is important that will useful for most developers and admins. Since the bootconfig already covers kernel and init options, this can be a new standard way to pass args to kernel boot.

Aha, so Steve and you believe this will become the next great thing after sliced bread. Sorry but I remain sceptical. :)

old news: some Kconfig symbols are Special & Important. ;)

I agree with you (as I also disagreed with "default y").

Quoted 7 lines

I would've done it differently: have it default 'n' and once it turns out that the major distros have enabled it and *actually* use it, *then* simply remove the config option. Like we usually do with functionality. Not the other way around.

In any case, I've disabled it on my machines and will wait for it missing to come back and bite me. :-P

Signature · 1 line
~Randy
author maintainer
#14 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 1 line · On Thu, 6 Feb 2020 10:10:28 -0800 Randy Dunlap <[email protected]> wrote:

old news: some Kconfig symbols are Special & Important. ;)

Well, to me its as important as the kernel command line itself, and printk(). I know printk() can be disabled, should that be default 'n'?

What I really like about this, is that you can have custom kernel configs for each initrd. My fear is if this is default off, an initrd that use to boot may no longer boot, because of a forgotten enabling of this.

-- Steve

#15 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 2 lines · Steven Rostedt

Well, to me its as important as the kernel command line itself, and printk(). I know printk() can be disabled, should that be default 'n'?

You're arguing for a feature which might potentially become ubiquitous. I don't think anyone minds it being built-in and even without a config option when that happens. Just until that happens, it should have been default n like all the other features we come up with and then enable everywhere after sufficient amount of time of testing and reporting/fixing bugs. Then even the config item gets removed. We do it this way all the time.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#16 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

In reply to Steven Rostedt

Hi Steven,

Quoted 9 lines · Steven Rostedt
Quoted 1 line · On Thu, 6 Feb 2020 10:10:28 -0800 Randy Dunlap <[email protected]> wrote:

old news: some Kconfig symbols are Special & Important. ;)

Well, to me its as important as the kernel command line itself, and printk(). I know printk() can be disabled, should that be default 'n'?

What I really like about this, is that you can have custom kernel configs for each initrd. My fear is if this is default off, an initrd

s/configs/command lines/?

Quoted 2 lines

that use to boot may no longer boot, because of a forgotten enabling of this.

I may be missing something here, but 12 KiB for extra command line support sounds a bit excessive to me.
Currently the maximum value of COMMAND_LINE_SIZE is 4096, while many architectures still use 256 or 512.
How much data do you want to pass?
What kind of configuration do you want to pass?
Is there some existing data structure you can use to hold this?

Thanks!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer
#17 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

In reply to Borislav Petkov

Hi,

Quoted 11 lines · On Thu, 6 Feb 2020 18:58:58 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 7 lines · Masami Hiramatsu

Oh, you are not the first person asked that :)

https://lkml.org/lkml/2019/12/9/563

And yes, I think this is important that will useful for most developers and admins. Since the bootconfig already covers kernel and init options, this can be a new standard way to pass args to kernel boot.

Aha, so Steve and you believe this will become the next great thing after sliced bread. Sorry but I remain sceptical. :)

It could change some other things. I recommend developers to use this feature to configure their subsystem easier and admins to configure kernel boot options more readable way.

Quoted 4 lines

I would've done it differently: have it default 'n' and once it turns out that the major distros have enabled it and *actually* use it, *then* simply remove the config option. Like we usually do with functionality. Not the other way around.

Many distros may not use it unless it is default y. I couldn't find any good example that the feature "default n" turns into "default y". Would you have any example?

Quoted 2 lines

In any case, I've disabled it on my machines and will wait for it missing to come back and bite me. :-P

Hmm, what would you afraid of? It is just a small footprint additional feature which never be enabled without "bootconfig" on the kernel cmdline...

Thank you,

Quoted 6 lines
Signature · 5 lines
-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
Signature · 1 line
Masami Hiramatsu <[email protected]>
#18 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 3 lines · Masami Hiramatsu

It could change some other things. I recommend developers to use this feature to configure their subsystem easier and admins to configure kernel boot options more readable way.

Well, I could use an actual justification for why I would need it. Because, frankly, I haven't sat down and thought: "hmm, this boot command line supplement thing is awful and I need a better one." IOW, it has never bothered me so far. But I'm always open to improvements as long as they don't make it worse. :)

Quoted 3 lines

Many distros may not use it unless it is default y. I couldn't find any good example that the feature "default n" turns into "default y". Would you have any example?

We - SUSE - always reevaluate our configs for the next service pack and enable things which make sense and customers use. So all the new drivers get enabled, kernel infra which makes sense too, etc.

If the bootconfig thing proves useful, I will glady enable it in our tree.

Quoted 2 lines

Hmm, what would you afraid of? It is just a small footprint additional feature which never be enabled without "bootconfig" on the kernel cmdline...

Not afraid - I don't know why I need it. Everything I don't need => off. But again, if there's a good use case, I will enable it. The usual feature evaluation thing we all do.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#19 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 10 lines · On Fri, 7 Feb 2020 12:41:22 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 3 lines · Masami Hiramatsu

It could change some other things. I recommend developers to use this feature to configure their subsystem easier and admins to configure kernel boot options more readable way.

Well, I could use an actual justification for why I would need it. Because, frankly, I haven't sat down and thought: "hmm, this boot command line supplement thing is awful and I need a better one." IOW, it has never bothered me so far. But I'm always open to improvements as long as they don't make it worse. :)

OK, could you tell me your idea to make it better? I'm waiting for such discussion a half of last year :)

For your information, here is the background of this bootconfig. To build my boot-time tracing, I need a way to pass a flexible and structured configuration at boot time.
I had tried to reuse devicetree at first, but it was rejected because the devicetree is only for describing hardware. So I introduced this bootconfig.
When I designed the bootconfig, I tried to sort out the requirements. That config should be able to pass all setting we can do on tracefs. Since ftrace already has a parser for tracefs, we don't need any types for each settings. Thus it should be something like sysctl.conf. But the sysctl.conf was too simple, it couldn't handle several related keys well. So I decided to introduce braces which put together some related parameters. And the bootconfig syntax was born.

I see that current piggyback method might look a bit odd. My first implementation was bootloader based method (I implemented it on grub and qemu), but that was not useful, especially it required user to replace their bootloader...

Quoted 10 lines
Quoted 3 lines

Many distros may not use it unless it is default y. I couldn't find any good example that the feature "default n" turns into "default y". Would you have any example?

We - SUSE - always reevaluate our configs for the next service pack and enable things which make sense and customers use. So all the new drivers get enabled, kernel infra which makes sense too, etc.

If the bootconfig thing proves useful, I will glady enable it in our tree.

Okay, I hope it and try to prove it. Anyway, to use boot-time tracing which can fully utilize ftrace at boot-time, we have to enable bootconfig.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
#20 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 2 lines · Masami Hiramatsu

OK, could you tell me your idea to make it better? I'm waiting for such discussion a half of last year :)

Yah, situation sounds familiar. :)

Quoted 3 lines

For your information, here is the background of this bootconfig. To build my boot-time tracing, I need a way to pass a flexible and structured configuration at boot time.

Can I see an actual example of what you're doing?

Quoted 3 lines

I had tried to reuse devicetree at first, but it was rejected because the devicetree is only for describing hardware. So I introduced this bootconfig.

Makes sense.

Quoted 7 lines

When I designed the bootconfig, I tried to sort out the requirements. That config should be able to pass all setting we can do on tracefs. Since ftrace already has a parser for tracefs, we don't need any types for each settings. Thus it should be something like sysctl.conf. But the sysctl.conf was too simple, it couldn't handle several related keys well. So I decided to introduce braces which put together some related parameters. And the bootconfig syntax was born.

Ok, here's my boot command line:

[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.5.0-rc7+ root=/dev/nvme0n1p2 ro root=/dev/disk/by-id/nvme-eui.0025385481b2fe2a-part2 resume=/dev/disk/by-id/nvme-eui.0025385481b2fe2a-part1 debug ignore_loglevel log_buf_len=16M no_console_suspend net.ifnames=0 mem_encrypt=off systemd.log_target=null

How do I use the bootconfig thing with it? Or is it not supposed to be used that way? IOW, how is it supposed to be used so that it needs to be enabled on every box?

Quoted 2 lines

Okay, I hope it and try to prove it. Anyway, to use boot-time tracing which can fully utilize ftrace at boot-time, we have to enable bootconfig.

Ok, this is getting closer. But not everyone is using boottime tracing?

Or is the logic: every user/tool might need to be able to do boottime tracing at some future point in time and bootconfig is a mandatory part of that use case?

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#21 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 11 lines · On Mon, 10 Feb 2020 12:25:13 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 2 lines · Masami Hiramatsu

OK, could you tell me your idea to make it better? I'm waiting for such discussion a half of last year :)

Yah, situation sounds familiar. :)

Quoted 3 lines

For your information, here is the background of this bootconfig. To build my boot-time tracing, I need a way to pass a flexible and structured configuration at boot time.

Can I see an actual example of what you're doing?

Sure, there are some examples under Documentation/trace/boottime-trace.rst. Since the tracefs (ftrace's filesystem user interface) is extensible by dynamic events and instanses, I need flexibility of option "keys" not only values, also I need structured settings because some keys will configure same events or trace instance.
For example, ftrace has tracing instances (which represents different trace logs) which has some set of configuration parameters. Some parameters has sub-parameters (trace options), and most parameters have default parameters. I don't want to make it a single parametarized options, like ftrace.instance="NAME:OPT1,OPT2:CLOCK:SIZE:SNAPSHOT:...", because it is not human readable and easy to make mistakes. Instead, bootconfig solve that with structured, multi-line keys;

ftrace.instance.NAME {
options = OPT1,OPT2
trace_clock = CLOCK
buffer_size = SIZE
...
}

If we have 3 or more instances, it is easy to expand it as

ftrace.instance {
	NAME1 {
		...
	}
	NAME2 {
		...
	}
	NAME3 {
		...
	}
}

(Hmm, maybe I should reserve "default" name for setting a default configuration)

Quoted 14 lines
Quoted 3 lines

I had tried to reuse devicetree at first, but it was rejected because the devicetree is only for describing hardware. So I introduced this bootconfig.

Makes sense.

Quoted 7 lines

When I designed the bootconfig, I tried to sort out the requirements. That config should be able to pass all setting we can do on tracefs. Since ftrace already has a parser for tracefs, we don't need any types for each settings. Thus it should be something like sysctl.conf. But the sysctl.conf was too simple, it couldn't handle several related keys well. So I decided to introduce braces which put together some related parameters. And the bootconfig syntax was born.

Quoted 7 lines

Ok, here's my boot command line:

[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.5.0-rc7+ root=/dev/nvme0n1p2 ro root=/dev/disk/by-id/nvme-eui.0025385481b2fe2a-part2 resume=/dev/disk/by-id/nvme-eui.0025385481b2fe2a-part1 debug ignore_loglevel log_buf_len=16M no_console_suspend net.ifnames=0 mem_encrypt=off systemd.log_target=null

How do I use the bootconfig thing with it? Or is it not supposed to be used that way? IOW, how is it supposed to be used so that it needs to be enabled on every box?

Sure,

1) write a following bootconfig file
----
kernel {

	# root device and resume devices
	root = /dev/disk/by-id/nvme-eui.0025385481b2fe2a-part2
	resume = /dev/disk/by-id/nvme-eui.0025385481b2fe2a-part1
	ro			# Mount root device readonly.
	debug			# boot with debug log
	ignore_loglevel	# this will print all messages
	log_buf_len = 16M	# So expand log buffer to 16MB
	no_console_suspend	# Debugging suspend process
	mem_encrypt = off	# Set AMD SME to off
}

init {
net.ifnames = 0 # Use tradisional ifname
systemd.log_target = null # Ignore systemd log?
}
----
2) Use tools/bootconfig/bootconfig to apply it to your initrd image

# tools/bootconfig/bootconfig -a <your-bootconfig> <your-initrd>
3) boot.

Note that I don't intended to "replace" all legacy command line (but it is easy for bootloaders to use bootconfig) it seems above example seems have some options which added by the bootloader.

Quoted 5 lines
Quoted 3 lines

Okay, I hope it and try to prove it. Anyway, to use boot-time tracing which can fully utilize ftrace at boot-time, we have to enable bootconfig.

Ok, this is getting closer. But not everyone is using boottime tracing?

No, (but I HOPE so).

Quoted 4 lines

Or is the logic: every user/tool might need to be able to do boottime tracing at some future point in time and bootconfig is a mandatory part of that use case?

Boot time tracing is just a example. I think we can expand this for some other subsystems too. And this might be also helpful for adding a bit more complex syntax to those parameters without parser.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
#22 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 5 lines · Masami Hiramatsu

Sure, there are some examples under Documentation/trace/boottime-trace.rst. Since the tracefs (ftrace's filesystem user interface) is extensible by dynamic events and instanses, I need flexibility of option "keys" not only values, also I need structured settings because some keys will configure same events or trace instance.

[ ... ]

Yap, gotcha. It makes a lot of sense for you guys because you don't want to be typing all those long ftrace command lines on every boot. And the command line in grub can become too long and hard to handle too.

Quoted 14 lines

1) write a following bootconfig file
----
kernel {

	# root device and resume devices
	root = /dev/disk/by-id/nvme-eui.0025385481b2fe2a-part2
	resume = /dev/disk/by-id/nvme-eui.0025385481b2fe2a-part1
	ro			# Mount root device readonly.
	debug			# boot with debug log
	ignore_loglevel	# this will print all messages
	log_buf_len = 16M	# So expand log buffer to 16MB
	no_console_suspend	# Debugging suspend process
	mem_encrypt = off	# Set AMD SME to off
}
Quoted 4 lines

init {
net.ifnames = 0 # Use tradisional ifname
systemd.log_target = null # Ignore systemd log?
}

Ok.

However, this has a downside. When you request dmesg from a user because you're debugging an issue - and we do that all the time - if the command line were in a config file, we would have to see that config file too.

VS now, it is simply in dmesg.

Quoted 3 lines

Boot time tracing is just a example. I think we can expand this for some other subsystems too. And this might be also helpful for adding a bit more complex syntax to those parameters without parser.

Yes, I think I see it now. And I still don't think you want this enabled by default on every box. It is expressed perfectly fine here:

config BOOTTIME_TRACING
bool "Boot-time Tracing support"
depends on BOOT_CONFIG && TRACING

so if distros want to enable that, they will enable BOOT_CONFIG too, transitively. And other subsystems would simply depend on it the same if they wanna use bootconfig.

But the way we supply command line args now ain't broke. And they normal user doesn't care - grub simply pastes them everywhere.

Don't get me wrong - I don't mind using a bootconfig. I simply don't see a compelling argument to have it enabled everywhere and by default and think that other stuff selecting it is perfectly fine. IMO, of course.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#23 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 7 lines · On Mon, 10 Feb 2020 18:40:53 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 5 lines · Masami Hiramatsu

Sure, there are some examples under Documentation/trace/boottime-trace.rst. Since the tracefs (ftrace's filesystem user interface) is extensible by dynamic events and instanses, I need flexibility of option "keys" not only values, also I need structured settings because some keys will configure same events or trace instance.

Quoted 5 lines

[ ... ]

Yap, gotcha. It makes a lot of sense for you guys because you don't want to be typing all those long ftrace command lines on every boot. And the command line in grub can become too long and hard to handle too.

Thanks :)

Quoted 20 lines
Quoted 15 lines

1) write a following bootconfig file
----
kernel {

	# root device and resume devices
	root = /dev/disk/by-id/nvme-eui.0025385481b2fe2a-part2
	resume = /dev/disk/by-id/nvme-eui.0025385481b2fe2a-part1
	ro			# Mount root device readonly.
	debug			# boot with debug log
	ignore_loglevel	# this will print all messages
	log_buf_len = 16M	# So expand log buffer to 16MB
	no_console_suspend	# Debugging suspend process
	mem_encrypt = off	# Set AMD SME to off
}
Quoted 4 lines

init {
net.ifnames = 0 # Use tradisional ifname
systemd.log_target = null # Ignore systemd log?
}

Quoted 7 lines

Ok.

However, this has a downside. When you request dmesg from a user because you're debugging an issue - and we do that all the time - if the command line were in a config file, we would have to see that config file too.

VS now, it is simply in dmesg.

The above kernel.* and init.* are merged into the legacy command line before printing it out to dmesg. For boot-time tracing, yes, we need /proc/bootconfig too.

Quoted 10 lines
Quoted 3 lines

Boot time tracing is just a example. I think we can expand this for some other subsystems too. And this might be also helpful for adding a bit more complex syntax to those parameters without parser.

Yes, I think I see it now. And I still don't think you want this enabled by default on every box. It is expressed perfectly fine here:

config BOOTTIME_TRACING
bool "Boot-time Tracing support"
depends on BOOT_CONFIG && TRACING

Hm, at least "select BOOT_CONFIG" so that user can see this option is there on menuconfig :)

Quoted 10 lines

so if distros want to enable that, they will enable BOOT_CONFIG too, transitively. And other subsystems would simply depend on it the same if they wanna use bootconfig.

But the way we supply command line args now ain't broke. And they normal user doesn't care - grub simply pastes them everywhere.

Don't get me wrong - I don't mind using a bootconfig. I simply don't see a compelling argument to have it enabled everywhere and by default and think that other stuff selecting it is perfectly fine. IMO, of course.

Sorry, you might misunderstand that the bootconfig replaces legacy command line. No, the legacy command line is still there and at least the part of suppremental command line parts of bootconfig are merged into the command line and shown in dmesg. So even if the user use bootconfig, their kernel command line was just updated, they can grub it and simply paste on other machine (if it accepts longer command line)

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
#24 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 6 lines · Masami Hiramatsu

Sorry, you might misunderstand that the bootconfig replaces legacy command line. No, the legacy command line is still there and at least the part of suppremental command line parts of bootconfig are merged into the command line and shown in dmesg. So even if the user use bootconfig, their kernel command line was just updated, they can grub it and simply paste on other machine (if it accepts longer command line)

Ok, I did just play with the thing. I used this boot config for my guest:

---

kernel {
	root=/dev/sda1
	resume=/dev/sda2
	debug
	ignore_loglevel
	log_buf_len=16M
	earlyprintk=ttyS0,115200
	console=ttyS0,115200
	console=tty0
	no_console_suspend
}

init {
net.ifnames=0
}
---

and added it to an initrd which I created especially for this. Which brings me to the next issue I see: AFAIU, bootconfig requires people to have initrd. And the majority of deployments do have initrd enabled but there are use cases where people don't need it. So if bootconfig is going to be default Y, it better support that case.

For example and for a similar reason I support builtin microcode in the microcode loader - when you don't want to enable initrd.

Then, I did add the above bootconfig to the initrd:

./tools/bootconfig/bootconfig -a bootconfig /tmp/initrd.img Apply bootconfig to /tmp/initrd.img

        Number of nodes: 21
        Size: 194 bytes
        Checksum: 16268

and booted my guest.

The thing I noticed is that the guest doesn't show any output in its window anymore but only shows the login window when it is done booting.

And that is probably because of the console= thing. /proc/bootconfig has

$ cat /proc/bootconfig
kernel.root = "/dev/sda1"
kernel.resume = "/dev/sda2"
kernel.debug = ""
kernel.ignore_loglevel = ""
kernel.log_buf_len = "16M"
kernel.earlyprintk = "ttyS0", "115200"
kernel.console = "ttyS0", "115200", "tty0"
kernel.no_console_suspend = ""
init.net.ifnames = "0"

and bootconfig parsing has merged the console= parameters. And the same thing happens if I boot the guest with "console=ttyS0,115200,tty0" on the normal cmdline. But

console=ttyS0,115200 console=tty0

is not the same as

console=ttyS0,115200,tty0

Former has been this way since forever if you wanna have serial output to ttyS* *and* tty output at the same time.

Also, I wouldn't want to rule out any other changes in behavior in other command line options due to this change in parsing and merging of options.

So again, I'm still not convinced bootconfig should be used everywhere and by default.

In addition to the initrd requirement, it needs a special tool to glue it to the end of the initrd. Yeah yeah, it is part of the kernel and the glueing can be made part of the initrd creation tool but still, it is one more and new step.

Now, if bootconfig can *supplement* the normal command line so that you can add more complex configuration directives with it, in *addition* to the normal command line, then sure, by all means.

And it seems that it does that: I did

---
kernel {
initcall_debug
}

init {
}
---

and added it to the cmdline:

[    0.047358] Kernel command line: initcall_debug root=/dev/sda1 resume=/dev/sda2 debug ignore_loglevel log_buf_len=16M earlyprintk=ttyS0,115200 console=ttyS0,115200 console=tty0 no_console_suspend net.ifnames=0  bootconfig

and you can see "initcall_debug" there and it did enable the initcall debugging output so yeah, that seems to work.

Btw, if you remove the boot config with the tool (-d) and still boot with "bootconfig" it says:

[    0.043958] bootconfig size -23483140 greater than max size 32767

so you need to check presence of bootconfig blob and limits in the parsing code too or so.

In any case, this is only my opinion, of course, and I might very well be missing something.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
author maintainer
#25 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 4 lines · On Tue, 18 Feb 2020 14:27:24 +0100 Borislav Petkov <[email protected]> wrote:

Btw, if you remove the boot config with the tool (-d) and still boot with "bootconfig" it says:

[    0.043958] bootconfig size -23483140 greater than max size 32767

I was aware of this but after you reported this, I don't like it.

Masami,

Can you add code to insert "magic" text at the start of the bootconfig appended to the initrd file? Perhaps just have "BOOTCONFIG", and then if it's not there we warn "bootconfig on command line but not found in the initrd". I'm starting to not like relying on the size and checksum only to determine if the bootconfig exists. We need to get this patch before 5.6 is released.

Quoted 6 lines

so you need to check presence of bootconfig blob and limits in the parsing code too or so.

In any case, this is only my opinion, of course, and I might very well be missing something.

OK, what if we put it as default 'n' but we still check if "bootconfig" is on the command line. And if it is, we warn with something like:

#ifndef CONFIG_BOOTCONFIG
	pr_err("WARNING: 'bootconfig' found on the kernel command line but CONFIG_BOOTCONFIG is not set in this kernel\n");

#endif

-- Steve

#26 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 6 lines · Steven Rostedt

OK, what if we put it as default 'n' but we still check if "bootconfig" is on the command line. And if it is, we warn with something like:

#ifndef CONFIG_BOOTCONFIG
	pr_err("WARNING: 'bootconfig' found on the kernel command line but CONFIG_BOOTCONFIG is not set in this kernel\n");

#endif

Sure, makes sense to me. And all the code that requires it, can simply select BOOTCONFIG.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#27 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

Quoted 10 lines · On Tue, 18 Feb 2020 20:38:50 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 6 lines · Steven Rostedt

OK, what if we put it as default 'n' but we still check if "bootconfig" is on the command line. And if it is, we warn with something like:

#ifndef CONFIG_BOOTCONFIG
	pr_err("WARNING: 'bootconfig' found on the kernel command line but CONFIG_BOOTCONFIG is not set in this kernel\n");

#endif

Sure, makes sense to me. And all the code that requires it, can simply select BOOTCONFIG.

OK, so I'll update it.

Thanks!

Signature · 1 line
Masami Hiramatsu <[email protected]>
maintainer
#28 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

In reply to Steven Rostedt
Quoted 9 lines · On Tue, 18 Feb 2020 12:57:48 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 4 lines · On Tue, 18 Feb 2020 14:27:24 +0100 Borislav Petkov <[email protected]> wrote:

Btw, if you remove the boot config with the tool (-d) and still boot with "bootconfig" it says:

[    0.043958] bootconfig size -23483140 greater than max size 32767

I was aware of this but after you reported this, I don't like it.

Yeah, it should be avoided.

Quoted 9 lines

Masami,

Can you add code to insert "magic" text at the start of the bootconfig appended to the initrd file? Perhaps just have "BOOTCONFIG", and then if it's not there we warn "bootconfig on command line but not found in the initrd". I'm starting to not like relying on the size and checksum only to determine if the bootconfig exists. We need to get this patch before 5.6 is released.

OK, that's a good idea. I also considering to add support bootconfig chain-loading support (allowing user to append several bootconfigs to initrd), for making bootloaders to support bootconfig easier. That will need a magic code too.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
maintainer
#29 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

In reply to Borislav Petkov
Quoted 11 lines · On Tue, 18 Feb 2020 14:27:24 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 6 lines · Masami Hiramatsu

Sorry, you might misunderstand that the bootconfig replaces legacy command line. No, the legacy command line is still there and at least the part of suppremental command line parts of bootconfig are merged into the command line and shown in dmesg. So even if the user use bootconfig, their kernel command line was just updated, they can grub it and simply paste on other machine (if it accepts longer command line)

Ok, I did just play with the thing. I used this boot config for my guest:

---

Quoted 8 lines
kernel {
	root=/dev/sda1
	resume=/dev/sda2
	debug
	ignore_loglevel
	log_buf_len=16M
	earlyprintk=ttyS0,115200
	console=ttyS0,115200

Ah, bootconfig syntax interprets the "," as a delimiter of array elements. So those must be quoted by "" (or '') as below.

	earlyprintk="ttyS0,115200"
	console="ttyS0,115200"
Quoted 1 line

console=tty0

Oops, I forgot to support double parameters.

Quoted 8 lines

no_console_suspend
}

init {
net.ifnames=0
}
---

Quoted 5 lines

and added it to an initrd which I created especially for this. Which brings me to the next issue I see: AFAIU, bootconfig requires people to have initrd. And the majority of deployments do have initrd enabled but there are use cases where people don't need it. So if bootconfig is going to be default Y, it better support that case.

Yes, I think we can embed bootconfig into the kernel image while building it as a text data. I think appending the bootconfig to kernel image will be hard because some kernel image will be compressed and self- extracted on memory. It might break original data.

Quoted 2 lines

For example and for a similar reason I support builtin microcode in the microcode loader - when you don't want to enable initrd.

Thanks for the good information! I'll check it.

Quoted 30 lines

Then, I did add the above bootconfig to the initrd:

./tools/bootconfig/bootconfig -a bootconfig /tmp/initrd.img Apply bootconfig to /tmp/initrd.img

        Number of nodes: 21
        Size: 194 bytes
        Checksum: 16268

and booted my guest.

The thing I noticed is that the guest doesn't show any output in its window anymore but only shows the login window when it is done booting.

And that is probably because of the console= thing. /proc/bootconfig has

$ cat /proc/bootconfig
kernel.root = "/dev/sda1"
kernel.resume = "/dev/sda2"
kernel.debug = ""
kernel.ignore_loglevel = ""
kernel.log_buf_len = "16M"
kernel.earlyprintk = "ttyS0", "115200"
kernel.console = "ttyS0", "115200", "tty0"
kernel.no_console_suspend = ""
init.net.ifnames = "0"

and bootconfig parsing has merged the console= parameters. And the same thing happens if I boot the guest with "console=ttyS0,115200,tty0" on the normal cmdline. But

Quoted 5 lines

console=ttyS0,115200 console=tty0

is not the same as

console=ttyS0,115200,tty0

Yes, that is my mistake. Since the legacy command line doesn't support array, it should be expanded. If you write it correctly, I will ensure it to
console=ttyS0,115200 console=tty0

Quoted 7 lines

Former has been this way since forever if you wanna have serial output to ttyS* *and* tty output at the same time.

Also, I wouldn't want to rule out any other changes in behavior in other command line options due to this change in parsing and merging of options.

For the above example, I can fix it. I also would not like to change the behaviors. Could you share your concerning items if you have more?

Quoted 31 lines

So again, I'm still not convinced bootconfig should be used everywhere and by default.

In addition to the initrd requirement, it needs a special tool to glue it to the end of the initrd. Yeah yeah, it is part of the kernel and the glueing can be made part of the initrd creation tool but still, it is one more and new step.

Now, if bootconfig can *supplement* the normal command line so that you can add more complex configuration directives with it, in *addition* to the normal command line, then sure, by all means.

And it seems that it does that: I did

---
kernel {
initcall_debug
}

init {
}
---

and added it to the cmdline:

[    0.047358] Kernel command line: initcall_debug root=/dev/sda1 resume=/dev/sda2 debug ignore_loglevel log_buf_len=16M earlyprintk=ttyS0,115200 console=ttyS0,115200 console=tty0 no_console_suspend net.ifnames=0  bootconfig

and you can see "initcall_debug" there and it did enable the initcall debugging output so yeah, that seems to work.

Quoted 7 lines

Btw, if you remove the boot config with the tool (-d) and still boot with "bootconfig" it says:

[    0.043958] bootconfig size -23483140 greater than max size 32767

so you need to check presence of bootconfig blob and limits in the parsing code too or so.

Agreed, that's confusing message.

Quoted 3 lines

In any case, this is only my opinion, of course, and I might very well be missing something.

Thank you very much for your opinion and information! That's very helpful to me.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
#30 lore raw

Re: [for-next][PATCH 04/26] bootconfig: Add Extra Boot Config support

In reply to Borislav Petkov
Quoted 11 lines · Borislav Petkov
Quoted 3 lines · Masami Hiramatsu

Boot time tracing is just a example. I think we can expand this for some other subsystems too. And this might be also helpful for adding a bit more complex syntax to those parameters without parser.

Yes, I think I see it now. And I still don't think you want this enabled by default on every box. It is expressed perfectly fine here:

config BOOTTIME_TRACING
bool "Boot-time Tracing support"
depends on BOOT_CONFIG && TRACING

Which is BTW "default y", too...

Quoted 3 lines

so if distros want to enable that, they will enable BOOT_CONFIG too, transitively. And other subsystems would simply depend on it the same if they wanna use bootconfig.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author maintainer
#31 lore raw

PATCH 5/26 bootconfig: Load boot config from the tail of initrd

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Load the extended boot config data from the tail of initrd image. If there is an SKC data there, it has [(u32)size][(u32)checksum] header (in really, this is a footer) at the end of initrd. If the checksum (simple sum of bytes) is match, this starts parsing it from there.

---
 init/Kconfig |  1 +
 init/main.c  | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)
init/Kconfig +1 -0
index 63450d3bbf12..ffd240fb88c3 100644
@@ -1217,6 +1217,7 @@ endif
 
 config BOOT_CONFIG
 	bool "Boot config support"
+	depends on BLK_DEV_INITRD
 	select LIBXBC
 	default y
 	help
init/main.c +54 -0

72 lines not on this page · raw message

Signature · 1 line
2.24.1
author maintainer
#32 lore raw

PATCH 6/26 tools: bootconfig: Add bootconfig command

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add "bootconfig" command which operates the bootconfig config-data on initrd image.

User can add/delete/verify the boot config on initrd image using this command.

e.g.
Add a boot config to initrd image

 # bootconfig -a myboot.conf /boot/initrd.img

Remove it.

 # bootconfig -d /boot/initrd.img

Or verify (and show) it.

 # bootconfig /boot/initrd.img
[ Removed extra blank line at end of bootconfig.c ]
---
 MAINTAINERS                                 |   1 +
 tools/Makefile                              |  11 +-
 tools/bootconfig/.gitignore                 |   1 +
 tools/bootconfig/Makefile                   |  20 ++
 tools/bootconfig/include/linux/bootconfig.h |   7 +
 tools/bootconfig/include/linux/bug.h        |  12 +
 tools/bootconfig/include/linux/ctype.h      |   7 +
 tools/bootconfig/include/linux/errno.h      |   7 +
 tools/bootconfig/include/linux/kernel.h     |  18 +
 tools/bootconfig/include/linux/printk.h     |  17 +
 tools/bootconfig/include/linux/string.h     |  32 ++
 tools/bootconfig/main.c                     | 353 ++++++++++++++++++++
 12 files changed, 481 insertions(+), 5 deletions(-)
 create mode 100644 tools/bootconfig/.gitignore
 create mode 100644 tools/bootconfig/Makefile
 create mode 100644 tools/bootconfig/include/linux/bootconfig.h
 create mode 100644 tools/bootconfig/include/linux/bug.h
 create mode 100644 tools/bootconfig/include/linux/ctype.h
 create mode 100644 tools/bootconfig/include/linux/errno.h
 create mode 100644 tools/bootconfig/include/linux/kernel.h
 create mode 100644 tools/bootconfig/include/linux/printk.h
 create mode 100644 tools/bootconfig/include/linux/string.h
 create mode 100644 tools/bootconfig/main.c
MAINTAINERS +1 -0
index 8597285eb7c8..06005006de7c 100644
@@ -15775,6 +15775,7 @@ M:	Masami Hiramatsu <[email protected]>
 S:	Maintained
 F:	lib/bootconfig.c
 F:	include/linux/bootconfig.h
+F:	tools/bootconfig/*
 
 SUN3/3X
 M:	Sam Creasey <[email protected]>
tools/Makefile +6 -5
index 7e42f7b8bfa7..bd778812e915 100644
@@ -28,6 +28,7 @@ help:
 	@echo '  pci                    - PCI tools'
 	@echo '  perf                   - Linux performance measurement and analysis tool'
 	@echo '  selftests              - various kernel selftests'
+	@echo '  bootconfig             - boot config tool'
 	@echo '  spi                    - spi tools'
 	@echo '  tmon                   - thermal monitoring and tuning tool'
 	@echo '  turbostat              - Intel CPU idle stats and freq reporting tool'
@@ -63,7 +64,7 @@ acpi: FORCE
 cpupower: FORCE
 	$(call descend,power/$@)
 
-cgroup firewire hv guest spi usb virtio vm bpf iio gpio objtool leds wmi pci firmware debugging: FORCE
+cgroup firewire hv guest bootconfig spi usb virtio vm bpf iio gpio objtool leds wmi pci firmware debugging: FORCE
 	$(call descend,$@)
 
 liblockdep: FORCE
@@ -96,7 +97,7 @@ kvm_stat: FORCE
 	$(call descend,kvm/$@)
 
 all: acpi cgroup cpupower gpio hv firewire liblockdep \
-		perf selftests spi turbostat usb \
+		perf selftests bootconfig spi turbostat usb \
 		virtio vm bpf x86_energy_perf_policy \
 		tmon freefall iio objtool kvm_stat wmi \
 		pci debugging
@@ -107,7 +108,7 @@ acpi_install:
 cpupower_install:
 	$(call descend,power/$(@:_install=),install)
 
-cgroup_install firewire_install gpio_install hv_install iio_install perf_install spi_install usb_install virtio_install vm_install bpf_install objtool_install wmi_install pci_install debugging_install:
+cgroup_install firewire_install gpio_install hv_install iio_install perf_install bootconfig_install spi_install usb_install virtio_install vm_install bpf_install objtool_install wmi_install pci_install debugging_install:
 	$(call descend,$(@:_install=),install)
 
 liblockdep_install:
@@ -141,7 +142,7 @@ acpi_clean:
 cpupower_clean:
 	$(call descend,power/cpupower,clean)
 
-cgroup_clean hv_clean firewire_clean spi_clean usb_clean virtio_clean vm_clean wmi_clean bpf_clean iio_clean gpio_clean objtool_clean leds_clean pci_clean firmware_clean debugging_clean:
+cgroup_clean hv_clean firewire_clean bootconfig_clean spi_clean usb_clean virtio_clean vm_clean wmi_clean bpf_clean iio_clean gpio_clean objtool_clean leds_clean pci_clean firmware_clean debugging_clean:
 	$(call descend,$(@:_clean=),clean)
 
 liblockdep_clean:
@@ -176,7 +177,7 @@ build_clean:
 	$(call descend,build,clean)
 
 clean: acpi_clean cgroup_clean cpupower_clean hv_clean firewire_clean \
-		perf_clean selftests_clean turbostat_clean spi_clean usb_clean virtio_clean \
+		perf_clean selftests_clean turbostat_clean bootconfig_clean spi_clean usb_clean virtio_clean \
 		vm_clean bpf_clean iio_clean x86_energy_perf_policy_clean tmon_clean \
 		freefall_clean build_clean libbpf_clean libsubcmd_clean liblockdep_clean \
 		gpio_clean objtool_clean leds_clean wmi_clean pci_clean firmware_clean debugging_clean \
tools/bootconfig/.gitignore new file +1 -0
new file mode 100644
index 000000000000..e7644dfaa4a7
@@ -0,0 +1 @@
+bootconfig
tools/bootconfig/Makefile new file +20 -0
new file mode 100644
index 000000000000..681b7aef3e44
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0
+# Makefile for bootconfig command
+
+bindir ?= /usr/bin
+
+HEADER = include/linux/bootconfig.h
+CFLAGS = -Wall -g -I./include
+
+PROGS = bootconfig
+
+all: $(PROGS)
+
+bootconfig: ../../lib/bootconfig.c main.c $(HEADER)
+	$(CC) $(filter %.c,$^) $(CFLAGS) -o $@
+
+install: $(PROGS)
+	install bootconfig $(DESTDIR)$(bindir)
+
+clean:
+	$(RM) -f *.o bootconfig
tools/bootconfig/include/linux/bootconfig.h new file +7 -0
new file mode 100644
index 000000000000..078cbd2ba651
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _BOOTCONFIG_LINUX_BOOTCONFIG_H
+#define _BOOTCONFIG_LINUX_BOOTCONFIG_H
+
+#include "../../../../include/linux/bootconfig.h"
+
+#endif
tools/bootconfig/include/linux/bug.h new file +12 -0
new file mode 100644
index 000000000000..7b65a389c0dd
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _SKC_LINUX_BUG_H
+#define _SKC_LINUX_BUG_H
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define WARN_ON(cond)	\
+	((cond) ? printf("Internal warning(%s:%d, %s): %s\n",	\
+			__FILE__, __LINE__, __func__, #cond) : 0)
+
+#endif
tools/bootconfig/include/linux/ctype.h new file +7 -0
new file mode 100644
index 000000000000..c56ecc136448
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _SKC_LINUX_CTYPE_H
+#define _SKC_LINUX_CTYPE_H
+
+#include <ctype.h>
+
+#endif
tools/bootconfig/include/linux/errno.h new file +7 -0
new file mode 100644
index 000000000000..5d9f91ec2fda
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _SKC_LINUX_ERRNO_H
+#define _SKC_LINUX_ERRNO_H
+
+#include <asm/errno.h>
+
+#endif
tools/bootconfig/include/linux/kernel.h new file +18 -0
new file mode 100644
index 000000000000..2d93320aa374
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _SKC_LINUX_KERNEL_H
+#define _SKC_LINUX_KERNEL_H
+
+#include <stdlib.h>
+#include <stdbool.h>
+
+#include <linux/printk.h>
+
+typedef unsigned short u16;
+typedef unsigned int   u32;
+
+#define unlikely(cond)	(cond)
+
+#define __init
+#define __initdata
+
+#endif
tools/bootconfig/include/linux/printk.h new file +17 -0
new file mode 100644
index 000000000000..017bcd6912a5
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _SKC_LINUX_PRINTK_H
+#define _SKC_LINUX_PRINTK_H
+
+#include <stdio.h>
+
+/* controllable printf */
+extern int pr_output;
+#define printk(fmt, ...)	\
+	(pr_output ? printf(fmt, __VA_ARGS__) : 0)
+
+#define pr_err printk
+#define pr_warn	printk
+#define pr_info	printk
+#define pr_debug printk
+
+#endif
tools/bootconfig/include/linux/string.h new file +32 -0
new file mode 100644
index 000000000000..8267af75153a
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _SKC_LINUX_STRING_H
+#define _SKC_LINUX_STRING_H
+
+#include <string.h>
+
+/* Copied from lib/string.c */
+static inline char *skip_spaces(const char *str)
+{
+	while (isspace(*str))
+		++str;
+	return (char *)str;
+}
+
+static inline char *strim(char *s)
+{
+	size_t size;
+	char *end;
+
+	size = strlen(s);
+	if (!size)
+		return s;
+
+	end = s + size - 1;
+	while (end >= s && isspace(*end))
+		end--;
+	*(end + 1) = '\0';
+
+	return skip_spaces(s);
+}
+
+#endif
tools/bootconfig/main.c new file +353 -0

353 lines not on this page · raw message

Signature · 1 line
2.24.1
#33 lore raw

Re: [for-next][PATCH 06/26] tools: bootconfig: Add bootconfig command

Quoted 23 lines · Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add "bootconfig" command which operates the bootconfig config-data on initrd image.

User can add/delete/verify the boot config on initrd image using this command.

e.g.
Add a boot config to initrd image

 # bootconfig -a myboot.conf /boot/initrd.img

Remove it.

 # bootconfig -d /boot/initrd.img

Or verify (and show) it.

 # bootconfig /boot/initrd.img
[ Removed extra blank line at end of bootconfig.c ]
Quoted 13 lines
---
 MAINTAINERS                                 |   1 +
 tools/Makefile                              |  11 +-
 tools/bootconfig/.gitignore                 |   1 +
 tools/bootconfig/Makefile                   |  20 ++
 tools/bootconfig/include/linux/bootconfig.h |   7 +
 tools/bootconfig/include/linux/bug.h        |  12 +
 tools/bootconfig/include/linux/ctype.h      |   7 +
 tools/bootconfig/include/linux/errno.h      |   7 +
 tools/bootconfig/include/linux/kernel.h     |  18 +
 tools/bootconfig/include/linux/printk.h     |  17 +
 tools/bootconfig/include/linux/string.h     |  32 ++
 tools/bootconfig/main.c                     | 353 ++++++++++++++++++++

This doesn't seem to build:

  $ cd tools/bootconfig
  $ make
  cc ../../lib/bootconfig.c main.c -Wall -g -I./include -o bootconfig
  In file included from ./include/linux/kernel.h:8,
                   from ../../lib/bootconfig.c:12:
  ../../lib/bootconfig.c: In function ‘xbc_init’:
  ./include/linux/printk.h:10:38: error: expected expression before ‘)’ token
     10 |  (pr_output ? printf(fmt, __VA_ARGS__) : 0)
        |                                      ^
  ./include/linux/printk.h:12:16: note: in expansion of macro ‘printk’
     12 | #define pr_err printk
        |                ^~~~~~
  ../../lib/bootconfig.c:740:3: note: in expansion of macro ‘pr_err’
    740 |   pr_err("Error: bootconfig is already initialized.\n");
        |   ^~~~~~
  make: *** [Makefile:14: bootconfig] Error 1

That's on Fedora 30, x86_64, but I see the same elsewhere.

cheers

maintainer
#34 lore raw

Re: [for-next][PATCH 06/26] tools: bootconfig: Add bootconfig command

Quoted 58 lines · On Sat, 08 Feb 2020 00:02:04 +1100 Michael Ellerman <[email protected]> wrote:
Quoted 23 lines · Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add "bootconfig" command which operates the bootconfig config-data on initrd image.

User can add/delete/verify the boot config on initrd image using this command.

e.g.
Add a boot config to initrd image

 # bootconfig -a myboot.conf /boot/initrd.img

Remove it.

 # bootconfig -d /boot/initrd.img

Or verify (and show) it.

 # bootconfig /boot/initrd.img
[ Removed extra blank line at end of bootconfig.c ]
Quoted 13 lines
---
 MAINTAINERS                                 |   1 +
 tools/Makefile                              |  11 +-
 tools/bootconfig/.gitignore                 |   1 +
 tools/bootconfig/Makefile                   |  20 ++
 tools/bootconfig/include/linux/bootconfig.h |   7 +
 tools/bootconfig/include/linux/bug.h        |  12 +
 tools/bootconfig/include/linux/ctype.h      |   7 +
 tools/bootconfig/include/linux/errno.h      |   7 +
 tools/bootconfig/include/linux/kernel.h     |  18 +
 tools/bootconfig/include/linux/printk.h     |  17 +
 tools/bootconfig/include/linux/string.h     |  32 ++
 tools/bootconfig/main.c                     | 353 ++++++++++++++++++++

This doesn't seem to build:

  $ cd tools/bootconfig
  $ make
  cc ../../lib/bootconfig.c main.c -Wall -g -I./include -o bootconfig
  In file included from ./include/linux/kernel.h:8,
                   from ../../lib/bootconfig.c:12:
  ../../lib/bootconfig.c: In function ‘xbc_init’:
  ./include/linux/printk.h:10:38: error: expected expression before ‘)’ token
     10 |  (pr_output ? printf(fmt, __VA_ARGS__) : 0)
        |                                      ^
  ./include/linux/printk.h:12:16: note: in expansion of macro ‘printk’
     12 | #define pr_err printk
        |                ^~~~~~
  ../../lib/bootconfig.c:740:3: note: in expansion of macro ‘pr_err’
    740 |   pr_err("Error: bootconfig is already initialized.\n");
        |   ^~~~~~
  make: *** [Makefile:14: bootconfig] Error 1
Quoted 1 line

That's on Fedora 30, x86_64, but I see the same elsewhere.

Oops, thanks for reporting!
I found that the above macro doesn't work if the function gets 1 argument. It should use ##__VA_ARGS__ instead of __VA_ARGS__.
OK, I'll fix it.

Thanks!

Signature · 1 line
Masami Hiramatsu <[email protected]>
maintainer
#35 lore raw

PATCH 1/1 tools/bootconfig: Fix wrong __VA_ARGS__ usage

In reply to Michael Ellerman

Since printk() wrapper macro uses __VA_ARGS__ without "##" prefix, it causes a build error if there is no variable arguments (e.g. only fmt is specified.) To fix this error, use ##__VA_ARGS__ instead of __VAR_ARGS__.

Fixes 950313ebf79c ("tools: bootconfig: Add bootconfig command")
---
 tools/bootconfig/include/linux/printk.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bootconfig/include/linux/printk.h +1 -1
index 017bcd6912a5..e978a63d3222 100644
@@ -7,7 +7,7 @@
 /* controllable printf */
 extern int pr_output;
 #define printk(fmt, ...)	\
-	(pr_output ? printf(fmt, __VA_ARGS__) : 0)
+	(pr_output ? printf(fmt, ##__VA_ARGS__) : 0)
 
 #define pr_err printk
 #define pr_warn	printk
#36 lore raw

Re: [PATCH] tools/bootconfig: Fix wrong __VA_ARGS__ usage

Quoted 6 lines · Masami Hiramatsu

Since printk() wrapper macro uses __VA_ARGS__ without "##" prefix, it causes a build error if there is no variable arguments (e.g. only fmt is specified.) To fix this error, use ##__VA_ARGS__ instead of __VAR_ARGS__.

Quoted 6 lines
Fixes 950313ebf79c ("tools: bootconfig: Add bootconfig command")
---
 tools/bootconfig/include/linux/printk.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks that builds for me.

The output when adding to a fresh initrd is a bit confusing though, eg:

  $ ./bootconfig -a samples/good-simple.bconf initrd.img
  Apply samples/good-simple.bconf to initrd.img
          Number of nodes: 13
          Size: 120 bytes
          Checksum: 9036
  checksum error: 0 != 444373994
  $ echo $?
  0

ie. the checksum error.

That's because although delete_xbc() does:

	pr_output = 0;
	size = load_xbc_from_initrd(fd, &buf);

in load_xbc_from_initrd() the error message is printed with printf, not printk, so it's not controlled by pr_output:

	printf("checksum error: %d != %d\n", csum, rcsum);

Switching that line to printk fixes it, ie. makes the checksum error go away, but it seems a bit odd to be using printk in userspace code.

cheers

maintainer
#37 lore raw

Re: [PATCH] tools/bootconfig: Fix wrong __VA_ARGS__ usage

Quoted 27 lines · On Sat, 08 Feb 2020 22:10:40 +1100 Michael Ellerman <[email protected]> wrote:
Quoted 6 lines · Masami Hiramatsu

Since printk() wrapper macro uses __VA_ARGS__ without "##" prefix, it causes a build error if there is no variable arguments (e.g. only fmt is specified.) To fix this error, use ##__VA_ARGS__ instead of __VAR_ARGS__.

Quoted 6 lines
Fixes 950313ebf79c ("tools: bootconfig: Add bootconfig command")
---
 tools/bootconfig/include/linux/printk.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks that builds for me.

The output when adding to a fresh initrd is a bit confusing though, eg:

  $ ./bootconfig -a samples/good-simple.bconf initrd.img
  Apply samples/good-simple.bconf to initrd.img
          Number of nodes: 13
          Size: 120 bytes
          Checksum: 9036
  checksum error: 0 != 444373994
  $ echo $?
  0
Quoted 1 line

ie. the checksum error.

Hmm...

Quoted 10 lines

That's because although delete_xbc() does:

	pr_output = 0;
	size = load_xbc_from_initrd(fd, &buf);

in load_xbc_from_initrd() the error message is printed with printf, not printk, so it's not controlled by pr_output:

	printf("checksum error: %d != %d\n", csum, rcsum);

Oh, I got it. If there is no bootconfig in initrd, it warns but that is expected result.

Quoted 3 lines

Switching that line to printk fixes it, ie. makes the checksum error go away, but it seems a bit odd to be using printk in userspace code.

What about pr_err() as perf does? :)
OK, I'll fix the error messages.

Thank you,

Quoted 2 lines

cheers

Signature · 1 line
Masami Hiramatsu <[email protected]>
maintainer
#38 lore raw

PATCH 1/1 tools/bootconfig: Suppress non-error messages

In reply to Michael Ellerman

Suppress non-error messages when applying new bootconfig to initrd image. To enable it, replace printf for error message with pr_err() macro.
This also adds a testcase for this fix.

---
 tools/bootconfig/main.c             |   28 ++++++++++++++--------------
 tools/bootconfig/test-bootconfig.sh |    9 +++++++++
 2 files changed, 23 insertions(+), 14 deletions(-)
tools/bootconfig/main.c +14 -14
index 47f488458328..e18eeb070562 100644
@@ -140,7 +140,7 @@ int load_xbc_from_initrd(int fd, char **buf)
 		return 0;
 
 	if (lseek(fd, -8, SEEK_END) < 0) {
-		printf("Failed to lseek: %d\n", -errno);
+		pr_err("Failed to lseek: %d\n", -errno);
 		return -errno;
 	}
 
@@ -155,7 +155,7 @@ int load_xbc_from_initrd(int fd, char **buf)
 		return 0;
 
 	if (lseek(fd, stat.st_size - 8 - size, SEEK_SET) < 0) {
-		printf("Failed to lseek: %d\n", -errno);
+		pr_err("Failed to lseek: %d\n", -errno);
 		return -errno;
 	}
 
@@ -166,7 +166,7 @@ int load_xbc_from_initrd(int fd, char **buf)
 	/* Wrong Checksum, maybe no boot config here */
 	rcsum = checksum((unsigned char *)*buf, size);
 	if (csum != rcsum) {
-		printf("checksum error: %d != %d\n", csum, rcsum);
+		pr_err("checksum error: %d != %d\n", csum, rcsum);
 		return 0;
 	}
 
@@ -185,13 +185,13 @@ int show_xbc(const char *path)
 
 	fd = open(path, O_RDONLY);
 	if (fd < 0) {
-		printf("Failed to open initrd %s: %d\n", path, fd);
+		pr_err("Failed to open initrd %s: %d\n", path, fd);
 		return -errno;
 	}
 
 	ret = load_xbc_from_initrd(fd, &buf);
 	if (ret < 0)
-		printf("Failed to load a boot config from initrd: %d\n", ret);
+		pr_err("Failed to load a boot config from initrd: %d\n", ret);
 	else
 		xbc_show_compact_tree();
 
@@ -209,7 +209,7 @@ int delete_xbc(const char *path)
 
 	fd = open(path, O_RDWR);
 	if (fd < 0) {
-		printf("Failed to open initrd %s: %d\n", path, fd);
+		pr_err("Failed to open initrd %s: %d\n", path, fd);
 		return -errno;
 	}
 
@@ -222,7 +222,7 @@ int delete_xbc(const char *path)
 	pr_output = 1;
 	if (size < 0) {
 		ret = size;
-		printf("Failed to load a boot config from initrd: %d\n", ret);
+		pr_err("Failed to load a boot config from initrd: %d\n", ret);
 	} else if (size > 0) {
 		ret = fstat(fd, &stat);
 		if (!ret)
@@ -245,7 +245,7 @@ int apply_xbc(const char *path, const char *xbc_path)
 
 	ret = load_xbc_file(xbc_path, &buf);
 	if (ret < 0) {
-		printf("Failed to load %s : %d\n", xbc_path, ret);
+		pr_err("Failed to load %s : %d\n", xbc_path, ret);
 		return ret;
 	}
 	size = strlen(buf) + 1;
@@ -262,7 +262,7 @@ int apply_xbc(const char *path, const char *xbc_path)
 	/* Check the data format */
 	ret = xbc_init(buf);
 	if (ret < 0) {
-		printf("Failed to parse %s: %d\n", xbc_path, ret);
+		pr_err("Failed to parse %s: %d\n", xbc_path, ret);
 		free(data);
 		free(buf);
 		return ret;
@@ -279,20 +279,20 @@ int apply_xbc(const char *path, const char *xbc_path)
 	/* Remove old boot config if exists */
 	ret = delete_xbc(path);
 	if (ret < 0) {
-		printf("Failed to delete previous boot config: %d\n", ret);
+		pr_err("Failed to delete previous boot config: %d\n", ret);
 		return ret;
 	}
 
 	/* Apply new one */
 	fd = open(path, O_RDWR | O_APPEND);
 	if (fd < 0) {
-		printf("Failed to open %s: %d\n", path, fd);
+		pr_err("Failed to open %s: %d\n", path, fd);
 		return fd;
 	}
 	/* TODO: Ensure the @path is initramfs/initrd image */
 	ret = write(fd, data, size + 8);
 	if (ret < 0) {
-		printf("Failed to apply a boot config: %d\n", ret);
+		pr_err("Failed to apply a boot config: %d\n", ret);
 		return ret;
 	}
 	close(fd);
@@ -334,12 +334,12 @@ int main(int argc, char **argv)
 	}
 
 	if (apply && delete) {
-		printf("Error: You can not specify both -a and -d at once.\n");
+		pr_err("Error: You can not specify both -a and -d at once.\n");
 		return usage();
 	}
 
 	if (optind >= argc) {
-		printf("Error: No initrd is specified.\n");
+		pr_err("Error: No initrd is specified.\n");
 		return usage();
 	}
 
tools/bootconfig/test-bootconfig.sh +9 -0
index 87725e8723f8..1de06de328e2 100755
@@ -64,6 +64,15 @@ echo "File size check"
 new_size=$(stat -c %s $INITRD)
 xpass test $new_size -eq $initrd_size
 
+echo "No error messge while applying"
+OUTFILE=`mktemp tempout-XXXX`
+dd if=/dev/zero of=$INITRD bs=4096 count=1
+printf " \0\0\0 \0\0\0" >> $INITRD
+$BOOTCONF -a $TEMPCONF $INITRD > $OUTFILE 2>&1
+xfail grep -i "failed" $OUTFILE
+xfail grep -i "error" $OUTFILE
+rm $OUTFILE
+
 echo "Max node number check"
 
 echo -n > $TEMPCONF
Tested-by on v1 1/1
#39 lore raw

Re: [PATCH] tools/bootconfig: Suppress non-error messages

Quoted 11 lines · Masami Hiramatsu

Suppress non-error messages when applying new bootconfig to initrd image. To enable it, replace printf for error message with pr_err() macro.
This also adds a testcase for this fix.

---
 tools/bootconfig/main.c             |   28 ++++++++++++++--------------
 tools/bootconfig/test-bootconfig.sh |    9 +++++++++
 2 files changed, 23 insertions(+), 14 deletions(-)

Thanks, that works for me.

cheers

maintainer
#40 lore raw

Re: [PATCH] tools/bootconfig: Suppress non-error messages

Hi Michael,

Quoted 13 lines · On Mon, 10 Feb 2020 13:06:14 +1100 Michael Ellerman <[email protected]> wrote:
Quoted 11 lines · Masami Hiramatsu

Suppress non-error messages when applying new bootconfig to initrd image. To enable it, replace printf for error message with pr_err() macro.
This also adds a testcase for this fix.

---
 tools/bootconfig/main.c             |   28 ++++++++++++++--------------
 tools/bootconfig/test-bootconfig.sh |    9 +++++++++
 2 files changed, 23 insertions(+), 14 deletions(-)
Quoted 3 lines

Thanks, that works for me.

Could you give me your tested-by to the previous patch too?

Thank you!

Quoted 2 lines

cheers

Signature · 1 line
Masami Hiramatsu <[email protected]>
#41 lore raw

Re: [PATCH] tools/bootconfig: Suppress non-error messages

Quoted 18 lines · Masami Hiramatsu

Hi Michael,

Quoted 13 lines · On Mon, 10 Feb 2020 13:06:14 +1100 Michael Ellerman <[email protected]> wrote:
Quoted 11 lines · Masami Hiramatsu

Suppress non-error messages when applying new bootconfig to initrd image. To enable it, replace printf for error message with pr_err() macro.
This also adds a testcase for this fix.

---
 tools/bootconfig/main.c             |   28 ++++++++++++++--------------
 tools/bootconfig/test-bootconfig.sh |    9 +++++++++
 2 files changed, 23 insertions(+), 14 deletions(-)
Quoted 5 lines
Quoted 3 lines

Thanks, that works for me.

Could you give me your tested-by to the previous patch too?

Sure, just sent.

cheers

Tested-by on v1 1/1
#42 lore raw

Re: [PATCH] tools/bootconfig: Fix wrong __VA_ARGS__ usage

In reply to Masami Hiramatsu
Quoted 18 lines · Masami Hiramatsu

Since printk() wrapper macro uses __VA_ARGS__ without "##" prefix, it causes a build error if there is no variable arguments (e.g. only fmt is specified.) To fix this error, use ##__VA_ARGS__ instead of __VAR_ARGS__.

Fixes 950313ebf79c ("tools: bootconfig: Add bootconfig command")
---
 tools/bootconfig/include/linux/printk.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bootconfig/include/linux/printk.h +0 -0
index 017bcd6912a5..e978a63d3222 100644

tools/bootconfig/include/linux/printk.h line 13

Quoted 8 lines
tools/bootconfig/include/linux/printk.h +1 -1
@@ -7,7 +7,7 @@
 /* controllable printf */
 extern int pr_output;
 #define printk(fmt, ...)	\
-	(pr_output ? printf(fmt, __VA_ARGS__) : 0)
+	(pr_output ? printf(fmt, ##__VA_ARGS__) : 0)
 
 #define pr_err printk
 #define pr_warn	printk

cheers

author maintainer
#43 lore raw

Re: [PATCH] tools/bootconfig: Fix wrong __VA_ARGS__ usage

Quoted 11 lines · On Mon, 10 Feb 2020 20:50:42 +1100 Michael Ellerman <[email protected]> wrote:
Quoted 11 lines
tools/bootconfig/include/linux/printk.h +1 -1
index 017bcd6912a5..e978a63d3222 100644
@@ -7,7 +7,7 @@
 /* controllable printf */
 extern int pr_output;
 #define printk(fmt, ...)	\
-	(pr_output ? printf(fmt, __VA_ARGS__) : 0)
+	(pr_output ? printf(fmt, ##__VA_ARGS__) : 0)
 
Quoted 4 lines

tools/bootconfig/include/linux/printk.h line 13

Quoted 2 lines
tools/bootconfig/include/linux/printk.h +0 -0
 #define pr_err printk
 #define pr_warn	printk  

Thanks! I'll rebase my branch with this.

-- Steve

author maintainer
#44 lore raw

PATCH 7/26 tools: bootconfig: Add bootconfig test script

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add a bootconfig test script to ensure the tool and boot config parser are working correctly.

---
 tools/bootconfig/Makefile                     |   3 +
 .../samples/bad-array-space-comment.bconf     |   5 +
 tools/bootconfig/samples/bad-array.bconf      |   2 +
 tools/bootconfig/samples/bad-dotword.bconf    |   4 +
 tools/bootconfig/samples/bad-empty.bconf      |   1 +
 tools/bootconfig/samples/bad-keyerror.bconf   |   2 +
 tools/bootconfig/samples/bad-longkey.bconf    |   1 +
 tools/bootconfig/samples/bad-manywords.bconf  |   1 +
 tools/bootconfig/samples/bad-no-keyword.bconf |   2 +
 .../bootconfig/samples/bad-nonprintable.bconf |   2 +
 tools/bootconfig/samples/bad-spaceword.bconf  |   2 +
 tools/bootconfig/samples/bad-tree.bconf       |   5 +
 tools/bootconfig/samples/bad-value.bconf      |   3 +
 tools/bootconfig/samples/escaped.bconf        |   3 +
 .../samples/good-array-space-comment.bconf    |   4 +
 .../samples/good-comment-after-value.bconf    |   1 +
 .../bootconfig/samples/good-printables.bconf  |   2 +
 tools/bootconfig/samples/good-simple.bconf    |  11 ++
 tools/bootconfig/samples/good-single.bconf    |   4 +
 .../samples/good-space-after-value.bconf      |   1 +
 tools/bootconfig/samples/good-tree.bconf      |  12 ++
 tools/bootconfig/test-bootconfig.sh           | 105 ++++++++++++++++++
 22 files changed, 176 insertions(+)
 create mode 100644 tools/bootconfig/samples/bad-array-space-comment.bconf
 create mode 100644 tools/bootconfig/samples/bad-array.bconf
 create mode 100644 tools/bootconfig/samples/bad-dotword.bconf
 create mode 100644 tools/bootconfig/samples/bad-empty.bconf
 create mode 100644 tools/bootconfig/samples/bad-keyerror.bconf
 create mode 100644 tools/bootconfig/samples/bad-longkey.bconf
 create mode 100644 tools/bootconfig/samples/bad-manywords.bconf
 create mode 100644 tools/bootconfig/samples/bad-no-keyword.bconf
 create mode 100644 tools/bootconfig/samples/bad-nonprintable.bconf
 create mode 100644 tools/bootconfig/samples/bad-spaceword.bconf
 create mode 100644 tools/bootconfig/samples/bad-tree.bconf
 create mode 100644 tools/bootconfig/samples/bad-value.bconf
 create mode 100644 tools/bootconfig/samples/escaped.bconf
 create mode 100644 tools/bootconfig/samples/good-array-space-comment.bconf
 create mode 100644 tools/bootconfig/samples/good-comment-after-value.bconf
 create mode 100644 tools/bootconfig/samples/good-printables.bconf
 create mode 100644 tools/bootconfig/samples/good-simple.bconf
 create mode 100644 tools/bootconfig/samples/good-single.bconf
 create mode 100644 tools/bootconfig/samples/good-space-after-value.bconf
 create mode 100644 tools/bootconfig/samples/good-tree.bconf
 create mode 100755 tools/bootconfig/test-bootconfig.sh
tools/bootconfig/Makefile +3 -0
index 681b7aef3e44..a6146ac64458 100644
@@ -16,5 +16,8 @@ bootconfig: ../../lib/bootconfig.c main.c $(HEADER)
 install: $(PROGS)
 	install bootconfig $(DESTDIR)$(bindir)
 
+test: bootconfig
+	./test-bootconfig.sh
+
 clean:
 	$(RM) -f *.o bootconfig
tools/bootconfig/samples/bad-array-space-comment.bconf new file +5 -0
new file mode 100644
index 000000000000..fda19e47d0db
@@ -0,0 +1,5 @@
+key =	# comment
+	"value1",	  # comment1
+	"value2" 	  # comment2
+,
+	"value3"
tools/bootconfig/samples/bad-array.bconf new file +2 -0
new file mode 100644
index 000000000000..0174af019d7f
@@ -0,0 +1,2 @@
+# Array must be comma separated.
+key = "value1" "value2"
tools/bootconfig/samples/bad-dotword.bconf new file +4 -0
new file mode 100644
index 000000000000..ba5557b2bdd3
@@ -0,0 +1,4 @@
+# do not start keyword with .
+key {
+  .word = 1
+}
tools/bootconfig/samples/bad-empty.bconf new file +1 -0
new file mode 100644
index 000000000000..2ba3f6cc6a47
@@ -0,0 +1 @@
+# Wrong boot config: comment only
tools/bootconfig/samples/bad-keyerror.bconf new file +2 -0
new file mode 100644
index 000000000000..b6e247a099d0
@@ -0,0 +1,2 @@
+# key word can not contain ","
+key,word
tools/bootconfig/samples/bad-longkey.bconf new file +1 -0
new file mode 100644
index 000000000000..eb97369f91a8
@@ -0,0 +1 @@
+key_word_is_too_long01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345
tools/bootconfig/samples/bad-manywords.bconf new file +1 -0
new file mode 100644
index 000000000000..8db81967c48a
@@ -0,0 +1 @@
+key1.is2.too3.long4.5.6.7.8.9.10.11.12.13.14.15.16.17
tools/bootconfig/samples/bad-no-keyword.bconf new file +2 -0
new file mode 100644
index 000000000000..eff26808566c
@@ -0,0 +1,2 @@
+# No keyword
+{}
tools/bootconfig/samples/bad-nonprintable.bconf new file +2 -0
new file mode 100644
index 000000000000..3bb1a2864e52
@@ -0,0 +1,2 @@
+# Non printable
+key = ""
tools/bootconfig/samples/bad-spaceword.bconf new file +2 -0
new file mode 100644
index 000000000000..90c703d32a9a
@@ -0,0 +1,2 @@
+# No space between words
+key . word
tools/bootconfig/samples/bad-tree.bconf new file +5 -0
new file mode 100644
index 000000000000..5a6038edcd55
@@ -0,0 +1,5 @@
+# brace is not closing
+tree {
+  node {
+    value = 1
+}
tools/bootconfig/samples/bad-value.bconf new file +3 -0
new file mode 100644
index 000000000000..a1217fed86cc
@@ -0,0 +1,3 @@
+# Quotes error
+value = "data
+
tools/bootconfig/samples/escaped.bconf new file +3 -0
new file mode 100644
index 000000000000..9f72043b3216
@@ -0,0 +1,3 @@
+key1 = "A\B\C"
+key2 = '\'\''
+key3 = "\\"
tools/bootconfig/samples/good-array-space-comment.bconf new file +4 -0
new file mode 100644
index 000000000000..45b938dc0695
@@ -0,0 +1,4 @@
+key =	# comment
+	"value1",	  # comment1
+	"value2"	 , # comment2
+	"value3"
tools/bootconfig/samples/good-comment-after-value.bconf new file +1 -0
new file mode 100644
index 000000000000..0d92a853df72
@@ -0,0 +1 @@
+key = "value"  # comment
tools/bootconfig/samples/good-printables.bconf new file +2 -0
new file mode 100644
index 000000000000..ebb985a66ed8
@@ -0,0 +1,2 @@
+key = "	
+ !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
tools/bootconfig/samples/good-simple.bconf new file +11 -0
new file mode 100644
index 000000000000..37dd6d21c176
@@ -0,0 +1,11 @@
+# A good simple bootconfig
+
+key.word1 = 1
+key.word2=2
+key.word3 = 3;
+
+key {
+word4 = 4 }
+
+key { word5 = 5; word6 = 6 }
+
tools/bootconfig/samples/good-single.bconf new file +4 -0
new file mode 100644
index 000000000000..98e55ad8b711
@@ -0,0 +1,4 @@
+# single key style
+key = 1
+key2 = 2
+key3 = "alpha", "beta"
tools/bootconfig/samples/good-space-after-value.bconf new file +1 -0
new file mode 100644
index 000000000000..56c15cbc5741
@@ -0,0 +1 @@
+key = "value"   
tools/bootconfig/samples/good-tree.bconf new file +12 -0
new file mode 100644
index 000000000000..f2ddefc8b52a
@@ -0,0 +1,12 @@
+key {
+  word {
+    tree {
+      value = "0"}
+  }
+  word2 {
+    tree {
+      value = 1,2 }
+  }
+}
+other.tree {
+  value = 2; value2 = 3;}
tools/bootconfig/test-bootconfig.sh new file +105 -0

105 lines not on this page · raw message

Signature · 1 line
2.24.1
author maintainer
#45 lore raw

PATCH 8/26 proc: bootconfig: Add /proc/bootconfig to show boot config list

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add /proc/bootconfig which shows the list of key-value pairs in boot config. Since after boot, all boot configs and tree are removed, this interface just keep a copy of key-value pairs in text.

---
 MAINTAINERS          |  1 +
 fs/proc/Makefile     |  1 +
 fs/proc/bootconfig.c | 89 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)
 create mode 100644 fs/proc/bootconfig.c
MAINTAINERS +1 -0
index 06005006de7c..903e8a7ed0bf 100644
@@ -15774,6 +15774,7 @@ EXTRA BOOT CONFIG
 M:	Masami Hiramatsu <[email protected]>
 S:	Maintained
 F:	lib/bootconfig.c
+F:	fs/proc/bootconfig.c
 F:	include/linux/bootconfig.h
 F:	tools/bootconfig/*
 
fs/proc/Makefile +1 -0
index ead487e80510..bd08616ed8ba 100644
@@ -33,3 +33,4 @@ proc-$(CONFIG_PROC_KCORE)	+= kcore.o
 proc-$(CONFIG_PROC_VMCORE)	+= vmcore.o
 proc-$(CONFIG_PRINTK)	+= kmsg.o
 proc-$(CONFIG_PROC_PAGE_MONITOR)	+= page.o
+proc-$(CONFIG_BOOT_CONFIG)	+= bootconfig.o
fs/proc/bootconfig.c new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
2.24.1
author maintainer
#46 lore raw

PATCH 9/26 init/main.c: Alloc initcall_command_line in do_initcall() and free it

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Since initcall_command_line is used as a temporary buffer, it could be freed after usage. Allocate it in do_initcall() and free it after used.

---
 init/main.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
init/main.c +15 -11
index 59c418a57f92..0b4e0c8ccf16 100644
@@ -137,8 +137,6 @@ char __initdata boot_command_line[COMMAND_LINE_SIZE];
 char *saved_command_line;
 /* Command line for parameter parsing */
 static char *static_command_line;
-/* Command line for per-initcall parameter parsing */
-static char *initcall_command_line;
 
 static char *execute_command;
 static char *ramdisk_execute_command;
@@ -433,10 +431,6 @@ static void __init setup_command_line(char *command_line)
 	if (!saved_command_line)
 		panic("%s: Failed to allocate %zu bytes\n", __func__, len);
 
-	initcall_command_line =	memblock_alloc(len, SMP_CACHE_BYTES);
-	if (!initcall_command_line)
-		panic("%s: Failed to allocate %zu bytes\n", __func__, len);
-
 	static_command_line = memblock_alloc(len, SMP_CACHE_BYTES);
 	if (!static_command_line)
 		panic("%s: Failed to allocate %zu bytes\n", __func__, len);
@@ -1044,13 +1038,12 @@ static const char *initcall_level_names[] __initdata = {
 	"late",
 };
 
-static void __init do_initcall_level(int level)
+static void __init do_initcall_level(int level, char *command_line)
 {
 	initcall_entry_t *fn;
 
-	strcpy(initcall_command_line, saved_command_line);
 	parse_args(initcall_level_names[level],
-		   initcall_command_line, __start___param,
+		   command_line, __start___param,
 		   __stop___param - __start___param,
 		   level, level,
 		   NULL, &repair_env_string);
@@ -1063,9 +1056,20 @@ static void __init do_initcall_level(int level)
 static void __init do_initcalls(void)
 {
 	int level;
+	size_t len = strlen(saved_command_line) + 1;
+	char *command_line;
+
+	command_line = kzalloc(len, GFP_KERNEL);
+	if (!command_line)
+		panic("%s: Failed to allocate %zu bytes\n", __func__, len);
+
+	for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++) {
+		/* Parser modifies command_line, restore it each time */
+		strcpy(command_line, saved_command_line);
+		do_initcall_level(level, command_line);
+	}
 
-	for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++)
-		do_initcall_level(level);
+	kfree(command_line);
 }
 
 /*
Signature · 1 line
2.24.1
author maintainer
#47 lore raw

PATCH 10/26 bootconfig: init: Allow admin to use bootconfig for kernel command line

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Since the current kernel command line is too short to describe many options which supported by kernel, allow user to use boot config to setup (add) the command line options.

All kernel parameters under "kernel." keywords will be used for setting up extra kernel command line.

For example,

kernel {
audit = on
audit_backlog_limit = 256
}

Note that you can not specify some early parameters (like console etc.) by this method, since it is loaded after early parameters parsed.

---
 init/main.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 101 insertions(+), 5 deletions(-)
init/main.c +101 -5
index 0b4e0c8ccf16..c0017d9d16e7 100644
@@ -137,6 +137,8 @@ char __initdata boot_command_line[COMMAND_LINE_SIZE];
 char *saved_command_line;
 /* Command line for parameter parsing */
 static char *static_command_line;
+/* Untouched extra command line */
+static char *extra_command_line;
 
 static char *execute_command;
 static char *ramdisk_execute_command;
@@ -245,6 +247,83 @@ static int __init loglevel(char *str)
 early_param("loglevel", loglevel);
 
 #ifdef CONFIG_BOOT_CONFIG
+
+char xbc_namebuf[XBC_KEYLEN_MAX] __initdata;
+
+#define rest(dst, end) ((end) > (dst) ? (end) - (dst) : 0)
+
+static int __init xbc_snprint_cmdline(char *buf, size_t size,
+				      struct xbc_node *root)
+{
+	struct xbc_node *knode, *vnode;
+	char *end = buf + size;
+	char c = '\"';
+	const char *val;
+	int ret;
+
+	xbc_node_for_each_key_value(root, knode, val) {
+		ret = xbc_node_compose_key_after(root, knode,
+					xbc_namebuf, XBC_KEYLEN_MAX);
+		if (ret < 0)
+			return ret;
+
+		vnode = xbc_node_get_child(knode);
+		ret = snprintf(buf, rest(buf, end), "%s%c", xbc_namebuf,
+				vnode ? '=' : ' ');
+		if (ret < 0)
+			return ret;
+		buf += ret;
+		if (!vnode)
+			continue;
+
+		c = '\"';
+		xbc_array_for_each_value(vnode, val) {
+			ret = snprintf(buf, rest(buf, end), "%c%s", c, val);
+			if (ret < 0)
+				return ret;
+			buf += ret;
+			c = ',';
+		}
+		if (rest(buf, end) > 2)
+			strcpy(buf, "\" ");
+		buf += 2;
+	}
+
+	return buf - (end - size);
+}
+#undef rest
+
+/* Make an extra command line under given key word */
+static char * __init xbc_make_cmdline(const char *key)
+{
+	struct xbc_node *root;
+	char *new_cmdline;
+	int ret, len = 0;
+
+	root = xbc_find_node(key);
+	if (!root)
+		return NULL;
+
+	/* Count required buffer size */
+	len = xbc_snprint_cmdline(NULL, 0, root);
+	if (len <= 0)
+		return NULL;
+
+	new_cmdline = memblock_alloc(len + 1, SMP_CACHE_BYTES);
+	if (!new_cmdline) {
+		pr_err("Failed to allocate memory for extra kernel cmdline.\n");
+		return NULL;
+	}
+
+	ret = xbc_snprint_cmdline(new_cmdline, len + 1, root);
+	if (ret < 0 || ret > len) {
+		pr_err("Failed to print extra kernel cmdline.\n");
+		return NULL;
+	}
+
+	return new_cmdline;
+}
+
 u32 boot_config_checksum(unsigned char *p, u32 size)
 {
 	u32 ret = 0;
@@ -289,8 +368,11 @@ static void __init setup_boot_config(void)
 
 	if (xbc_init(copy) < 0)
 		pr_err("Failed to parse boot config\n");
-	else
+	else {
 		pr_info("Load boot config: %d bytes\n", size);
+		/* keys starting with "kernel." are passed via cmdline */
+		extra_command_line = xbc_make_cmdline("kernel");
+	}
 }
 #else
 #define setup_boot_config()	do { } while (0)
@@ -425,7 +507,12 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }
  */
 static void __init setup_command_line(char *command_line)
 {
-	size_t len = strlen(boot_command_line) + 1;
+	size_t len, xlen = 0;
+
+	if (extra_command_line)
+		xlen = strlen(extra_command_line);
+
+	len = xlen + strlen(boot_command_line) + 1;
 
 	saved_command_line = memblock_alloc(len, SMP_CACHE_BYTES);
 	if (!saved_command_line)
@@ -435,8 +522,17 @@ static void __init setup_command_line(char *command_line)
 	if (!static_command_line)
 		panic("%s: Failed to allocate %zu bytes\n", __func__, len);
 
-	strcpy(saved_command_line, boot_command_line);
-	strcpy(static_command_line, command_line);
+	if (xlen) {
+		/*
+		 * We have to put extra_command_line before boot command
+		 * lines because there could be dashes (separator of init
+		 * command line) in the command lines.
+		 */
+		strcpy(saved_command_line, extra_command_line);
+		strcpy(static_command_line, extra_command_line);
+	}
+	strcpy(saved_command_line + xlen, boot_command_line);
+	strcpy(static_command_line + xlen, command_line);
 }
 
 /*
@@ -652,7 +748,7 @@ asmlinkage __visible void __init start_kernel(void)
 	build_all_zonelists(NULL);
 	page_alloc_init();
 
-	pr_notice("Kernel command line: %s\n", boot_command_line);
+	pr_notice("Kernel command line: %s\n", saved_command_line);
 	/* parameters may set static keys */
 	jump_label_init();
 	parse_early_param();
Signature · 1 line
2.24.1
author maintainer
#48 lore raw

PATCH 11/26 bootconfig: init: Allow admin to use bootconfig for init command line

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Since the current kernel command line is too short to describe long and many options for init (e.g. systemd command line options), this allows admin to use boot config for init command line.

All init command line under "init." keywords will be passed to init.

For example,

init.systemd {
unified_cgroup_hierarchy = 1
debug_shell
default_timeout_start_sec = 60
}

---
 init/main.c | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)
init/main.c +28 -3
index c0017d9d16e7..dd7da62d99a5 100644
@@ -139,6 +139,8 @@ char *saved_command_line;
 static char *static_command_line;
 /* Untouched extra command line */
 static char *extra_command_line;
+/* Extra init arguments */
+static char *extra_init_args;
 
 static char *execute_command;
 static char *ramdisk_execute_command;
@@ -372,6 +374,8 @@ static void __init setup_boot_config(void)
 		pr_info("Load boot config: %d bytes\n", size);
 		/* keys starting with "kernel." are passed via cmdline */
 		extra_command_line = xbc_make_cmdline("kernel");
+		/* Also, "init." keys are init arguments */
+		extra_init_args = xbc_make_cmdline("init");
 	}
 }
 #else
@@ -507,16 +511,18 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }
  */
 static void __init setup_command_line(char *command_line)
 {
-	size_t len, xlen = 0;
+	size_t len, xlen = 0, ilen = 0;
 
 	if (extra_command_line)
 		xlen = strlen(extra_command_line);
+	if (extra_init_args)
+		ilen = strlen(extra_init_args) + 4; /* for " -- " */
 
 	len = xlen + strlen(boot_command_line) + 1;
 
-	saved_command_line = memblock_alloc(len, SMP_CACHE_BYTES);
+	saved_command_line = memblock_alloc(len + ilen, SMP_CACHE_BYTES);
 	if (!saved_command_line)
-		panic("%s: Failed to allocate %zu bytes\n", __func__, len);
+		panic("%s: Failed to allocate %zu bytes\n", __func__, len + ilen);
 
 	static_command_line = memblock_alloc(len, SMP_CACHE_BYTES);
 	if (!static_command_line)
@@ -533,6 +539,22 @@ static void __init setup_command_line(char *command_line)
 	}
 	strcpy(saved_command_line + xlen, boot_command_line);
 	strcpy(static_command_line + xlen, command_line);
+
+	if (ilen) {
+		/*
+		 * Append supplemental init boot args to saved_command_line
+		 * so that user can check what command line options passed
+		 * to init.
+		 */
+		len = strlen(saved_command_line);
+		if (!strstr(boot_command_line, " -- ")) {
+			strcpy(saved_command_line + len, " -- ");
+			len += 4;
+		} else
+			saved_command_line[len++] = ' ';
+
+		strcpy(saved_command_line + len, extra_init_args);
+	}
 }
 
 /*
@@ -759,6 +781,9 @@ asmlinkage __visible void __init start_kernel(void)
 	if (!IS_ERR_OR_NULL(after_dashes))
 		parse_args("Setting init args", after_dashes, NULL, 0, -1, -1,
 			   NULL, set_init_arg);
+	if (extra_init_args)
+		parse_args("Setting extra init args", extra_init_args,
+			   NULL, 0, -1, -1, NULL, set_init_arg);
 
 	/*
 	 * These use large bootmem allocations and must precede
Signature · 1 line
2.24.1
author maintainer
#49 lore raw

PATCH 12/26 Documentation: bootconfig: Add a doc for extended boot config

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add a documentation for extended boot config under admin-guide, since it is including the syntax of boot config.

---
 Documentation/admin-guide/bootconfig.rst | 184 +++++++++++++++++++++++
 Documentation/admin-guide/index.rst      |   1 +
 MAINTAINERS                              |   1 +
 3 files changed, 186 insertions(+)
 create mode 100644 Documentation/admin-guide/bootconfig.rst
Documentation/admin-guide/bootconfig.rst new file +184 -0
new file mode 100644
index 000000000000..f7475df2a718
@@ -0,0 +1,184 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+==================
+Boot Configuration
+==================
+
+:Author: Masami Hiramatsu <[email protected]>
+
+Overview
+========
+
+The boot configuration is expanding current kernel cmdline to support
+additional key-value data when boot the kernel in an efficient way.
+This allows adoministrators to pass a structured-Key config file.
+
+Config File Syntax
+==================
+
+The boot config syntax is a simple structured key-value. Each key consists
+of dot-connected-words, and key and value are connected by "=". The value
+has to be terminated by semi-colon (``;``) or newline (``\n``).
+For array value, array entries are separated by comma (``,``). ::
+
+KEY[.WORD[...]] = VALUE[, VALUE2[...]][;]
+
+Each key word must contain only alphabets, numbers, dash (``-``) or underscore
+(``_``). And each value only contains printable characters or spaces except
+for delimiters such as semi-colon (``;``), new-line (``\n``), comma (``,``),
+hash (``#``) and closing brace (``}``).
+
+If you want to use those delimiters in a value, you can use either double-
+quotes (``"VALUE"``) or single-quotes (``'VALUE'``) to quote it. Note that
+you can not escape these quotes.
+
+There can be a key which doesn't have value or has an empty value. Those keys
+are used for checking the key exists or not (like a boolean).
+
+Key-Value Syntax
+----------------
+
+The boot config file syntax allows user to merge partially same word keys
+by brace. For example::
+
+ foo.bar.baz = value1
+ foo.bar.qux.quux = value2
+
+These can be written also in::
+
+ foo.bar {
+    baz = value1
+    qux.quux = value2
+ }
+
+Or more shorter, written as following::
+
+ foo.bar { baz = value1; qux.quux = value2 }
+
+In both styles, same key words are automatically merged when parsing it
+at boot time. So you can append similar trees or key-values.
+
+Comments
+--------
+
+The config syntax accepts shell-script style comments. The comments start
+with hash ("#") until newline ("\n") will be ignored.
+
+::
+
+ # comment line
+ foo = value # value is set to foo.
+ bar = 1, # 1st element
+       2, # 2nd element
+       3  # 3rd element
+
+This is parsed as below::
+
+ foo = value
+ bar = 1, 2, 3
+
+Note that you can not put a comment between value and delimiter(``,`` or
+``;``). This means following config has a syntax error ::
+
+ key = 1 # comment
+       ,2
+
+
+/proc/bootconfig
+================
+
+/proc/bootconfig is a user-space interface of the boot config.
+Unlike /proc/cmdline, this file shows the key-value style list.
+Each key-value pair is shown in each line with following style::
+
+ KEY[.WORDS...] = "[VALUE]"[,"VALUE2"...]
+
+
+Boot Kernel With a Boot Config
+==============================
+
+Since the boot configuration file is loaded with initrd, it will be added
+to the end of the initrd (initramfs) image file. The Linux kernel decodes
+the last part of the initrd image in memory to get the boot configuration
+data.
+Because of this "piggyback" method, there is no need to change or
+update the boot loader and the kernel image itself.
+
+To do this operation, Linux kernel provides "bootconfig" command under
+tools/bootconfig, which allows admin to apply or delete the config file
+to/from initrd image. You can build it by follwoing command::
+
+ # make -C tools/bootconfig
+
+To add your boot config file to initrd image, run bootconfig as below
+(Old data is removed automatically if exists)::
+
+ # tools/bootconfig/bootconfig -a your-config /boot/initrd.img-X.Y.Z
+
+To remove the config from the image, you can use -d option as below::
+
+ # tools/bootconfig/bootconfig -d /boot/initrd.img-X.Y.Z
+
+
+C onfig File Limitation
+======================
+
+Currently the maximum config size size is 32KB and the total key-words (not
+key-value entries) must be under 1024 nodes.
+Note: this is not the number of entries but nodes, an entry must consume
+more than 2 nodes (a key-word and a value). So theoretically, it will be
+up to 512 key-value pairs. If keys contains 3 words in average, it can
+contain 256 key-value pairs. In most cases, the number of config items
+will be under 100 entries and smaller than 8KB, so it would be enough.
+If the node number exceeds 1024, parser returns an error even if the file
+size is smaller than 32KB.
+Anyway, since bootconfig command verifies it when appending a boot config
+to initrd image, user can notice it before boot.
+
+
+Bootconfig APIs
+===============
+
+User can query or loop on key-value pairs, also it is possible to find
+a root (prefix) key node and find key-values under that node.
+
+If you have a key string, you can query the value directly with the key
+using xbc_find_value(). If you want to know what keys exist in the SKC
+tree, you can use xbc_for_each_key_value() to iterate key-value pairs.
+Note that you need to use xbc_array_for_each_value() for accessing
+each arraies value, e.g.::
+
+ vnode = NULL;
+ xbc_find_value("key.word", &vnode);
+ if (vnode && xbc_node_is_array(vnode))
+    xbc_array_for_each_value(vnode, value) {
+      printk("%s ", value);
+    }
+
+If you want to focus on keys which has a prefix string, you can use
+xbc_find_node() to find a node which prefix key words, and iterate
+keys under the prefix node with xbc_node_for_each_key_value().
+
+But the most typical usage is to get the named value under prefix
+or get the named array under prefix as below::
+
+ root = xbc_find_node("key.prefix");
+ value = xbc_node_find_value(root, "option", &vnode);
+ ...
+ xbc_node_for_each_array_value(root, "array-option", value, anode) {
+    ...
+ }
+
+This accesses a value of "key.prefix.option" and an array of
+"key.prefix.array-option".
+
+Locking is not needed, since after initialized, the config becomes readonly.
+All data and keys must be copied if you need to modify it.
+
+
+Functions and structures
+========================
+
+.. kernel-doc:: include/linux/bootconfig.h
+.. kernel-doc:: lib/bootconfig.c
+
Documentation/admin-guide/index.rst +1 -0
index 4405b7485312..9e0f1e3fd152 100644
@@ -64,6 +64,7 @@ configure specific aspects of kernel behavior to your liking.
    binderfs
    binfmt-misc
    blockdev/index
+   bootconfig
    braille-console
    btmrvl
    cgroup-v1/index
MAINTAINERS +1 -0
index 903e8a7ed0bf..47873f2e6696 100644
@@ -15777,6 +15777,7 @@ F:	lib/bootconfig.c
 F:	fs/proc/bootconfig.c
 F:	include/linux/bootconfig.h
 F:	tools/bootconfig/*
+F:	Documentation/admin-guide/bootconfig.rst
 
 SUN3/3X
 M:	Sam Creasey <[email protected]>
Signature · 1 line
2.24.1
author maintainer
#50 lore raw

PATCH 13/26 tracing: Apply soft-disabled and filter to tracepoints printk

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Apply soft-disabled and the filter rule of the trace events to the printk output of tracepoints (a.k.a. tp_printk kernel parameter) as same as trace buffer output.

---
 kernel/trace/trace.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/trace/trace.c +7 -0
index b4a07d7ed82a..b4294eb020f8 100644
@@ -2610,6 +2610,7 @@ static DEFINE_MUTEX(tracepoint_printk_mutex);
 static void output_printk(struct trace_event_buffer *fbuffer)
 {
 	struct trace_event_call *event_call;
+	struct trace_event_file *file;
 	struct trace_event *event;
 	unsigned long flags;
 	struct trace_iterator *iter = tracepoint_print_iter;
@@ -2623,6 +2624,12 @@ static void output_printk(struct trace_event_buffer *fbuffer)
 	    !event_call->event.funcs->trace)
 		return;
 
+	file = fbuffer->trace_file;
+	if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags) ||
+	    (unlikely(file->flags & EVENT_FILE_FL_FILTERED) &&
+	     !filter_match_preds(file->filter, fbuffer->entry)))
+		return;
+
 	event = &fbuffer->trace_file->event_call->event;
 
 	spin_lock_irqsave(&tracepoint_iter_lock, flags);
Signature · 1 line
2.24.1
author maintainer
#51 lore raw

PATCH 14/26 tracing: kprobes: Output kprobe event to printk buffer

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Since kprobe-events use event_trigger_unlock_commit_regs() directly, that events doesn't show up in printk buffer if "tp_printk" is set.

Use trace_event_buffer_commit() in kprobe events so that it can invoke output_printk() as same as other trace events.

[ Adjusted data var declaration placement in __kretprobe_trace_func() ]
---
 include/linux/trace_events.h |  1 +
 kernel/trace/trace.c         |  4 +--
 kernel/trace/trace_events.c  |  1 +
 kernel/trace/trace_kprobe.c  | 57 ++++++++++++++++++------------------
 4 files changed, 32 insertions(+), 31 deletions(-)
include/linux/trace_events.h +1 -0
index 5f7b2b1fce24..20948ee56f8c 100644
@@ -216,6 +216,7 @@ struct trace_event_buffer {
 	void				*entry;
 	unsigned long			flags;
 	int				pc;
+	struct pt_regs			*regs;
 };
 
 void *trace_event_buffer_reserve(struct trace_event_buffer *fbuffer,
kernel/trace/trace.c +2 -2
index b4294eb020f8..cb850d2c4bfa 100644
@@ -2680,9 +2680,9 @@ void trace_event_buffer_commit(struct trace_event_buffer *fbuffer)
 	if (static_key_false(&tracepoint_printk_key.key))
 		output_printk(fbuffer);
 
-	event_trigger_unlock_commit(fbuffer->trace_file, fbuffer->buffer,
+	event_trigger_unlock_commit_regs(fbuffer->trace_file, fbuffer->buffer,
 				    fbuffer->event, fbuffer->entry,
-				    fbuffer->flags, fbuffer->pc);
+				    fbuffer->flags, fbuffer->pc, fbuffer->regs);
 }
 EXPORT_SYMBOL_GPL(trace_event_buffer_commit);
 
kernel/trace/trace_events.c +1 -0
index a16d1b601c5c..dfb736a964d6 100644
@@ -272,6 +272,7 @@ void *trace_event_buffer_reserve(struct trace_event_buffer *fbuffer,
 	if (!fbuffer->event)
 		return NULL;
 
+	fbuffer->regs = NULL;
 	fbuffer->entry = ring_buffer_event_data(fbuffer->event);
 	return fbuffer->entry;
 }
kernel/trace/trace_kprobe.c +28 -29

99 lines not on this page · raw message

Signature · 1 line
2.24.1
author maintainer
#52 lore raw

PATCH 15/26 tracing: kprobes: Register to dynevent earlier stage

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Register kprobe event to dynevent in subsys_initcall level. This will allow kernel to register new kprobe events in fs_initcall level via trace_run_command.

---
 kernel/trace/trace_kprobe.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
kernel/trace/trace_kprobe.c +15 -4
index 33a6a661904b..8113d6aa7bc5 100644
@@ -1685,11 +1685,12 @@ static __init void setup_boot_kprobe_events(void)
 	enable_boot_kprobe_events();
 }
 
-/* Make a tracefs interface for controlling probe points */
-static __init int init_kprobe_trace(void)
+/*
+ * Register dynevent at subsys_initcall. This allows kernel to setup kprobe
+ * events in fs_initcall without tracefs.
+ */
+static __init int init_kprobe_trace_early(void)
 {
-	struct dentry *d_tracer;
-	struct dentry *entry;
 	int ret;
 
 	ret = dyn_event_register(&trace_kprobe_ops);
@@ -1699,6 +1700,16 @@ static __init int init_kprobe_trace(void)
 	if (register_module_notifier(&trace_kprobe_module_nb))
 		return -EINVAL;
 
+	return 0;
+}
+subsys_initcall(init_kprobe_trace_early);
+
+/* Make a tracefs interface for controlling probe points */
+static __init int init_kprobe_trace(void)
+{
+	struct dentry *d_tracer;
+	struct dentry *entry;
+
 	d_tracer = tracing_init_dentry();
 	if (IS_ERR(d_tracer))
 		return 0;
Signature · 1 line
2.24.1
author maintainer
#53 lore raw

PATCH 16/26 tracing: Accept different type for synthetic event fields

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Make the synthetic event accepts a different type field to record. However, the size and signed flag must be same.

---
 kernel/trace/trace_events_hist.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
kernel/trace/trace_events_hist.c +5 -2
index 0454abaeb486..4f4759c6e972 100644
@@ -4110,8 +4110,11 @@ static int check_synth_field(struct synth_event *event,
 
 	field = event->fields[field_pos];
 
-	if (strcmp(field->type, hist_field->type) != 0)
-		return -EINVAL;
+	if (strcmp(field->type, hist_field->type) != 0) {
+		if (field->size != hist_field->size ||
+		    field->is_signed != hist_field->is_signed)
+			return -EINVAL;
+	}
 
 	return 0;
 }
Signature · 1 line
2.24.1
author maintainer
#54 lore raw

PATCH 17/26 tracing: Add NULL trace-array check in print_synth_event()

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add NULL trace-array check in print_synth_event(), because if we enable tp_printk option, iter->tr can be NULL.

---
 kernel/trace/trace_events_hist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +1 -1
index 4f4759c6e972..1cb4c4c8e5b7 100644
@@ -833,7 +833,7 @@ static enum print_line_t print_synth_event(struct trace_iterator *iter,
 		fmt = synth_field_fmt(se->fields[i]->type);
 
 		/* parameter types */
-		if (tr->trace_flags & TRACE_ITER_VERBOSE)
+		if (tr && tr->trace_flags & TRACE_ITER_VERBOSE)
 			trace_seq_printf(s, "%s ", fmt);
 
 		snprintf(print_fmt, sizeof(print_fmt), "%%s=%s%%s", fmt);
Signature · 1 line
2.24.1
author maintainer
#55 lore raw

PATCH 18/26 tracing/boot: Add boot-time tracing

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Setup tracing options via extra boot config in addition to kernel command line.

This adds following commands support. These are applied to the global trace instance.

- ftrace.options = OPT1[,OPT2...]
Enable given ftrace options.

- ftrace.trace_clock = CLOCK
Set given CLOCK to ftrace's trace_clock.

- ftrace.buffer_size = SIZE
Configure ftrace buffer size to SIZE. You can use "KB" or "MB" for that SIZE.

- ftrace.events = EVENT[, EVENT2...]
Enable given events on boot. You can use a wild card in EVENT.

- ftrace.tracer = TRACER
Set TRACER to current tracer on boot. (e.g. function)

Note that this is NOT replacing the kernel parameters, because this boot config based setting is later than that. If you want to trace earlier boot events, you still need kernel parameters.

---
 kernel/trace/Kconfig      |   9 +++
 kernel/trace/Makefile     |   1 +
 kernel/trace/trace.c      |  10 ++--
 kernel/trace/trace_boot.c | 113 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 128 insertions(+), 5 deletions(-)
 create mode 100644 kernel/trace/trace_boot.c
kernel/trace/Kconfig +9 -0
index 25a0fcfa7a5d..75326d8ab1af 100644
@@ -814,6 +814,15 @@ config GCOV_PROFILE_FTRACE
 	  Note that on a kernel compiled with this config, ftrace will
 	  run significantly slower.
 
+config BOOTTIME_TRACING
+	bool "Boot-time Tracing support"
+	depends on BOOT_CONFIG && TRACING
+	default y
+	help
+	  Enable developer to setup ftrace subsystem via supplemental
+	  kernel cmdline at boot time for debugging (tracing) driver
+	  initialization and boot process.
+
 endif # FTRACE
 
 endif # TRACING_SUPPORT
kernel/trace/Makefile +1 -0
index 0e63db62225f..395e2db9c742 100644
@@ -83,6 +83,7 @@ endif
 obj-$(CONFIG_DYNAMIC_EVENTS) += trace_dynevent.o
 obj-$(CONFIG_PROBE_EVENTS) += trace_probe.o
 obj-$(CONFIG_UPROBE_EVENTS) += trace_uprobe.o
+obj-$(CONFIG_BOOTTIME_TRACING) += trace_boot.o
 
 obj-$(CONFIG_TRACEPOINT_BENCHMARK) += trace_benchmark.o
 
kernel/trace/trace.c +5 -5
index cb850d2c4bfa..6c996d1b1687 100644
@@ -162,7 +162,7 @@ union trace_eval_map_item {
 static union trace_eval_map_item *trace_eval_maps;
 #endif /* CONFIG_TRACE_EVAL_MAP_FILE */
 
-static int tracing_set_tracer(struct trace_array *tr, const char *buf);
+int tracing_set_tracer(struct trace_array *tr, const char *buf);
 static void ftrace_trace_userstack(struct trace_buffer *buffer,
 				   unsigned long flags, int pc);
 
@@ -4747,7 +4747,7 @@ int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
 	return 0;
 }
 
-static int trace_set_options(struct trace_array *tr, char *option)
+int trace_set_options(struct trace_array *tr, char *option)
 {
 	char *cmp;
 	int neg = 0;
@@ -5647,8 +5647,8 @@ static int __tracing_resize_ring_buffer(struct trace_array *tr,
 	return ret;
 }
 
-static ssize_t tracing_resize_ring_buffer(struct trace_array *tr,
-					  unsigned long size, int cpu_id)
+ssize_t tracing_resize_ring_buffer(struct trace_array *tr,
+				  unsigned long size, int cpu_id)
 {
 	int ret = size;
 
@@ -5727,7 +5727,7 @@ static void add_tracer_options(struct trace_array *tr, struct tracer *t)
 	create_trace_option_files(tr, t);
 }
 
-static int tracing_set_tracer(struct trace_array *tr, const char *buf)
+int tracing_set_tracer(struct trace_array *tr, const char *buf)
 {
 	struct tracer *t;
 #ifdef CONFIG_TRACER_MAX_TRACE
kernel/trace/trace_boot.c new file +113 -0

113 lines not on this page · raw message

Signature · 1 line
2.24.1
author maintainer
#56 lore raw

PATCH 19/26 tracing/boot: Add per-event settings

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add per-event settings for boottime tracing. User can set filter, actions and enable on each event on boot. The event entries are under ftrace.event.GROUP.EVENT node (note that the option key includes event's group name and event name.) This supports below configs.

- ftrace.event.GROUP.EVENT.enable
Enables GROUP:EVENT tracing.

- ftrace.event.GROUP.EVENT.filter = FILTER
Set FILTER rule to the GROUP:EVENT.

- ftrace.event.GROUP.EVENT.actions = ACTION[, ACTION2...] Set ACTIONs to the GROUP:EVENT.

For example,

  ftrace.event.sched.sched_process_exec {
                filter = "pid < 128"
		enable

}

this will enable tracing "sched:sched_process_exec" event with "pid < 128" filter.

---
 kernel/trace/trace_boot.c           | 60 +++++++++++++++++++++++++++++
 kernel/trace/trace_events_trigger.c |  2 +-
 2 files changed, 61 insertions(+), 1 deletion(-)
kernel/trace/trace_boot.c +60 -0
index 4b41310184df..37524031533e 100644
@@ -56,6 +56,7 @@ trace_boot_set_ftrace_options(struct trace_array *tr, struct xbc_node *node)
 
 #ifdef CONFIG_EVENT_TRACING
 extern int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set);
+extern int trigger_process_regex(struct trace_event_file *file, char *buff);
 
 static void __init
 trace_boot_enable_events(struct trace_array *tr, struct xbc_node *node)
@@ -74,8 +75,66 @@ trace_boot_enable_events(struct trace_array *tr, struct xbc_node *node)
 			pr_err("Failed to enable event: %s\n", p);
 	}
 }
+
+static void __init
+trace_boot_init_one_event(struct trace_array *tr, struct xbc_node *gnode,
+			  struct xbc_node *enode)
+{
+	struct trace_event_file *file;
+	struct xbc_node *anode;
+	char buf[MAX_BUF_LEN];
+	const char *p, *group, *event;
+
+	group = xbc_node_get_data(gnode);
+	event = xbc_node_get_data(enode);
+
+	mutex_lock(&event_mutex);
+	file = find_event_file(tr, group, event);
+	if (!file) {
+		pr_err("Failed to find event: %s:%s\n", group, event);
+		goto out;
+	}
+
+	p = xbc_node_find_value(enode, "filter", NULL);
+	if (p && *p != '\0') {
+		if (strlcpy(buf, p, ARRAY_SIZE(buf)) >= ARRAY_SIZE(buf))
+			pr_err("filter string is too long: %s\n", p);
+		else if (apply_event_filter(file, buf) < 0)
+			pr_err("Failed to apply filter: %s\n", buf);
+	}
+
+	xbc_node_for_each_array_value(enode, "actions", anode, p) {
+		if (strlcpy(buf, p, ARRAY_SIZE(buf)) >= ARRAY_SIZE(buf))
+			pr_err("action string is too long: %s\n", p);
+		else if (trigger_process_regex(file, buf) < 0)
+			pr_err("Failed to apply an action: %s\n", buf);
+	}
+
+	if (xbc_node_find_value(enode, "enable", NULL)) {
+		if (trace_event_enable_disable(file, 1, 0) < 0)
+			pr_err("Failed to enable event node: %s:%s\n",
+				group, event);
+	}
+out:
+	mutex_unlock(&event_mutex);
+}
+
+static void __init
+trace_boot_init_events(struct trace_array *tr, struct xbc_node *node)
+{
+	struct xbc_node *gnode, *enode;
+
+	node = xbc_node_find_child(node, "event");
+	if (!node)
+		return;
+	/* per-event key starts with "event.GROUP.EVENT" */
+	xbc_node_for_each_child(node, gnode)
+		xbc_node_for_each_child(gnode, enode)
+			trace_boot_init_one_event(tr, gnode, enode);
+}
 #else
 #define trace_boot_enable_events(tr, node) do {} while (0)
+#define trace_boot_init_events(tr, node) do {} while (0)
 #endif
 
 static void __init
@@ -104,6 +163,7 @@ static int __init trace_boot_init(void)
 		return 0;
 
 	trace_boot_set_ftrace_options(tr, trace_node);
+	trace_boot_init_events(tr, trace_node);
 	trace_boot_enable_events(tr, trace_node);
 	trace_boot_enable_tracer(tr, trace_node);
 
kernel/trace/trace_events_trigger.c +1 -1
index 2cd53ca21b51..d8ada4c6f3f7 100644
@@ -213,7 +213,7 @@ static int event_trigger_regex_open(struct inode *inode, struct file *file)
 	return ret;
 }
 
-static int trigger_process_regex(struct trace_event_file *file, char *buff)
+int trigger_process_regex(struct trace_event_file *file, char *buff)
 {
 	char *command, *next = buff;
 	struct event_command *p;
Signature · 1 line
2.24.1
author maintainer
#57 lore raw

PATCH 20/26 tracing/boot Add kprobe event support

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add kprobe event support on event node to boot-time tracing. If the group name of event is "kprobes", the boot-time tracing defines new probe event according to "probes" values.

- ftrace.event.kprobes.EVENT.probes = PROBE[, PROBE2...] Defines new kprobe event based on PROBEs. It is able to define multiple probes on one event, but those must have same type of arguments.

For example,

 ftrace.events.kprobes.myevent {
	probes = "vfs_read $arg1 $arg2";
	enable;

}

This will add kprobes:myevent on vfs_read with the 1st and the 2nd arguments.

---
 kernel/trace/trace_boot.c   | 46 +++++++++++++++++++++++++++++++++++++
 kernel/trace/trace_kprobe.c |  5 ++++
 2 files changed, 51 insertions(+)
kernel/trace/trace_boot.c +46 -0
index 37524031533e..a11dc60299fb 100644
@@ -76,6 +76,48 @@ trace_boot_enable_events(struct trace_array *tr, struct xbc_node *node)
 	}
 }
 
+#ifdef CONFIG_KPROBE_EVENTS
+extern int trace_kprobe_run_command(const char *command);
+
+static int __init
+trace_boot_add_kprobe_event(struct xbc_node *node, const char *event)
+{
+	struct xbc_node *anode;
+	char buf[MAX_BUF_LEN];
+	const char *val;
+	char *p;
+	int len;
+
+	len = snprintf(buf, ARRAY_SIZE(buf) - 1, "p:kprobes/%s ", event);
+	if (len >= ARRAY_SIZE(buf)) {
+		pr_err("Event name is too long: %s\n", event);
+		return -E2BIG;
+	}
+	p = buf + len;
+	len = ARRAY_SIZE(buf) - len;
+
+	xbc_node_for_each_array_value(node, "probes", anode, val) {
+		if (strlcpy(p, val, len) >= len) {
+			pr_err("Probe definition is too long: %s\n", val);
+			return -E2BIG;
+		}
+		if (trace_kprobe_run_command(buf) < 0) {
+			pr_err("Failed to add probe: %s\n", buf);
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+#else
+static inline int __init
+trace_boot_add_kprobe_event(struct xbc_node *node, const char *event)
+{
+	pr_err("Kprobe event is not supported.\n");
+	return -ENOTSUPP;
+}
+#endif
+
 static void __init
 trace_boot_init_one_event(struct trace_array *tr, struct xbc_node *gnode,
 			  struct xbc_node *enode)
@@ -88,6 +130,10 @@ trace_boot_init_one_event(struct trace_array *tr, struct xbc_node *gnode,
 	group = xbc_node_get_data(gnode);
 	event = xbc_node_get_data(enode);
 
+	if (!strcmp(group, "kprobes"))
+		if (trace_boot_add_kprobe_event(enode, event) < 0)
+			return;
+
 	mutex_lock(&event_mutex);
 	file = find_event_file(tr, group, event);
 	if (!file) {
kernel/trace/trace_kprobe.c +5 -0
index 8113d6aa7bc5..283b7c437440 100644
@@ -902,6 +902,11 @@ static int create_or_delete_trace_kprobe(int argc, char **argv)
 	return ret == -ECANCELED ? -EINVAL : ret;
 }
 
+int trace_kprobe_run_command(const char *command)
+{
+	return trace_run_command(command, create_or_delete_trace_kprobe);
+}
+
 static int trace_kprobe_release(struct dyn_event *ev)
 {
 	struct trace_kprobe *tk = to_trace_kprobe(ev);
Signature · 1 line
2.24.1
author maintainer
#58 lore raw

PATCH 21/26 tracing/boot: Add synthetic event support

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add synthetic event node support to boot time tracing. The synthetic event is a kind of event node, but the group name is "synthetic".

- ftrace.event.synthetic.EVENT.fields = FIELD[, FIELD2...] Defines new synthetic event with FIELDs. Each field should be "type varname".

The synthetic node requires "fields" string arraies, which defines the fields as same as tracing/synth_events interface.

---
 kernel/trace/trace_boot.c        | 47 ++++++++++++++++++++++++++++++++
 kernel/trace/trace_events_hist.c |  5 ++++
 2 files changed, 52 insertions(+)
kernel/trace/trace_boot.c +47 -0
index a11dc60299fb..3054921b0877 100644
@@ -118,6 +118,50 @@ trace_boot_add_kprobe_event(struct xbc_node *node, const char *event)
 }
 #endif
 
+#ifdef CONFIG_HIST_TRIGGERS
+extern int synth_event_run_command(const char *command);
+
+static int __init
+trace_boot_add_synth_event(struct xbc_node *node, const char *event)
+{
+	struct xbc_node *anode;
+	char buf[MAX_BUF_LEN], *q;
+	const char *p;
+	int len, delta, ret;
+
+	len = ARRAY_SIZE(buf);
+	delta = snprintf(buf, len, "%s", event);
+	if (delta >= len) {
+		pr_err("Event name is too long: %s\n", event);
+		return -E2BIG;
+	}
+	len -= delta; q = buf + delta;
+
+	xbc_node_for_each_array_value(node, "fields", anode, p) {
+		delta = snprintf(q, len, " %s;", p);
+		if (delta >= len) {
+			pr_err("fields string is too long: %s\n", p);
+			return -E2BIG;
+		}
+		len -= delta; q += delta;
+	}
+
+	ret = synth_event_run_command(buf);
+	if (ret < 0)
+		pr_err("Failed to add synthetic event: %s\n", buf);
+
+
+	return ret;
+}
+#else
+static inline int __init
+trace_boot_add_synth_event(struct xbc_node *node, const char *event)
+{
+	pr_err("Synthetic event is not supported.\n");
+	return -ENOTSUPP;
+}
+#endif
+
 static void __init
 trace_boot_init_one_event(struct trace_array *tr, struct xbc_node *gnode,
 			  struct xbc_node *enode)
@@ -133,6 +177,9 @@ trace_boot_init_one_event(struct trace_array *tr, struct xbc_node *gnode,
 	if (!strcmp(group, "kprobes"))
 		if (trace_boot_add_kprobe_event(enode, event) < 0)
 			return;
+	if (!strcmp(group, "synthetic"))
+		if (trace_boot_add_synth_event(enode, event) < 0)
+			return;
 
 	mutex_lock(&event_mutex);
 	file = find_event_file(tr, group, event);
kernel/trace/trace_events_hist.c +5 -0
index 1cb4c4c8e5b7..8e90f1ada437 100644
@@ -1384,6 +1384,11 @@ static int create_or_delete_synth_event(int argc, char **argv)
 	return ret == -ECANCELED ? -EINVAL : ret;
 }
 
+int synth_event_run_command(const char *command)
+{
+	return trace_run_command(command, create_or_delete_synth_event);
+}
+
 static int synth_event_create(int argc, const char **argv)
 {
 	const char *name = argv[0];
Signature · 1 line
2.24.1
author maintainer
#59 lore raw

PATCH 22/26 tracing/boot: Add instance node support

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add instance node support to boot-time tracing. User can set some options and event nodes under instance node.

- ftrace.instance.INSTANCE[...]
Add new INSTANCE instance. Some options and event nodes are acceptable for instance node.

---
 kernel/trace/trace_boot.c | 43 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 38 insertions(+), 5 deletions(-)
kernel/trace/trace_boot.c +38 -5
index 3054921b0877..f5db30d25b0b 100644
@@ -20,7 +20,7 @@ extern ssize_t tracing_resize_ring_buffer(struct trace_array *tr,
 					  unsigned long size, int cpu_id);
 
 static void __init
-trace_boot_set_ftrace_options(struct trace_array *tr, struct xbc_node *node)
+trace_boot_set_instance_options(struct trace_array *tr, struct xbc_node *node)
 {
 	struct xbc_node *anode;
 	const char *p;
@@ -242,6 +242,40 @@ trace_boot_enable_tracer(struct trace_array *tr, struct xbc_node *node)
 	}
 }
 
+static void __init
+trace_boot_init_one_instance(struct trace_array *tr, struct xbc_node *node)
+{
+	trace_boot_set_instance_options(tr, node);
+	trace_boot_init_events(tr, node);
+	trace_boot_enable_events(tr, node);
+	trace_boot_enable_tracer(tr, node);
+}
+
+static void __init
+trace_boot_init_instances(struct xbc_node *node)
+{
+	struct xbc_node *inode;
+	struct trace_array *tr;
+	const char *p;
+
+	node = xbc_node_find_child(node, "instance");
+	if (!node)
+		return;
+
+	xbc_node_for_each_child(node, inode) {
+		p = xbc_node_get_data(inode);
+		if (!p || *p == '\0')
+			continue;
+
+		tr = trace_array_get_by_name(p);
+		if (IS_ERR(tr)) {
+			pr_err("Failed to get trace instance %s\n", p);
+			continue;
+		}
+		trace_boot_init_one_instance(tr, inode);
+	}
+}
+
 static int __init trace_boot_init(void)
 {
 	struct xbc_node *trace_node;
@@ -255,10 +289,9 @@ static int __init trace_boot_init(void)
 	if (!tr)
 		return 0;
 
-	trace_boot_set_ftrace_options(tr, trace_node);
-	trace_boot_init_events(tr, trace_node);
-	trace_boot_enable_events(tr, trace_node);
-	trace_boot_enable_tracer(tr, trace_node);
+	/* Global trace array is also one instance */
+	trace_boot_init_one_instance(tr, trace_node);
+	trace_boot_init_instances(trace_node);
 
 	return 0;
 }
Signature · 1 line
2.24.1
author maintainer
#60 lore raw

PATCH 23/26 tracing/boot: Add cpu_mask option support

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add ftrace.cpumask option support to boot-time tracing. This sets cpumask for each instance.

- ftrace.[instance.INSTANCE.]cpumask = CPUMASK;
Set the trace cpumask. Note that the CPUMASK should be a string which <tracefs>/tracing_cpumask can accepts.

---
 kernel/trace/trace.c      | 42 +++++++++++++++++++++++++++------------
 kernel/trace/trace_boot.c | 14 +++++++++++++
 2 files changed, 43 insertions(+), 13 deletions(-)
kernel/trace/trace.c +29 -13
index 6c996d1b1687..106bbc0988fe 100644
@@ -4561,20 +4561,13 @@ tracing_cpumask_read(struct file *filp, char __user *ubuf,
 	return count;
 }
 
-static ssize_t
-tracing_cpumask_write(struct file *filp, const char __user *ubuf,
-		      size_t count, loff_t *ppos)
+int tracing_set_cpumask(struct trace_array *tr,
+			cpumask_var_t tracing_cpumask_new)
 {
-	struct trace_array *tr = file_inode(filp)->i_private;
-	cpumask_var_t tracing_cpumask_new;
-	int err, cpu;
-
-	if (!alloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
-		return -ENOMEM;
+	int cpu;
 
-	err = cpumask_parse_user(ubuf, count, tracing_cpumask_new);
-	if (err)
-		goto err_unlock;
+	if (!tr)
+		return -EINVAL;
 
 	local_irq_disable();
 	arch_spin_lock(&tr->max_lock);
@@ -4598,11 +4591,34 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
 	local_irq_enable();
 
 	cpumask_copy(tr->tracing_cpumask, tracing_cpumask_new);
+
+	return 0;
+}
+
+static ssize_t
+tracing_cpumask_write(struct file *filp, const char __user *ubuf,
+		      size_t count, loff_t *ppos)
+{
+	struct trace_array *tr = file_inode(filp)->i_private;
+	cpumask_var_t tracing_cpumask_new;
+	int err;
+
+	if (!alloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
+		return -ENOMEM;
+
+	err = cpumask_parse_user(ubuf, count, tracing_cpumask_new);
+	if (err)
+		goto err_free;
+
+	err = tracing_set_cpumask(tr, tracing_cpumask_new);
+	if (err)
+		goto err_free;
+
 	free_cpumask_var(tracing_cpumask_new);
 
 	return count;
 
-err_unlock:
+err_free:
 	free_cpumask_var(tracing_cpumask_new);
 
 	return err;
kernel/trace/trace_boot.c +14 -0
index f5db30d25b0b..81d923c16a4d 100644
@@ -18,6 +18,8 @@ extern int trace_set_options(struct trace_array *tr, char *option);
 extern int tracing_set_tracer(struct trace_array *tr, const char *buf);
 extern ssize_t tracing_resize_ring_buffer(struct trace_array *tr,
 					  unsigned long size, int cpu_id);
+extern int tracing_set_cpumask(struct trace_array *tr,
+				cpumask_var_t tracing_cpumask_new);
 
 static void __init
 trace_boot_set_instance_options(struct trace_array *tr, struct xbc_node *node)
@@ -52,6 +54,18 @@ trace_boot_set_instance_options(struct trace_array *tr, struct xbc_node *node)
 		if (tracing_resize_ring_buffer(tr, v, RING_BUFFER_ALL_CPUS) < 0)
 			pr_err("Failed to resize trace buffer to %s\n", p);
 	}
+
+	p = xbc_node_find_value(node, "cpumask", NULL);
+	if (p && *p != '\0') {
+		cpumask_var_t new_mask;
+
+		if (alloc_cpumask_var(&new_mask, GFP_KERNEL)) {
+			if (cpumask_parse(p, new_mask) < 0 ||
+			    tracing_set_cpumask(tr, new_mask) < 0)
+				pr_err("Failed to set new CPU mask %s\n", p);
+			free_cpumask_var(new_mask);
+		}
+	}
 }
 
 #ifdef CONFIG_EVENT_TRACING
Signature · 1 line
2.24.1
author maintainer
#61 lore raw

PATCH 24/26 tracing/boot: Add function tracer filter options

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add below function-tracer filter options to boot-time tracing.

- ftrace.[instance.INSTANCE.]ftrace.filters
This will take an array of tracing function filter rules

- ftrace.[instance.INSTANCE.]ftrace.notraces
This will take an array of NON-tracing function filter rules

---
 kernel/trace/trace_boot.c | 40 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
kernel/trace/trace_boot.c +40 -0
index 81d923c16a4d..fa9603dc6469 100644
@@ -244,11 +244,51 @@ trace_boot_init_events(struct trace_array *tr, struct xbc_node *node)
 #define trace_boot_init_events(tr, node) do {} while (0)
 #endif
 
+#ifdef CONFIG_DYNAMIC_FTRACE
+extern bool ftrace_filter_param __initdata;
+extern int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
+			     int len, int reset);
+extern int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
+			      int len, int reset);
+static void __init
+trace_boot_set_ftrace_filter(struct trace_array *tr, struct xbc_node *node)
+{
+	struct xbc_node *anode;
+	const char *p;
+	char *q;
+
+	xbc_node_for_each_array_value(node, "ftrace.filters", anode, p) {
+		q = kstrdup(p, GFP_KERNEL);
+		if (!q)
+			return;
+		if (ftrace_set_filter(tr->ops, q, strlen(q), 0) < 0)
+			pr_err("Failed to add %s to ftrace filter\n", p);
+		else
+			ftrace_filter_param = true;
+		kfree(q);
+	}
+	xbc_node_for_each_array_value(node, "ftrace.notraces", anode, p) {
+		q = kstrdup(p, GFP_KERNEL);
+		if (!q)
+			return;
+		if (ftrace_set_notrace(tr->ops, q, strlen(q), 0) < 0)
+			pr_err("Failed to add %s to ftrace filter\n", p);
+		else
+			ftrace_filter_param = true;
+		kfree(q);
+	}
+}
+#else
+#define trace_boot_set_ftrace_filter(tr, node) do {} while (0)
+#endif
+
 static void __init
 trace_boot_enable_tracer(struct trace_array *tr, struct xbc_node *node)
 {
 	const char *p;
 
+	trace_boot_set_ftrace_filter(tr, node);
+
 	p = xbc_node_find_value(node, "tracer", NULL);
 	if (p && *p != '\0') {
 		if (tracing_set_tracer(tr, p) < 0)
Signature · 1 line
2.24.1
author maintainer
#62 lore raw

PATCH 25/26 Documentation: tracing: Add boot-time tracing document

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Add a documentation about boot-time tracing options in boot config.

---
 Documentation/admin-guide/bootconfig.rst |   2 +
 Documentation/trace/boottime-trace.rst   | 184 +++++++++++++++++++++++
 Documentation/trace/index.rst            |   1 +
 3 files changed, 187 insertions(+)
 create mode 100644 Documentation/trace/boottime-trace.rst
Documentation/admin-guide/bootconfig.rst +2 -0
index f7475df2a718..c8f7cd4cf44e 100644
@@ -1,5 +1,7 @@
 .. SPDX-License-Identifier: GPL-2.0
 
+.. _bootconfig:
+
 ==================
 Boot Configuration
 ==================
Documentation/trace/boottime-trace.rst new file +184 -0

184 lines not on this page · raw message

Documentation/trace/index.rst +1 -0
index 04acd277c5f6..fa9e1c730f6a 100644
@@ -19,6 +19,7 @@ Linux Tracing Technologies
    events-msr
    mmiotrace
    histogram
+   boottime-trace
    hwlat_detector
    intel_th
    stm
Signature · 1 line
2.24.1
author maintainer
#63 lore raw

PATCH 26/26 tracing: trigger: Replace unneeded RCU-list traversals

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

With CONFIG_PROVE_RCU_LIST, I had many suspicious RCU warnings when I ran ftracetest trigger testcases.

-----

  # dmesg -c > /dev/null
  # ./ftracetest test.d/trigger
  ...
  # dmesg | grep "RCU-list traversed" | cut -f 2 -d ] | cut -f 2 -d " "
  kernel/trace/trace_events_hist.c:6070
  kernel/trace/trace_events_hist.c:1760
  kernel/trace/trace_events_hist.c:5911
  kernel/trace/trace_events_trigger.c:504
  kernel/trace/trace_events_hist.c:1810
  kernel/trace/trace_events_hist.c:3158
  kernel/trace/trace_events_hist.c:3105
  kernel/trace/trace_events_hist.c:5518
  kernel/trace/trace_events_hist.c:5998
  kernel/trace/trace_events_hist.c:6019
  kernel/trace/trace_events_hist.c:6044
  kernel/trace/trace_events_trigger.c:1500
  kernel/trace/trace_events_trigger.c:1540
  kernel/trace/trace_events_trigger.c:539
  kernel/trace/trace_events_trigger.c:584
-----

I investigated those warnings and found that the RCU-list traversals in event trigger and hist didn't need to use RCU version because those were called only under event_mutex.

I also checked other RCU-list traversals related to event trigger list, and found that most of them were called from event_hist_trigger_func() or hist_unregister_trigger() or register/unregister functions except for a few cases.

Replace these unneeded RCU-list traversals with normal list traversal macro and lockdep_assert_held() to check the event_mutex is held.

---
 kernel/trace/trace_events_hist.c    | 41 +++++++++++++++++++++--------
 kernel/trace/trace_events_trigger.c | 20 ++++++++++----
 2 files changed, 45 insertions(+), 16 deletions(-)
kernel/trace/trace_events_hist.c +30 -11
index 8e90f1ada437..117a1202a6b9 100644
@@ -1771,11 +1771,13 @@ static struct hist_field *find_var(struct hist_trigger_data *hist_data,
 	struct event_trigger_data *test;
 	struct hist_field *hist_field;
 
+	lockdep_assert_held(&event_mutex);
+
 	hist_field = find_var_field(hist_data, var_name);
 	if (hist_field)
 		return hist_field;
 
-	list_for_each_entry_rcu(test, &file->triggers, list) {
+	list_for_each_entry(test, &file->triggers, list) {
 		if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
 			test_data = test->private_data;
 			hist_field = find_var_field(test_data, var_name);
@@ -1825,7 +1827,9 @@ static struct hist_field *find_file_var(struct trace_event_file *file,
 	struct event_trigger_data *test;
 	struct hist_field *hist_field;
 
-	list_for_each_entry_rcu(test, &file->triggers, list) {
+	lockdep_assert_held(&event_mutex);
+
+	list_for_each_entry(test, &file->triggers, list) {
 		if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
 			test_data = test->private_data;
 			hist_field = find_var_field(test_data, var_name);
@@ -3120,7 +3124,9 @@ static char *find_trigger_filter(struct hist_trigger_data *hist_data,
 {
 	struct event_trigger_data *test;
 
-	list_for_each_entry_rcu(test, &file->triggers, list) {
+	lockdep_assert_held(&event_mutex);
+
+	list_for_each_entry(test, &file->triggers, list) {
 		if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
 			if (test->private_data == hist_data)
 				return test->filter_str;
@@ -3171,9 +3177,11 @@ find_compatible_hist(struct hist_trigger_data *target_hist_data,
 	struct event_trigger_data *test;
 	unsigned int n_keys;
 
+	lockdep_assert_held(&event_mutex);
+
 	n_keys = target_hist_data->n_fields - target_hist_data->n_vals;
 
-	list_for_each_entry_rcu(test, &file->triggers, list) {
+	list_for_each_entry(test, &file->triggers, list) {
 		if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
 			hist_data = test->private_data;
 
@@ -5536,7 +5544,7 @@ static int hist_show(struct seq_file *m, void *v)
 		goto out_unlock;
 	}
 
-	list_for_each_entry_rcu(data, &event_file->triggers, list) {
+	list_for_each_entry(data, &event_file->triggers, list) {
 		if (data->cmd_ops->trigger_type == ETT_EVENT_HIST)
 			hist_trigger_show(m, data, n++);
 	}
@@ -5929,7 +5937,9 @@ static int hist_register_trigger(char *glob, struct event_trigger_ops *ops,
 	if (hist_data->attrs->name && !named_data)
 		goto new;
 
-	list_for_each_entry_rcu(test, &file->triggers, list) {
+	lockdep_assert_held(&event_mutex);
+
+	list_for_each_entry(test, &file->triggers, list) {
 		if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
 			if (!hist_trigger_match(data, test, named_data, false))
 				continue;
@@ -6013,10 +6023,12 @@ static bool have_hist_trigger_match(struct event_trigger_data *data,
 	struct event_trigger_data *test, *named_data = NULL;
 	bool match = false;
 
+	lockdep_assert_held(&event_mutex);
+
 	if (hist_data->attrs->name)
 		named_data = find_named_trigger(hist_data->attrs->name);
 
-	list_for_each_entry_rcu(test, &file->triggers, list) {
+	list_for_each_entry(test, &file->triggers, list) {
 		if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
 			if (hist_trigger_match(data, test, named_data, false)) {
 				match = true;
@@ -6034,10 +6046,12 @@ static bool hist_trigger_check_refs(struct event_trigger_data *data,
 	struct hist_trigger_data *hist_data = data->private_data;
 	struct event_trigger_data *test, *named_data = NULL;
 
+	lockdep_assert_held(&event_mutex);
+
 	if (hist_data->attrs->name)
 		named_data = find_named_trigger(hist_data->attrs->name);
 
-	list_for_each_entry_rcu(test, &file->triggers, list) {
+	list_for_each_entry(test, &file->triggers, list) {
 		if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
 			if (!hist_trigger_match(data, test, named_data, false))
 				continue;
@@ -6059,10 +6073,12 @@ static void hist_unregister_trigger(char *glob, struct event_trigger_ops *ops,
 	struct event_trigger_data *test, *named_data = NULL;
 	bool unregistered = false;
 
+	lockdep_assert_held(&event_mutex);
+
 	if (hist_data->attrs->name)
 		named_data = find_named_trigger(hist_data->attrs->name);
 
-	list_for_each_entry_rcu(test, &file->triggers, list) {
+	list_for_each_entry(test, &file->triggers, list) {
 		if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
 			if (!hist_trigger_match(data, test, named_data, false))
 				continue;
@@ -6088,7 +6104,9 @@ static bool hist_file_check_refs(struct trace_event_file *file)
 	struct hist_trigger_data *hist_data;
 	struct event_trigger_data *test;
 
-	list_for_each_entry_rcu(test, &file->triggers, list) {
+	lockdep_assert_held(&event_mutex);
+
+	list_for_each_entry(test, &file->triggers, list) {
 		if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
 			hist_data = test->private_data;
 			if (check_var_refs(hist_data))
@@ -6331,7 +6349,8 @@ hist_enable_trigger(struct event_trigger_data *data, void *rec,
 	struct enable_trigger_data *enable_data = data->private_data;
 	struct event_trigger_data *test;
 
-	list_for_each_entry_rcu(test, &enable_data->file->triggers, list) {
+	list_for_each_entry_rcu(test, &enable_data->file->triggers, list,
+				lockdep_is_held(&event_mutex)) {
 		if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
 			if (enable_data->enable)
 				test->paused = false;
kernel/trace/trace_events_trigger.c +15 -5
index d8ada4c6f3f7..60959c31791d 100644
@@ -501,7 +501,9 @@ void update_cond_flag(struct trace_event_file *file)
 	struct event_trigger_data *data;
 	bool set_cond = false;
 
-	list_for_each_entry_rcu(data, &file->triggers, list) {
+	lockdep_assert_held(&event_mutex);
+
+	list_for_each_entry(data, &file->triggers, list) {
 		if (data->filter || event_command_post_trigger(data->cmd_ops) ||
 		    event_command_needs_rec(data->cmd_ops)) {
 			set_cond = true;
@@ -536,7 +538,9 @@ static int register_trigger(char *glob, struct event_trigger_ops *ops,
 	struct event_trigger_data *test;
 	int ret = 0;
 
-	list_for_each_entry_rcu(test, &file->triggers, list) {
+	lockdep_assert_held(&event_mutex);
+
+	list_for_each_entry(test, &file->triggers, list) {
 		if (test->cmd_ops->trigger_type == data->cmd_ops->trigger_type) {
 			ret = -EEXIST;
 			goto out;
@@ -581,7 +585,9 @@ static void unregister_trigger(char *glob, struct event_trigger_ops *ops,
 	struct event_trigger_data *data;
 	bool unregistered = false;
 
-	list_for_each_entry_rcu(data, &file->triggers, list) {
+	lockdep_assert_held(&event_mutex);
+
+	list_for_each_entry(data, &file->triggers, list) {
 		if (data->cmd_ops->trigger_type == test->cmd_ops->trigger_type) {
 			unregistered = true;
 			list_del_rcu(&data->list);
@@ -1497,7 +1503,9 @@ int event_enable_register_trigger(char *glob,
 	struct event_trigger_data *test;
 	int ret = 0;
 
-	list_for_each_entry_rcu(test, &file->triggers, list) {
+	lockdep_assert_held(&event_mutex);
+
+	list_for_each_entry(test, &file->triggers, list) {
 		test_enable_data = test->private_data;
 		if (test_enable_data &&
 		    (test->cmd_ops->trigger_type ==
@@ -1537,7 +1545,9 @@ void event_enable_unregister_trigger(char *glob,
 	struct event_trigger_data *data;
 	bool unregistered = false;
 
-	list_for_each_entry_rcu(data, &file->triggers, list) {
+	lockdep_assert_held(&event_mutex);
+
+	list_for_each_entry(data, &file->triggers, list) {
 		enable_data = data->private_data;
 		if (enable_data &&
 		    (data->cmd_ops->trigger_type ==
Signature · 1 line
2.24.1
author maintainer
#64 lore raw

Re: [for-next][PATCH 26/26] tracing: trigger: Replace unneeded RCU-list traversals

Quoted 42 lines · On Tue, 14 Jan 2020 16:03:42 -0500 Steven Rostedt <[email protected]> wrote:

From: Masami Hiramatsu <[email protected]>

With CONFIG_PROVE_RCU_LIST, I had many suspicious RCU warnings when I ran ftracetest trigger testcases.

-----

  # dmesg -c > /dev/null
  # ./ftracetest test.d/trigger
  ...
  # dmesg | grep "RCU-list traversed" | cut -f 2 -d ] | cut -f 2 -d " "
  kernel/trace/trace_events_hist.c:6070
  kernel/trace/trace_events_hist.c:1760
  kernel/trace/trace_events_hist.c:5911
  kernel/trace/trace_events_trigger.c:504
  kernel/trace/trace_events_hist.c:1810
  kernel/trace/trace_events_hist.c:3158
  kernel/trace/trace_events_hist.c:3105
  kernel/trace/trace_events_hist.c:5518
  kernel/trace/trace_events_hist.c:5998
  kernel/trace/trace_events_hist.c:6019
  kernel/trace/trace_events_hist.c:6044
  kernel/trace/trace_events_trigger.c:1500
  kernel/trace/trace_events_trigger.c:1540
  kernel/trace/trace_events_trigger.c:539
  kernel/trace/trace_events_trigger.c:584
-----

I investigated those warnings and found that the RCU-list traversals in event trigger and hist didn't need to use RCU version because those were called only under event_mutex.

I also checked other RCU-list traversals related to event trigger list, and found that most of them were called from event_hist_trigger_func() or hist_unregister_trigger() or register/unregister functions except for a few cases.

Replace these unneeded RCU-list traversals with normal list traversal macro and lockdep_assert_held() to check the event_mutex is held.

Quoted 8 lines
---
 kernel/trace/trace_events_hist.c    | 41 +++++++++++++++++++++--------
 kernel/trace/trace_events_trigger.c | 20 ++++++++++----
 2 files changed, 45 insertions(+), 16 deletions(-)

I think I may add this to my urgent branch and mark this for stable.

-- Steve