Skip to content

Commit 76bfd3d

Browse files
committed
Merge tag 'trace-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing updates from Steven Rostedt: "The majority of the changes are for fixes and clean ups. Notable changes: - Rework trace event triggers code to be easier to interact with. - Support for embedding bootconfig with the kernel (as suppose to having it embedded in initram). This is useful for embedded boards without initram disks. - Speed up boot by parallelizing the creation of tracefs files. - Allow absolute ring buffer timestamps handle timestamps that use more than 59 bits. - Added new tracing clock "TAI" (International Atomic Time) - Have weak functions show up in available_filter_function list as: __ftrace_invalid_address___<invalid-offset> instead of using the name of the function before it" * tag 'trace-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (52 commits) ftrace: Add FTRACE_MCOUNT_MAX_OFFSET to avoid adding weak function tracing: Fix comments for event_trigger_separate_filter() x86/traceponit: Fix comment about irq vector tracepoints x86,tracing: Remove unused headers ftrace: Clean up hash direct_functions on register failures tracing: Fix comments of create_filter() tracing: Disable kcov on trace_preemptirq.c tracing: Initialize integer variable to prevent garbage return value ftrace: Fix typo in comment ftrace: Remove return value of ftrace_arch_modify_*() tracing: Cleanup code by removing init "char *name" tracing: Change "char *" string form to "char []" tracing/timerlat: Do not wakeup the thread if the trace stops at the IRQ tracing/timerlat: Print stacktrace in the IRQ handler if needed tracing/timerlat: Notify IRQ new max latency only if stop tracing is set kprobes: Fix build errors with CONFIG_KRETPROBES=n tracing: Fix return value of trace_pid_write() tracing: Fix potential double free in create_var_ref() tracing: Use strim() to remove whitespace instead of doing it manually ftrace: Deal with error return code of the ftrace_process_locs() function ...
2 parents 09f73a1 + b39181f commit 76bfd3d

40 files changed

+822
-646
lines changed

Documentation/admin-guide/bootconfig.rst

+28-3
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,15 @@ Each key-value pair is shown in each line with following style::
158158
Boot Kernel With a Boot Config
159159
==============================
160160

161-
Since the boot configuration file is loaded with initrd, it will be added
162-
to the end of the initrd (initramfs) image file with padding, size,
163-
checksum and 12-byte magic word as below.
161+
There are two options to boot the kernel with bootconfig: attaching the
162+
bootconfig to the initrd image or embedding it in the kernel itself.
163+
164+
Attaching a Boot Config to Initrd
165+
---------------------------------
166+
167+
Since the boot configuration file is loaded with initrd by default,
168+
it will be added to the end of the initrd (initramfs) image file with
169+
padding, size, checksum and 12-byte magic word as below.
164170

165171
[initrd][bootconfig][padding][size(le32)][checksum(le32)][#BOOTCONFIG\n]
166172

@@ -196,6 +202,25 @@ To remove the config from the image, you can use -d option as below::
196202
Then add "bootconfig" on the normal kernel command line to tell the
197203
kernel to look for the bootconfig at the end of the initrd file.
198204

205+
Embedding a Boot Config into Kernel
206+
-----------------------------------
207+
208+
If you can not use initrd, you can also embed the bootconfig file in the
209+
kernel by Kconfig options. In this case, you need to recompile the kernel
210+
with the following configs::
211+
212+
CONFIG_BOOT_CONFIG_EMBED=y
213+
CONFIG_BOOT_CONFIG_EMBED_FILE="/PATH/TO/BOOTCONFIG/FILE"
214+
215+
``CONFIG_BOOT_CONFIG_EMBED_FILE`` requires an absolute path or a relative
216+
path to the bootconfig file from source tree or object tree.
217+
The kernel will embed it as the default bootconfig.
218+
219+
Just as when attaching the bootconfig to the initrd, you need ``bootconfig``
220+
option on the kernel command line to enable the embedded bootconfig.
221+
222+
Note that even if you set this option, you can override the embedded
223+
bootconfig by another bootconfig which attached to the initrd.
199224

200225
Kernel parameters via Boot Config
201226
=================================

Documentation/trace/ftrace.rst

+12
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,18 @@ of ftrace. Here is a list of some of the key files:
517517
processing should be able to handle them. See comments in the
518518
ktime_get_boot_fast_ns() function for more information.
519519

520+
tai:
521+
This is the tai clock (CLOCK_TAI) and is derived from the wall-
522+
clock time. However, this clock does not experience
523+
discontinuities and backwards jumps caused by NTP inserting leap
524+
seconds. Since the clock access is designed for use in tracing,
525+
side effects are possible. The clock access may yield wrong
526+
readouts in case the internal TAI offset is updated e.g., caused
527+
by setting the system time or using adjtimex() with an offset.
528+
These effects are rare and post processing should be able to
529+
handle them. See comments in the ktime_get_tai_fast_ns()
530+
function for more information.
531+
520532
To set a clock, simply echo the clock name into this file::
521533

522534
# echo global > trace_clock

Documentation/trace/timerlat-tracer.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ directory. The timerlat configs are:
7474
- stop_tracing_total_us: stop the system tracing if a
7575
timer latency at the *thread* context is higher than the configured
7676
value happens. Writing 0 disables this option.
77-
- print_stack: save the stack of the IRQ occurrence, and print
78-
it after the *thread context* event".
77+
- print_stack: save the stack of the IRQ occurrence. The stack is printed
78+
after the *thread context* event, or at the IRQ handler if *stop_tracing_us*
79+
is hit.
7980

8081
timerlat and osnoise
8182
----------------------------

MAINTAINERS

+3-2
Original file line numberDiff line numberDiff line change
@@ -7517,6 +7517,7 @@ S: Maintained
75177517
F: Documentation/admin-guide/bootconfig.rst
75187518
F: fs/proc/bootconfig.c
75197519
F: include/linux/bootconfig.h
7520+
F: lib/bootconfig-data.S
75207521
F: lib/bootconfig.c
75217522
F: tools/bootconfig/*
75227523
F: tools/bootconfig/scripts/*
@@ -20119,8 +20120,8 @@ M: Ingo Molnar <[email protected]>
2011920120
S: Maintained
2012020121
T: git git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
2012120122
F: Documentation/trace/ftrace.rst
20122-
F: arch/*/*/*/ftrace.h
20123-
F: arch/*/kernel/ftrace.c
20123+
F: arch/*/*/*/*ftrace*
20124+
F: arch/*/*/*ftrace*
2012420125
F: fs/tracefs/
2012520126
F: include/*/ftrace.h
2012620127
F: include/linux/trace*.h

arch/arm/kernel/ftrace.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,14 @@ static unsigned long __ref adjust_address(struct dyn_ftrace *rec,
7979
return (unsigned long)&ftrace_regs_caller_from_init;
8080
}
8181

82-
int ftrace_arch_code_modify_prepare(void)
82+
void ftrace_arch_code_modify_prepare(void)
8383
{
84-
return 0;
8584
}
8685

87-
int ftrace_arch_code_modify_post_process(void)
86+
void ftrace_arch_code_modify_post_process(void)
8887
{
8988
/* Make sure any TLB misses during machine stop are cleared. */
9089
flush_tlb_all();
91-
return 0;
9290
}
9391

9492
static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr,

arch/riscv/kernel/ftrace.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212
#include <asm/patch.h>
1313

1414
#ifdef CONFIG_DYNAMIC_FTRACE
15-
int ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)
15+
void ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)
1616
{
1717
mutex_lock(&text_mutex);
18-
return 0;
1918
}
2019

21-
int ftrace_arch_code_modify_post_process(void) __releases(&text_mutex)
20+
void ftrace_arch_code_modify_post_process(void) __releases(&text_mutex)
2221
{
2322
mutex_unlock(&text_mutex);
24-
return 0;
2523
}
2624

2725
static int ftrace_check_current_call(unsigned long hook_pos,

arch/s390/kernel/ftrace.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,13 @@ void arch_ftrace_update_code(int command)
225225
ftrace_modify_all_code(command);
226226
}
227227

228-
int ftrace_arch_code_modify_post_process(void)
228+
void ftrace_arch_code_modify_post_process(void)
229229
{
230230
/*
231231
* Flush any pre-fetched instructions on all
232232
* CPUs to make the new code visible.
233233
*/
234234
text_poke_sync_lock();
235-
return 0;
236235
}
237236

238237
#ifdef CONFIG_MODULES

arch/x86/include/asm/ftrace.h

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
# define MCOUNT_ADDR ((unsigned long)(__fentry__))
1010
#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
1111

12+
/* Ignore unused weak functions which will have non zero offsets */
13+
#ifdef CONFIG_HAVE_FENTRY
14+
# include <asm/ibt.h>
15+
/* Add offset for endbr64 if IBT enabled */
16+
# define FTRACE_MCOUNT_MAX_OFFSET ENDBR_INSN_SIZE
17+
#endif
18+
1219
#ifdef CONFIG_DYNAMIC_FTRACE
1320
#define ARCH_SUPPORTS_FTRACE_OPS 1
1421
#endif

arch/x86/kernel/ftrace.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
static int ftrace_poke_late = 0;
3939

40-
int ftrace_arch_code_modify_prepare(void)
40+
void ftrace_arch_code_modify_prepare(void)
4141
__acquires(&text_mutex)
4242
{
4343
/*
@@ -47,10 +47,9 @@ int ftrace_arch_code_modify_prepare(void)
4747
*/
4848
mutex_lock(&text_mutex);
4949
ftrace_poke_late = 1;
50-
return 0;
5150
}
5251

53-
int ftrace_arch_code_modify_post_process(void)
52+
void ftrace_arch_code_modify_post_process(void)
5453
__releases(&text_mutex)
5554
{
5655
/*
@@ -61,7 +60,6 @@ int ftrace_arch_code_modify_post_process(void)
6160
text_poke_finish();
6261
ftrace_poke_late = 0;
6362
mutex_unlock(&text_mutex);
64-
return 0;
6563
}
6664

6765
static const char *ftrace_nop_replace(void)

arch/x86/kernel/tracepoint.c

-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* Code for supporting irq vector tracepoints.
4-
*
53
* Copyright (C) 2013 Seiji Aguchi <[email protected]>
6-
*
74
*/
85
#include <linux/jump_label.h>
96
#include <linux/atomic.h>
107

11-
#include <asm/hw_irq.h>
12-
#include <asm/desc.h>
138
#include <asm/trace/exceptions.h>
14-
#include <asm/trace/irq_vectors.h>
159

1610
DEFINE_STATIC_KEY_FALSE(trace_pagefault_key);
1711

include/linux/bootconfig.h

+10
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,14 @@ int __init xbc_get_info(int *node_size, size_t *data_size);
289289
/* XBC cleanup data structures */
290290
void __init xbc_exit(void);
291291

292+
/* XBC embedded bootconfig data in kernel */
293+
#ifdef CONFIG_BOOT_CONFIG_EMBED
294+
const char * __init xbc_get_embedded_bootconfig(size_t *size);
295+
#else
296+
static inline const char *xbc_get_embedded_bootconfig(size_t *size)
297+
{
298+
return NULL;
299+
}
300+
#endif
301+
292302
#endif

include/linux/ftrace.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ static inline void stack_tracer_enable(void) { }
452452

453453
#ifdef CONFIG_DYNAMIC_FTRACE
454454

455-
int ftrace_arch_code_modify_prepare(void);
456-
int ftrace_arch_code_modify_post_process(void);
455+
void ftrace_arch_code_modify_prepare(void);
456+
void ftrace_arch_code_modify_post_process(void);
457457

458458
enum ftrace_bug_type {
459459
FTRACE_BUG_UNKNOWN,

include/linux/kprobes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ void unregister_kretprobe(struct kretprobe *rp);
424424
int register_kretprobes(struct kretprobe **rps, int num);
425425
void unregister_kretprobes(struct kretprobe **rps, int num);
426426

427-
#ifdef CONFIG_KRETPROBE_ON_RETHOOK
427+
#if defined(CONFIG_KRETPROBE_ON_RETHOOK) || !defined(CONFIG_KRETPROBES)
428428
#define kprobe_flush_task(tk) do {} while (0)
429429
#else
430430
void kprobe_flush_task(struct task_struct *tk);

init/Kconfig

+20-1
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ endif
13381338

13391339
config BOOT_CONFIG
13401340
bool "Boot config support"
1341-
select BLK_DEV_INITRD
1341+
select BLK_DEV_INITRD if !BOOT_CONFIG_EMBED
13421342
help
13431343
Extra boot config allows system admin to pass a config file as
13441344
complemental extension of kernel cmdline when booting.
@@ -1348,6 +1348,25 @@ config BOOT_CONFIG
13481348

13491349
If unsure, say Y.
13501350

1351+
config BOOT_CONFIG_EMBED
1352+
bool "Embed bootconfig file in the kernel"
1353+
depends on BOOT_CONFIG
1354+
help
1355+
Embed a bootconfig file given by BOOT_CONFIG_EMBED_FILE in the
1356+
kernel. Usually, the bootconfig file is loaded with the initrd
1357+
image. But if the system doesn't support initrd, this option will
1358+
help you by embedding a bootconfig file while building the kernel.
1359+
1360+
If unsure, say N.
1361+
1362+
config BOOT_CONFIG_EMBED_FILE
1363+
string "Embedded bootconfig file path"
1364+
depends on BOOT_CONFIG_EMBED
1365+
help
1366+
Specify a bootconfig file which will be embedded to the kernel.
1367+
This bootconfig will be used if there is no initrd or no other
1368+
bootconfig in the initrd.
1369+
13511370
config INITRAMFS_PRESERVE_MTIME
13521371
bool "Preserve cpio archive mtimes in initramfs"
13531372
default y

init/main.c

+19-19
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static int __init loglevel(char *str)
266266
early_param("loglevel", loglevel);
267267

268268
#ifdef CONFIG_BLK_DEV_INITRD
269-
static void * __init get_boot_config_from_initrd(u32 *_size, u32 *_csum)
269+
static void * __init get_boot_config_from_initrd(size_t *_size)
270270
{
271271
u32 size, csum;
272272
char *data;
@@ -300,17 +300,20 @@ static void * __init get_boot_config_from_initrd(u32 *_size, u32 *_csum)
300300
return NULL;
301301
}
302302

303+
if (xbc_calc_checksum(data, size) != csum) {
304+
pr_err("bootconfig checksum failed\n");
305+
return NULL;
306+
}
307+
303308
/* Remove bootconfig from initramfs/initrd */
304309
initrd_end = (unsigned long)data;
305310
if (_size)
306311
*_size = size;
307-
if (_csum)
308-
*_csum = csum;
309312

310313
return data;
311314
}
312315
#else
313-
static void * __init get_boot_config_from_initrd(u32 *_size, u32 *_csum)
316+
static void * __init get_boot_config_from_initrd(size_t *_size)
314317
{
315318
return NULL;
316319
}
@@ -407,14 +410,16 @@ static int __init warn_bootconfig(char *str)
407410
static void __init setup_boot_config(void)
408411
{
409412
static char tmp_cmdline[COMMAND_LINE_SIZE] __initdata;
410-
const char *msg;
411-
int pos;
412-
u32 size, csum;
413-
char *data, *err;
414-
int ret;
413+
const char *msg, *data;
414+
int pos, ret;
415+
size_t size;
416+
char *err;
415417

416418
/* Cut out the bootconfig data even if we have no bootconfig option */
417-
data = get_boot_config_from_initrd(&size, &csum);
419+
data = get_boot_config_from_initrd(&size);
420+
/* If there is no bootconfig in initrd, try embedded one. */
421+
if (!data)
422+
data = xbc_get_embedded_bootconfig(&size);
418423

419424
strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
420425
err = parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL,
@@ -433,13 +438,8 @@ static void __init setup_boot_config(void)
433438
}
434439

435440
if (size >= XBC_DATA_MAX) {
436-
pr_err("bootconfig size %d greater than max size %d\n",
437-
size, XBC_DATA_MAX);
438-
return;
439-
}
440-
441-
if (xbc_calc_checksum(data, size) != csum) {
442-
pr_err("bootconfig checksum failed\n");
441+
pr_err("bootconfig size %ld greater than max size %d\n",
442+
(long)size, XBC_DATA_MAX);
443443
return;
444444
}
445445

@@ -452,7 +452,7 @@ static void __init setup_boot_config(void)
452452
msg, pos);
453453
} else {
454454
xbc_get_info(&ret, NULL);
455-
pr_info("Load bootconfig: %d bytes %d nodes\n", size, ret);
455+
pr_info("Load bootconfig: %ld bytes %d nodes\n", (long)size, ret);
456456
/* keys starting with "kernel." are passed via cmdline */
457457
extra_command_line = xbc_make_cmdline("kernel");
458458
/* Also, "init." keys are init arguments */
@@ -471,7 +471,7 @@ static void __init exit_boot_config(void)
471471
static void __init setup_boot_config(void)
472472
{
473473
/* Remove bootconfig data from initrd */
474-
get_boot_config_from_initrd(NULL, NULL);
474+
get_boot_config_from_initrd(NULL);
475475
}
476476

477477
static int __init warn_bootconfig(char *str)

0 commit comments

Comments
 (0)