Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase of PR 1/11: @Clementguidi: dynamic: Refactor logic to perform multiple updates (dynamic runtime init) #1851

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

bernhardkaindl
Copy link
Contributor

@bernhardkaindl bernhardkaindl commented Nov 29, 2023

This is #1702 (first PR of @clementguidi's series) below rebased to the current master to hopefully fix the remaining test failures.

The description for this first PR in the series is:

First, we refactor the life cycle of dynamic structures so a dynamic update can be triggered at anytime during execution, any amount of times. This will allow the agent to call mcount_dynamic_update() multiple times at runtime.

I only did:

gh pr checkout 1702
git switch -c this-branch
git rebase master
git push

Hopefully, this fixes the remaining test failures from #1702:

Copied from the description of #1702:

This is the first PR in a series of patches intended to bring runtime dynamic tracing on x86_64 to uftrace.

#1702 🠈
#1703
#1704
#1705
#1745
#1746
#1747
#1748
#1749
#1750
#1751

First, we refactor the life cycle of dynamic structures so a dynamic update can be triggered at anytime during execution, any amount of times. This will allow the agent to call mcount_dynamic_update() multiple times at runtime.

Related: #1698

azharivs and others added 9 commits November 28, 2023 18:36
This is in preparation of runtime dynamic patching. This commit
guarantees that dynamic info is read only once for the target binary and
for each module.

Co-authored-by: Gabriel-Andrew Pollo-Guilbert <gabrielpolloguilbert@gmail.com>
Signed-off-by: Seyed-Vahid Azhari <vazhari@ciena.com>
If 'mcount_dynamic_update' is called multiple times (e.g. at runtime),
it initializes the size filter only once.

Signed-off-by: Clément Guidi <cguidi@ciena.com>
Skip the initialization of the disassembly engine with it has already
been performed.

Signed-off-by: Clément Guidi <cguidi@ciena.com>
The dynamic pattern list is not reused from a dynamic update to another,
keeping libmcount stateless in that regard.

Co-authored-by: Gabriel-Andrew Pollo-Guilbert <gabrielpolloguilbert@gmail.com>
Signed-off-by: Clément Guidi <cguidi@ciena.com>
The 'mcount_dynamic_update' is now safe to call multiple times,
including at runtime. On each call, it will perform patching and
unpatching of the target (not implemented yet).

Signed-off-by: Clément Guidi <cguidi@ciena.com>
Install a trampoline for each loaded module map, on initialization. Keep
the trampolines in memory to allow for dynamic patching at runtime.
Clear the trampolines on libmcount exit.

Co-authored-by: Gabriel-Andrew Pollo-Guilbert <gabrielpolloguilbert@gmail.com>
Signed-off-by: Clément Guidi <cguidi@ciena.com>
Trigger architecture specific dynamic initialization when initializing
the dynamic instrumentation mechanics.

Co-authored-by: Gabriel-Andrew Pollo-Guilbert <gabrielpolloguilbert@gmail.com>
Signed-off-by: Clément Guidi <cguidi@ciena.com>
Don't save instructions if they are already present in the code hmap.

Signed-off-by: Clément Guidi <cguidi@ciena.com>
Commands used:
gh pr checkout 1702
git switch -c new-branch
git rebase master        # (no warnings, no conflicts)
git push

Signed-off-by: Bernhard Kaindl <43588962+bernhardkaindl@users.noreply.github.com>
@bernhardkaindl bernhardkaindl changed the title Clementguidi dynamic runtime init Rebase of PR 1/11: @Clementguidi: dynamic: Refactor logic to perform multiple updates (dynamic runtime init) Nov 29, 2023
@namhyung
Copy link
Owner

Thanks for doing this! I'll check the code.

In this case, you added some work on others. Then you need to add your own Signed-off-by line at the bottom.

@bernhardkaindl
Copy link
Contributor Author

@namhyung: Done now, added a final commit at the bottom:

@namhyung
Copy link
Owner

namhyung commented Dec 8, 2023

I'm still seeing some test failures:

$ make -j8 runtest TESTARG=dynamic
  TEST     test_run
Start 15 tests with 8 worker

Compiler                  gcc                                           clang                                       
Runtime test case         pg             finstrument-fu fpatchable-fun  pg             finstrument-fu fpatchable-fun
------------------------: O0 O1 O2 O3 Os O0 O1 O2 O3 Os O0 O1 O2 O3 Os  O0 O1 O2 O3 Os O0 O1 O2 O3 Os O0 O1 O2 O3 Os
136 dynamic             : OK OK OK OK OK SK SK SK SK SK OK OK OK OK OK  SK SK SK SK SK SK SK SK SK SK SK SK SK SK SK
138 kernel_dynamic      : SK SK SK SK SK SK SK SK SK SK SK SK SK SK SK  SK SK SK SK SK SK SK SK SK SK SK SK SK SK SK
139 kernel_dynamic2     : SK SK SK SK SK SK SK SK SK SK SK SK SK SK SK  SK SK SK SK SK SK SK SK SK SK SK SK SK SK SK
140 dynamic_xray        : OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK  OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK
223 dynamic_full        : NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ  NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ
224 dynamic_lib         : NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ  NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ
225 dynamic_size        : NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ  NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ
232 dynamic_unpatch     : OK OK OK OK OK SK SK SK SK SK OK OK OK OK OK  SK SK SK SK SK SK SK SK SK SK SK SK SK SK SK
233 dynamic_unpatch2    : NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ  NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ
248 dynamic_dlopen      : NG NG NG NG NG NG NG NG NG NG NG NG NG NG NG  NG NG NG NG NG NG NG NG NG NG NG NG NG NG NG
263 patchable_dynamic   : OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK  OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK
264 patchable_dynamic2  : OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK  OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK
265 patchable_dynamic3  : OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK  OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK
266 patchable_dynamic4  : OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK  OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK
267 patchable_dynamic5  : OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK  OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK


runtime test stats
====================
total   450  Tests executed (success: 44.44%)
  OK:   200  Test succeeded
  OK:     0  Test succeeded (with some fixup)
  NG:    30  Different test result
  NZ:   120  Non-zero return value
  SG:     0  Abnormal exit by signal
  TM:     0  Test ran too long
  BI:     0  Build failed
  LA:     0  Unsupported Language
  SK:   100  Skipped

@bernhardkaindl
Copy link
Contributor Author

@clementguidi: FYI, This would still cause regression(s), can you check?

(Maybe fixed by other parts of your series?

@clementguidi
Copy link
Contributor

Hi @bernhardkaindl, thank you I'll have a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants