Skip to content
Snippets Groups Projects
  1. Jul 17, 2024
  2. Mar 20, 2024
  3. Feb 12, 2024
    • Daniel Bristot de Oliveira's avatar
      tools/rv: Fix curr_reactor uninitialized variable · 61ec586b
      Daniel Bristot de Oliveira authored
      clang is reporting:
      
      $ make HOSTCC=clang CC=clang LLVM_IAS=1
      
      clang -O -g -DVERSION=\"6.8.0-rc3\" -flto=auto -fexceptions
      	-fstack-protector-strong -fasynchronous-unwind-tables
      	-fstack-clash-protection  -Wall -Werror=format-security
      	-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS
      	$(pkg-config --cflags libtracefs)  -I include
      	-c -o src/in_kernel.o src/in_kernel.c
      [...]
      
      src/in_kernel.c:227:6: warning: variable 'curr_reactor' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        227 |         if (!end)
            |             ^~~~
      src/in_kernel.c:242:9: note: uninitialized use occurs here
        242 |         return curr_reactor;
            |                ^~~~~~~~~~~~
      src/in_kernel.c:227:2: note: remove the 'if' if its condition is always false
        227 |         if (!end)
            |         ^~~~~~~~~
        228 |                 goto out_free;
            |                 ~~~~~~~~~~~~~
      src/in_kernel.c:221:6: warning: variable 'curr_reactor' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        221 |         if (!start)
            |             ^~~~~~
      src/in_kernel.c:242:9: note: uninitialized use occurs here
        242 |         return curr_reactor;
            |                ^~~~~~~~~~~~
      src/in_kernel.c:221:2: note: remove the 'if' if its condition is always false
        221 |         if (!start)
            |         ^~~~~~~~~~~
        222 |                 goto out_free;
            |                 ~~~~~~~~~~~~~
      src/in_kernel.c:215:20: note: initialize the variable 'curr_reactor' to silence this warning
        215 |         char *curr_reactor;
            |                           ^
            |                            = NULL
      2 warnings generated.
      
      Which is correct. Setting curr_reactor to NULL avoids the problem.
      
      Link: https://lkml.kernel.org/r/3a35551149e5ee0cb0950035afcb8082c3b5d05b.1707217097.git.bristot@kernel.org
      
      
      
      Cc: stable@vger.kernel.org
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Bill Wendling <morbo@google.com>
      Cc: Justin Stitt <justinstitt@google.com>
      Cc: Donald Zickus <dzickus@redhat.com>
      Fixes: 6d60f896 ("tools/rv: Add in-kernel monitor interface")
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      61ec586b
    • Daniel Bristot de Oliveira's avatar
      tools/rv: Fix Makefile compiler options for clang · f9b2c871
      Daniel Bristot de Oliveira authored
      The following errors are showing up when compiling rv with clang:
      
       $ make HOSTCC=clang CC=clang LLVM_IAS=1
       [...]
        clang -O -g -DVERSION=\"6.8.0-rc1\" -flto=auto -ffat-lto-objects
        -fexceptions -fstack-protector-strong -fasynchronous-unwind-tables
        -fstack-clash-protection  -Wall -Werror=format-security
        -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS
        -Wno-maybe-uninitialized $(pkg-config --cflags libtracefs)
        -I include   -c -o src/utils.o src/utils.c
        clang: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
        warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
        1 warning generated.
      
        clang -o rv -ggdb  src/in_kernel.o src/rv.o src/trace.o src/utils.o $(pkg-config --libs libtracefs)
        src/in_kernel.o: file not recognized: file format not recognized
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        make: *** [Makefile:110: rv] Error 1
      
      Solve these issues by:
        - removing -ffat-lto-objects and -Wno-maybe-uninitialized if using clang
        - informing the linker about -flto=auto
      
      Link: https://lkml.kernel.org/r/ed94a8ddc2ca8c8ef663cfb7ae9dd196c4a66b33.1707217097.git.bristot@kernel.org
      
      
      
      Cc: stable@vger.kernel.org
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Bill Wendling <morbo@google.com>
      Cc: Justin Stitt <justinstitt@google.com>
      Fixes: 4bc4b131 ("rv: Add rv tool")
      Suggested-by: default avatarDonald Zickus <dzickus@redhat.com>
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      f9b2c871
  4. Oct 30, 2023
  5. Apr 25, 2023
  6. Feb 01, 2023
  7. Dec 20, 2022
  8. Dec 09, 2022
    • Daniel Bristot de Oliveira's avatar
      Documentation/rv: Add verification/rv man pages · afc70ccb
      Daniel Bristot de Oliveira authored
      Add man pages for the rv command line, using the same scheme we used
      in rtla.
      
      Link: https://lkml.kernel.org/r/e841d7cfbdfc3ebdaf7cbd40278571940145d829.1668180100.git.bristot@kernel.org
      
      
      
      Cc: Jonathan Corbet <corbet@lwn.net>
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      afc70ccb
    • Daniel Bristot de Oliveira's avatar
      tools/rv: Add in-kernel monitor interface · 6d60f896
      Daniel Bristot de Oliveira authored
      Add the ability to control and trace in-kernel monitors. This is
      a generic interface, it will check for existing monitors and enable
      standard setup, like enabling reactors.
      
      For example:
      
        # rv list
        wip                      wakeup in preemptive per-cpu testing monitor. [OFF]
        wwnr                     wakeup while not running per-task testing model. [OFF]
      
        # rv mon wwnr --help
        rv version 6.1.0-rc4: help
      
        usage: rv mon wwnr [-h] [-q] [-r reactor] [-s] [-v]
      	-h/--help: print this menu and the reactor list
      	-r/--reactor 'reactor': enables the 'reactor'
      	-s/--self: when tracing (-t), also trace rv command
      	-t/--trace: trace monitor's event
      	-v/--verbose: print debug messages
      
        available reactors: nop printk panic
      
        # rv mon wwnr --trace
                <TASK>-PID      [CPU]  TYPE       ID                    STATE x EVENT                    -> NEXT_STATE               FINAL
                    |   |          |     |        |                        |     |                           |                       |
                    rv-3613     [001] event     3613                  running x switch_out               -> not_running              Y
                  sshd-1248     [005] event     1248                  running x switch_out               -> not_running              Y
                <idle>-0        [005] event       71              not_running x wakeup                   -> not_running              Y
                <idle>-0        [005] event       71              not_running x switch_in                -> running                  N
            kcompactd0-71       [005] event       71                  running x switch_out               -> not_running              Y
                <idle>-0        [000] event      860              not_running x wakeup                   -> not_running              Y
                <idle>-0        [000] event      860              not_running x switch_in                -> running                  N
          systemd-oomd-860      [000] event      860                  running x switch_out               -> not_running              Y
                <idle>-0        [000] event      860              not_running x wakeup                   -> not_running              Y
                <idle>-0        [000] event      860              not_running x switch_in                -> running                  N
          systemd-oomd-860      [000] event      860                  running x switch_out               -> not_running              Y
                <idle>-0        [005] event       71              not_running x wakeup                   -> not_running              Y
                <idle>-0        [005] event       71              not_running x switch_in                -> running                  N
            kcompactd0-71       [005] event       71                  running x switch_out               -> not_running              Y
                <idle>-0        [000] event      860              not_running x wakeup                   -> not_running              Y
                <idle>-0        [000] event      860              not_running x switch_in                -> running                  N
          systemd-oomd-860      [000] event      860                  running x switch_out               -> not_running              Y
                <idle>-0        [001] event     3613              not_running x wakeup                   -> not_running              Y
      
      Link: https://lkml.kernel.org/r/1e57547e3acadda6e23949b2672c89e76ec2ec42.1668180100.git.bristot@kernel.org
      
      
      
      Cc: Jonathan Corbet <corbet@lwn.net>
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      6d60f896
    • Daniel Bristot de Oliveira's avatar
      rv: Add rv tool · 4bc4b131
      Daniel Bristot de Oliveira authored
      This is the (user-space) runtime verification tool, named rv.
      
      This tool aims to be the interface for in-kernel rv monitors, as
      well as the home for monitors in user-space (online asynchronous),
      and in *eBPF.
      
      The tool receives a command as the first argument, the current
      commands are:
      
        list	- list all available monitors
        mon	- run a given monitor
      
      Each monitor is an independent piece of software inside the
      tool and can have their own arguments.
      
      There is no monitor implemented in this patch, it only
      adds the basic structure of the tool, based on rtla.
      
        # rv --help
          rv version 6.1.0-rc4: help
      
          usage: rv command [-h] [command_options]
      
      	-h/--help: print this menu
      
      	command: run one of the following command:
      	  list: list all available monitors
      	  mon:  run a monitor
      
      	[command options]: each command has its own set of options
      		           run rv command -h for further information
      
      *dot2bpf is the next patch set, depends on this, doing cleanups.
      
      Link: https://lkml.kernel.org/r/fb51184f3b95aea0d7bfdc33ec09f4153aee84fa.1668180100.git.bristot@kernel.org
      
      
      
      Cc: Jonathan Corbet <corbet@lwn.net>
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      4bc4b131
  9. Oct 20, 2022
  10. Sep 26, 2022
  11. Jul 30, 2022
    • Daniel Bristot de Oliveira's avatar
      rv/monitor: Add the wwnr monitor · ccc319dc
      Daniel Bristot de Oliveira authored
      Per task wakeup while not running (wwnr) monitor.
      
      This model is broken, the reason is that a task can be running in the
      processor without being set as RUNNABLE. Think about a task about to
      sleep:
      
      1:      set_current_state(TASK_UNINTERRUPTIBLE);
      2:      schedule();
      
      And then imagine an IRQ happening in between the lines one and two,
      waking the task up. BOOM, the wakeup will happen while the task is
      running.
      
      Q: Why do we need this model, so?
      A: To test the reactors.
      
      Link: https://lkml.kernel.org/r/473c0fc39967250fdebcff8b620311c11dccad30.1659052063.git.bristot@kernel.org
      
      
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      ccc319dc
    • Daniel Bristot de Oliveira's avatar
      rv/monitor: Add the wip monitor · 10bde81c
      Daniel Bristot de Oliveira authored
      The wakeup in preemptive (wip) monitor verifies if the
      wakeup events always take place with preemption disabled:
      
                           |
                           |
                           v
                         #==================#
                         H    preemptive    H <+
                         #==================#  |
                           |                   |
                           | preempt_disable   | preempt_enable
                           v                   |
          sched_waking   +------------------+  |
        +--------------- |                  |  |
        |                |  non_preemptive  |  |
        +--------------> |                  | -+
                         +------------------+
      
      The wakeup event always takes place with preemption disabled because
      of the scheduler synchronization. However, because the preempt_count
      and its trace event are not atomic with regard to interrupts, some
      inconsistencies might happen.
      
      The documentation illustrates one of these cases.
      
      Link: https://lkml.kernel.org/r/c98ca678df81115fddc04921b3c79720c836b18f.1659052063.git.bristot@kernel.org
      
      
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      10bde81c
    • Daniel Bristot de Oliveira's avatar
      Documentation/rv: Add deterministic automata monitor synthesis documentation · d57aff24
      Daniel Bristot de Oliveira authored
      Add the da_monitor_synthesis.rst introduces some concepts behind the
      Deterministic Automata (DA) monitor synthesis and interface.
      
      Link: https://lkml.kernel.org/r/7873bdb7b2e5d2bc0b2eb6ca0b324af9a0ba27a0.1659052063.git.bristot@kernel.org
      
      
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      d57aff24
    • Daniel Bristot de Oliveira's avatar
      tools/rv: Add dot2k · 24bce201
      Daniel Bristot de Oliveira authored
      transform .dot file into kernel rv monitor
      
      usage: dot2k [-h] -d DOT_FILE -t MONITOR_TYPE [-n MODEL_NAME] [-D DESCRIPTION]
      
      optional arguments:
        -h, --help            show this help message and exit
        -d DOT_FILE, --dot DOT_FILE
        -t MONITOR_TYPE, --monitor_type MONITOR_TYPE
        -n MODEL_NAME, --model_name MODEL_NAME
        -D DESCRIPTION, --description DESCRIPTION
      
      Link: https://lkml.kernel.org/r/083b3ae61e5a62c1e2e5d08009baa91f82181618.1659052063.git.bristot@kernel.org
      
      
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      24bce201
    • Daniel Bristot de Oliveira's avatar
      Documentation/rv: Add deterministic automaton documentation · 4041b9bb
      Daniel Bristot de Oliveira authored
      Add documentation about deterministic automaton and its possible
      representations (formal, graphic, .dot and C).
      
      Link: https://lkml.kernel.org/r/387edaed87630bd5eb37c4275045dfd229700aa6.1659052063.git.bristot@kernel.org
      
      
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      4041b9bb
    • Daniel Bristot de Oliveira's avatar
      tools/rv: Add dot2c · e3c9fc78
      Daniel Bristot de Oliveira authored
      dot2c is a tool that transforms an automata in the graphiviz .dot file
      into an C representation of the automata.
      
      usage: dot2c [-h] dot_file
      
      dot2c: converts a .dot file into a C structure
      
      positional arguments:
        dot_file    The dot file to be converted
      
      optional arguments:
        -h, --help  show this help message and exit
      
      Link: https://lkml.kernel.org/r/b26204ba9509c80bcda31b76cdea31ddb188cd24.1659052063.git.bristot@kernel.org
      
      
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      e3c9fc78
Loading