20 Jan, 2021

1 commit

  • commit 55ed4560774d81d7343223b8fd2784c530a9c6c1 upstream.

    Add ftrace.instance.INSTANCE.tracing_on support to ftrace2bconf.sh
    and bconf2ftrace.sh.

    commit 8490db06f914 ("tracing/boot: Add per-instance tracing_on
    option support") added the per-instance tracing_on option,
    but forgot to update the helper scripts.

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

    Cc: stable@vger.kernel.org
    Fixes: 8490db06f914 ("tracing/boot: Add per-instance tracing_on option support")
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     

01 Dec, 2020

1 commit

  • Store the size and the checksum fields in the footer as le32
    instead of u32. This will allow us to apply bootconfig to the
    cross build initrd without caring the endianness.

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

    Reported-by: Steven Rostedt
    Suggested-by: Linus Torvalds
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     

19 Nov, 2020

3 commits

  • Align the bootconfig applied initrd image size to 4. To fill the gap,
    the bootconfig command uses null characters in between the bootconfig
    data and the footer. This will expands the footer size but don't change
    the checksum.
    Thus the block image of the initrd file with bootconfig is as follows.

    [initrd][bootconfig][(pad)][size][csum]["#BOOTCONFIG\n"]

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

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Fix to check the write(2) failure including partial write
    correctly and try to rollback the partial write, because
    if there is no BOOTCONFIG_MAGIC string, we can not remove it.

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

    Fixes: 85c46b78da58 ("bootconfig: Add bootconfig magic word for indicating bootconfig explicitly")
    Suggested-by: Linus Torvalds
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Fix not to refer the errno variable as the result of previous libc
    functions after printf() because printf() can change the errno.

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

    Fixes: 85c46b78da58 ("bootconfig: Add bootconfig magic word for indicating bootconfig explicitly")
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     

16 Oct, 2020

1 commit

  • Pull tracing updates from Steven Rostedt:
    "Updates for tracing and bootconfig:

    - Add support for "bool" type in synthetic events

    - Add per instance tracing for bootconfig

    - Support perf-style return probe ("SYMBOL%return") in kprobes and
    uprobes

    - Allow for kprobes to be enabled earlier in boot up

    - Added tracepoint helper function to allow testing if tracepoints
    are enabled in headers

    - Synthetic events can now have dynamic strings (variable length)

    - Various fixes and cleanups"

    * tag 'trace-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (58 commits)
    tracing: support "bool" type in synthetic trace events
    selftests/ftrace: Add test case for synthetic event syntax errors
    tracing: Handle synthetic event array field type checking correctly
    selftests/ftrace: Change synthetic event name for inter-event-combined test
    tracing: Add synthetic event error logging
    tracing: Check that the synthetic event and field names are legal
    tracing: Move is_good_name() from trace_probe.h to trace.h
    tracing: Don't show dynamic string internals in synthetic event description
    tracing: Fix some typos in comments
    tracing/boot: Add ftrace.instance.*.alloc_snapshot option
    tracing: Fix race in trace_open and buffer resize call
    tracing: Check return value of __create_val_fields() before using its result
    tracing: Fix synthetic print fmt check for use of __get_str()
    tracing: Remove a pointless assignment
    ftrace: ftrace_global_list is renamed to ftrace_ops_list
    ftrace: Format variable declarations of ftrace_allocate_records
    ftrace: Simplify the calculation of page number for ftrace_page->records
    ftrace: Simplify the dyn_ftrace->flags macro
    ftrace: Simplify the hash calculation
    ftrace: Use fls() to get the bits for dup_hash()
    ...

    Linus Torvalds
     

22 Sep, 2020

2 commits


19 Sep, 2020

6 commits

  • Since the ftrace current setting may conflict with the new setting
    from bootconfig, add the --init option to initialize ftrace before
    setting for bconf2ftrace.sh.

    E.g.
    $ bconf2ftrace.sh --init boottrace.bconf

    This initialization method copied from selftests/ftrace.

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

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Add a ftrace2bconf.sh under tools/bootconfig/scripts which generates
    a bootconfig file from the current ftrace settings.

    To read the ftrace settings, ftrace2bconf.sh requires the root
    privilege (or sudo). The ftrace2bconf.sh will output the bootconfig
    to stdout and error messages to stderr, so usually you'll run it as

    # ftrace2bconf.sh > ftrace.bconf

    Note that some ftrace configurations are not supported. For example,
    function-call/callgraph trace/notrace settings are not supported because
    the wildcard has been expanded and lost in the ftrace anymore.

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

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Add a bconf2ftrace.sh under tools/bootconfig/scripts which generates
    a shell script to setup boot-time trace from bootconfig file for testing
    the bootconfig.

    bconf2ftrace.sh will take a bootconfig file (includes boot-time tracing)
    and convert it into a shell-script which is almost same as the boot-time
    tracer does.
    If --apply option is given, it also tries to apply those command to the
    running kernel, which requires the root privilege (or sudo).

    For example, if you just want to confirm the shell commands, save
    the output as below.

    # bconf2ftrace.sh ftrace.bconf > ftrace.sh

    Or, you can apply it directly.

    # bconf2ftrace.sh --apply ftrace.bconf

    Note that some boot-time tracing parameters under kernel.* are not able
    to set via tracefs nor procfs (e.g. tp_printk, traceoff_on_warning.),
    so those are ignored.

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

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Make all functions static except for main(). This is just a cleanup.

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

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Add list option (-l) to show the bootconfig in the list style.
    This is same output of /proc/bootconfig. So users can check
    how their bootconfig will be shown in procfs. This will help
    them to write a user-space script to parse the /proc/bootconfig.

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

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Show the bootconfig compact tree from the bootconfig file
    instead of an initrd if the given file has no magic number
    and is smaller than 32KB.

    User can use this for checking the syntax error or output
    checking before applying the bootconfig to initrd.

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

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     

04 Aug, 2020

1 commit


17 Jun, 2020

3 commits

  • Add testcases for the return value of the command to show
    bootconfig in initrd, and double/single quotes selecting.

    Link: http://lkml.kernel.org/r/159230247428.65555.2109472942519215104.stgit@devnote2

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Fix bootconfig to return 0 if succeeded to show the bootconfig
    in initrd. Without this fix, "bootconfig INITRD" command
    returns !0 even if the command succeeded to show the bootconfig.

    Link: http://lkml.kernel.org/r/159230246566.65555.11891772258543514487.stgit@devnote2

    Cc: stable@vger.kernel.org
    Fixes: 950313ebf79c ("tools: bootconfig: Add bootconfig command")
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Fix bootconfig tool to select double or single quotes
    correctly according to the value.

    If a bootconfig value includes a double quote character,
    we must use single-quotes to quote that value.

    Link: http://lkml.kernel.org/r/159230245697.65555.12444299015852932304.stgit@devnote2

    Cc: stable@vger.kernel.org
    Fixes: 950313ebf79c ("tools: bootconfig: Add bootconfig command")
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     

20 May, 2020

1 commit


12 May, 2020

1 commit

  • The return of apply_xbc() returns the result of the last write() call, which
    is not what is expected. It should only return zero on success.

    Link: https://lore.kernel.org/r/20200508093059.GF9365@kadam

    Fixes: 8842604446d1 ("tools/bootconfig: Fix resource leak in apply_xbc()")
    Reported-by: Dan Carpenter
    Acked-by: Masami Hiramatsu
    Tested-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     

08 May, 2020

1 commit


06 Apr, 2020

1 commit

  • Pull tracing updates from Steven Rostedt:
    "New tracing features:

    - The ring buffer is no longer disabled when reading the trace file.

    The trace_pipe file was made to be used for live tracing and
    reading as it acted like the normal producer/consumer. As the trace
    file would not consume the data, the easy way of handling it was to
    just disable writes to the ring buffer.

    This came to a surprise to the BPF folks who complained about lost
    events due to reading. This is no longer an issue. If someone wants
    to keep the old disabling there's a new option "pause-on-trace"
    that can be set.

    - New set_ftrace_notrace_pid file. PIDs in this file will not be
    traced by the function tracer.

    Similar to set_ftrace_pid, which makes the function tracer only
    trace those tasks with PIDs in the file, the set_ftrace_notrace_pid
    does the reverse.

    - New set_event_notrace_pid file. PIDs in this file will cause events
    not to be traced if triggered by a task with a matching PID.

    Similar to the set_event_pid file but will not be traced. Note,
    sched_waking and sched_switch events may still be traced if one of
    the tasks referenced by those events contains a PID that is allowed
    to be traced.

    Tracing related features:

    - New bootconfig option, that is attached to the initrd file.

    If bootconfig is on the command line, then the initrd file is
    searched looking for a bootconfig appended at the end.

    - New GPU tracepoint infrastructure to help the gfx drivers to get
    off debugfs (acked by Greg Kroah-Hartman)

    And other minor updates and fixes"

    * tag 'trace-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (27 commits)
    tracing: Do not allocate buffer in trace_find_next_entry() in atomic
    tracing: Add documentation on set_ftrace_notrace_pid and set_event_notrace_pid
    selftests/ftrace: Add test to test new set_event_notrace_pid file
    selftests/ftrace: Add test to test new set_ftrace_notrace_pid file
    tracing: Create set_event_notrace_pid to not trace tasks
    ftrace: Create set_ftrace_notrace_pid to not trace tasks
    ftrace: Make function trace pid filtering a bit more exact
    ftrace/kprobe: Show the maxactive number on kprobe_events
    tracing: Have the document reflect that the trace file keeps tracing enabled
    ring-buffer/tracing: Have iterator acknowledge dropped events
    tracing: Do not disable tracing when reading the trace file
    ring-buffer: Do not disable recording when there is an iterator
    ring-buffer: Make resize disable per cpu buffer instead of total buffer
    ring-buffer: Optimize rb_iter_head_event()
    ring-buffer: Do not die if rb_iter_peek() fails more than thrice
    ring-buffer: Have rb_iter_head_event() handle concurrent writer
    ring-buffer: Add page_stamp to iterator for synchronization
    ring-buffer: Rename ring_buffer_read() to read_buffer_iter_advance()
    ring-buffer: Have ring_buffer_empty() not depend on tracing stopped
    tracing: Save off entry when peeking at next entry
    ...

    Linus Torvalds
     

25 Mar, 2020

1 commit


04 Mar, 2020

2 commits

  • Show line and column when we got a parse error in bootconfig tool.
    Current lib/bootconfig shows the parse error with byte offset, but
    that is not human readable.
    This makes xbc_init() not showing error message itself but able to
    pass the error message and position to caller, so that the caller
    can decode it and show the error message with line number and columns.

    With this patch, bootconfig tool shows an error with line:column as
    below.

    $ cat samples/bad-dotword.bconf
    # do not start keyword with .
    key {
    .word = 1
    }
    $ ./bootconfig -a samples/bad-dotword.bconf initrd
    Parse Error: Invalid keyword at 3:3

    Link: http://lkml.kernel.org/r/158323469002.10560.4023923847704522760.stgit@devnote2

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Support O= option to build bootconfig tool in
    the other directory. As same as other tools, if you specify
    O=, bootconfig command is build under .

    Link: http://lkml.kernel.org/r/158323468033.10560.14661631369326294355.stgit@devnote2

    Reported-by: Randy Dunlap
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     

21 Feb, 2020

5 commits

  • Add append value operator "+=" support to bootconfig syntax.
    With this operator, user can add new value to the key as
    an entry of array instead of overwriting.
    For example,

    foo = bar
    ...
    foo += baz

    Then the key "foo" has "bar" and "baz" values as an array.

    Link: http://lkml.kernel.org/r/158227283195.12842.8310503105963275584.stgit@devnote2

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Currently, bootconfig adds a new value on the existing key to the tail of an
    array. But this looks a bit confusing because an admin can easily rewrite
    the original value in the same config file.

    This rejects the following value re-definition.

    key = value1
    ...
    key = value2

    You should rewrite value1 to value2 in this case.

    Link: http://lkml.kernel.org/r/158227282199.12842.10110929876059658601.stgit@devnote2

    Suggested-by: Steven Rostedt (VMware)
    Signed-off-by: Masami Hiramatsu
    [ Fixed spelling of arraies to arrays ]
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Reject if a value node is mixed with subkey node on same
    parent key node.

    A value node can not co-exist with subkey node under some key
    node, e.g.

    key = value
    key.subkey = another-value

    This is not be allowed because bootconfig API is not designed
    to handle such case.

    Link: http://lkml.kernel.org/r/158220115232.26565.7792340045009731803.stgit@devnote2

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Remove error message silent knob, we don't need it anymore
    because we can check if there is a bootconfig by checking
    the magic word.
    If there is a magic word, but failed to load a bootconfig
    from initrd, there is a real problem.

    Link: http://lkml.kernel.org/r/158220113256.26565.14264598654427773104.stgit@devnote2

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • Add bootconfig magic word to the end of bootconfig on initrd
    image for indicating explicitly the bootconfig is there.
    Also tools/bootconfig treats wrong size or wrong checksum or
    parse error as an error, because if there is a bootconfig magic
    word, there must be a bootconfig.

    The bootconfig magic word is "#BOOTCONFIG\n", 12 bytes word.
    Thus the block image of the initrd file with bootconfig is
    as follows.

    [Initrd][bootconfig][size][csum][#BOOTCONFIG\n]

    Link: http://lkml.kernel.org/r/158220112263.26565.3944814205960612841.stgit@devnote2

    Suggested-by: Steven Rostedt
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     

11 Feb, 2020

3 commits

  • 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.

    Link: http://lkml.kernel.org/r/158125351377.16911.13283712972275131160.stgit@devnote2

    Reported-by: Michael Ellerman
    Tested-by: Michael Ellerman
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • 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.

    Link: http://lkml.kernel.org/r/158108569699.3187.6512834527603883707.stgit@devnote2

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    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__.

    Link: http://lkml.kernel.org/r/158108370130.2758.10893830923800978011.stgit@devnote2

    Fixes: 950313ebf79c ("tools: bootconfig: Add bootconfig command")
    Reported-by: Michael Ellerman
    Tested-by: Michael Ellerman
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     

06 Feb, 2020

1 commit

  • Show the number of bootconfig nodes when applying new bootconfig to
    initrd.

    Since there are limitations of bootconfig not only in its filesize,
    but also the number of nodes, the number should be shown when applying
    so that user can get the feeling of scale of current bootconfig.

    Link: http://lkml.kernel.org/r/158091061337.27924.10886706631693823982.stgit@devnote2

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     

22 Jan, 2020

1 commit


14 Jan, 2020

2 commits

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

    Link: http://lkml.kernel.org/r/157867224728.17873.18114241801246589416.stgit@devnote2

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     
  • 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

    Link: http://lkml.kernel.org/r/157867223582.17873.14342161849213219982.stgit@devnote2

    Signed-off-by: Masami Hiramatsu
    [ Removed extra blank line at end of bootconfig.c ]
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu