qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Alexandre Iooss" <erdnaxe@crans.org>,
	"Mahmoud Mandour" <ma.mandourr@gmail.com>
Subject: [PULL 20/21] docs/devel: update tcg-plugins page
Date: Thu, 15 Aug 2024 15:49:10 +0100	[thread overview]
Message-ID: <20240815144911.1931487-21-alex.bennee@linaro.org> (raw)
In-Reply-To: <20240815144911.1931487-1-alex.bennee@linaro.org>

From: Pierrick Bouvier <pierrick.bouvier@linaro.org>

Reflect recent changes on API (inline ops) and new plugins.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240812231945.169310-1-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240813202329.1237572-21-alex.bennee@linaro.org>

diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst
index c03033e4e9..eea1261baa 100644
--- a/docs/about/emulation.rst
+++ b/docs/about/emulation.rst
@@ -207,8 +207,8 @@ Once built a program can be run with multiple plugins loaded each with
 their own arguments::
 
   $QEMU $OTHER_QEMU_ARGS \
-      -plugin contrib/plugin/libhowvec.so,inline=on,count=hint \
-      -plugin contrib/plugin/libhotblocks.so
+      -plugin contrib/plugins/libhowvec.so,inline=on,count=hint \
+      -plugin contrib/plugins/libhotblocks.so
 
 Arguments are plugin specific and can be used to modify their
 behaviour. In this case the howvec plugin is being asked to use inline
@@ -219,6 +219,14 @@ Linux user-mode emulation also evaluates the environment variable
 
   QEMU_PLUGIN="file=contrib/plugins/libhowvec.so,inline=on,count=hint" $QEMU
 
+QEMU plugins avoid to write directly to stdin/stderr, and use the log provided
+by the API (see function ``qemu_plugin_outs``).
+To show output, you may use this additional parameter::
+
+  $QEMU $OTHER_QEMU_ARGS \
+    -d plugin \
+    -plugin contrib/plugins/libhowvec.so,inline=on,count=hint
+
 Example Plugins
 ~~~~~~~~~~~~~~~
 
@@ -260,8 +268,7 @@ Behaviour can be tweaked with the following arguments:
   * - Option
     - Description
   * - inline=true|false
-    - Use faster inline addition of a single counter. Not per-cpu and not
-      thread safe.
+    - Use faster inline addition of a single counter.
   * - idle=true|false
     - Dump the current execution stats whenever the guest vCPU idles
 
@@ -381,6 +388,15 @@ run::
   160          1      0
   135          1      0
 
+Test inline operations
+......................
+
+``tests/plugins/inline.c``
+
+This plugin is used for testing all inline operations, conditional callbacks and
+scoreboard. It prints a per-cpu summary of all events.
+
+
 Hot Blocks
 ..........
 
@@ -394,9 +410,6 @@ with linux-user execution as system emulation tends to generate
 re-translations as blocks from different programs get swapped in and
 out of system memory.
 
-If your program is single-threaded you can use the ``inline`` option for
-slightly faster (but not thread safe) counters.
-
 Example::
 
   $ qemu-aarch64 \
@@ -736,6 +749,28 @@ The plugin will log the reason of exit, for example::
 
   0xd4 reached, exiting
 
+Limit instructions per second
+.............................
+
+This plugin can limit the number of Instructions Per Second that are executed::
+
+    # get number of instructions
+    $ num_insn=$(./build/qemu-x86_64 -plugin ./build/tests/plugin/libinsn.so -d plugin /bin/true |& grep total | sed -e 's/.*: //')
+    # limit speed to execute in 10 seconds
+    $ time ./build/qemu-x86_64 -plugin ./build/contrib/plugins/libips.so,ips=$(($num_insn/10)) /bin/true
+    real 10.000s
+
+
+.. list-table:: IPS arguments
+  :widths: 20 80
+  :header-rows: 1
+
+  * - Option
+    - Description
+  * - ips=N
+    - Maximum number of instructions per cpu that can be executed in one second.
+      The plugin will sleep when the given number of instructions is reached.
+
 Other emulation features
 ------------------------
 
diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst
index d8725c2854..9463692c41 100644
--- a/docs/devel/tcg-plugins.rst
+++ b/docs/devel/tcg-plugins.rst
@@ -61,11 +61,14 @@ translation event the plugin has an option to enumerate the
 instructions in a block of instructions and optionally register
 callbacks to some or all instructions when they are executed.
 
-There is also a facility to add an inline event where code to
-increment a counter can be directly inlined with the translation.
-Currently only a simple increment is supported. This is not atomic so
-can miss counts. If you want absolute precision you should use a
-callback which can then ensure atomicity itself.
+There is also a facility to add inline instructions doing various operations,
+like adding or storing an immediate value. It is also possible to execute a
+callback conditionally, with condition being evaluated inline. All those inline
+operations are associated to a ``scoreboard``, which is a thread-local storage
+automatically expanded when new cores/threads are created and that can be
+accessed/modified in a thread-safe way without any lock needed. Combining inline
+operations and conditional callbacks offer a more efficient way to instrument
+binaries, compared to classic callbacks.
 
 Finally when QEMU exits all the registered *atexit* callbacks are
 invoked.
-- 
2.39.2



  parent reply	other threads:[~2024-08-15 14:56 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-15 14:48 [PULL for 9.1 00/21] Some fixes for 9.1-rc3 (build, replay, docs, plugins) Alex Bennée
2024-08-15 14:48 ` [PULL 01/21] tests/avocado: Re-enable gdbsim-r5f562n8 testing U-Boot Alex Bennée
2024-08-15 14:48 ` [PULL 02/21] Makefile: trigger re-configure on updated pythondeps Alex Bennée
2024-08-15 14:48 ` [PULL 03/21] configure: Fix arch detection for GDB_HAS_MTE Alex Bennée
2024-08-15 14:48 ` [PULL 04/21] configure: Avoid use of param. expansion when using gdb_version Alex Bennée
2024-08-15 14:48 ` [PULL 05/21] configure: Fix GDB version detection for GDB_HAS_MTE Alex Bennée
2024-08-15 14:48 ` [PULL 06/21] scripts/checkpatch: more checks on files imported from Linux Alex Bennée
2024-08-15 14:48 ` [PULL 07/21] target/i386: allow access_ptr to force slow path on failed probe Alex Bennée
2024-08-15 14:48 ` [PULL 08/21] buildsys: Fix building without plugins on Darwin Alex Bennée
2024-08-15 14:48 ` [PULL 09/21] scripts/replay-dump.py: Update to current rr record format Alex Bennée
2024-08-15 14:49 ` [PULL 10/21] scripts/replay-dump.py: rejig decoders in event number order Alex Bennée
2024-08-15 14:49 ` [PULL 11/21] tests/avocado: excercise scripts/replay-dump.py in replay tests Alex Bennée
2024-08-15 14:49 ` [PULL 12/21] replay: allow runstate shutdown->running when replaying trace Alex Bennée
2024-08-15 14:49 ` [PULL 13/21] Revert "replay: stop us hanging in rr_wait_io_event" Alex Bennée
2024-08-15 14:49 ` [PULL 14/21] tests/avocado: replay_kernel.py add x86-64 q35 machine test Alex Bennée
2024-08-15 14:49 ` [PULL 15/21] chardev: set record/replay on the base device of a muxed device Alex Bennée
2024-08-19 11:46   ` Peter Maydell
2024-08-15 14:49 ` [PULL 16/21] virtio-net: Use replay_schedule_bh_event for bhs that affect machine state Alex Bennée
2024-08-15 14:49 ` [PULL 17/21] virtio-net: Use virtual time for RSC timers Alex Bennée
2024-08-15 14:49 ` [PULL 18/21] savevm: Fix load_snapshot error path crash Alex Bennée
2024-08-15 14:49 ` [PULL 19/21] docs: Fix some typos (found by typos) and grammar issues Alex Bennée
2024-08-15 14:49 ` Alex Bennée [this message]
2024-08-15 14:49 ` [PULL 21/21] plugins: fix race condition with scoreboards Alex Bennée
2024-08-15 22:28 ` [PULL for 9.1 00/21] Some fixes for 9.1-rc3 (build, replay, docs, plugins) Richard Henderson
2024-08-16 12:54   ` Alex Bennée
2024-08-16 13:05     ` Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240815144911.1931487-21-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=erdnaxe@crans.org \
    --cc=ma.mandourr@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).