Skip to content

Devel/sampling#2

Closed
briancoutinho0905 wants to merge 21 commits intopowerjg:masterfrom
briancoutinho0905:devel/sampling
Closed

Devel/sampling#2
briancoutinho0905 wants to merge 21 commits intopowerjg:masterfrom
briancoutinho0905:devel/sampling

Conversation

@briancoutinho0905
Copy link

No description provided.

powerjg and others added 21 commits May 23, 2016 10:21
This removes the sync between the thread contexts on m5ops. This works
for some m5 ops, but not others. It's needed for m5_readfile, which I
use.

See also: http://reviews.gem5.org/r/2774/
This patch makes kvm work for both Intel and AMD CPUs.
See http://reviews.gem5.org/r/2613/
I really have no idea what's in the changeset. But it seems to be
required to get KVM to work on the CSL machines with RHEL6.

Patch is from Nilay.
Previously, before a CPU was switched out, the TLB was always flushed
Now, we first call takeOverFrom with the TLB. We only flush
the TLB right before the CPU is switched in.
This changeset also contains the needed code for x86 to
takeOverFrom with the TLB, similar changes may be needed for the ARM
architecture.
With this changeset, when you switch from atomic to timing mode the
TLB is warm.
Previously, when forking, the thread states were inconsistent.
Now, after a fork, we re-create all the needed threads.
This allows you to run in *single-threaded* mode after a fork.
There would need to be a way to migrate the threads to conintue
in threaded mode.
This adds a couple of example config files for using kvm and sampling.
Additionally, it adds a set of python files similar to the simple FS
configs from Learning gem5.
simply moved around code from original sample_2d.py
the Sample() function for simulating at a single sample point
and sampleROI() wrapper.
The example script sample_2d.py shows the usage of sampleROI()
made changes to the library so generateSamples() is more generic
 sample_one_var.py gives an example of doing online stats.
The key idea with this sample script is to run as many simulations
at a sample point to hit a pre-defined bound on the error in the
estimated mean.
1. Added better documentation for the example scripts
2. Minor bug fixes
3. Miscellaneous changes
…and memory controller. This is used for adding random perturbations for the purpose of sampling. The max memory delay can be set using the --max_random_delay
@briancoutinho0905
Copy link
Author

Added the sampling utilities - util/sampling/tardis_analysis.py

@powerjg powerjg deleted the branch powerjg:master July 14, 2023 16:53
@powerjg powerjg closed this Jul 14, 2023
powerjg pushed a commit that referenced this pull request Aug 21, 2025
Apply construct-on-first-use scheme to address this issue.

==2940471==ERROR: AddressSanitizer: initialization-order-fiasco on address 0x00001bd22044 at pc 0x0000045b8041 bp 0x7ffefca16730 sp 0x7ffefca16728
READ of size 4 at 0x00001bd22044 thread T0
    #0 0x0000045b8040 in gem5::DrainManager::state() const gem5/sim/drain.hh:152
    #1 0x0000045b8040 in gem5::Drainable::Drainable() gem5/sim/drain.cc:199
    #2 0x000004790b13 in gem5::SimObject::SimObject() gem5/sim/sim_object.cc:71
    #3 0x000000926dee in DefaultRequestPort gem5/mem/port.cc:67
    #4 0x000000926dee in __static_initialization_and_destruction_0 gem5/mem/port.cc:110
    #5 0x000000926dee in _GLOBAL__sub_I__ZN4gem511RequestPortC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS_9SimObjectEs gem5/mem/port.cc:208
    gem5#6 0x7fd81e6b6eba in call_init ../csu/libc-start.c:145
powerjg pushed a commit that referenced this pull request Aug 21, 2025
We can remedy this with proper initializations. The offending variable was
TargetList's canMergeWrites, but I also fixed up everything in MSHR.

gem5/mem/cache/mshr.hh:169:11: runtime error: load of value 8, which is not a valid value for type 'bool'
    #0 0x000003e0a992 in gem5::MSHR::TargetList::TargetList(gem5::MSHR::TargetList const&) gem5/mem/cache/mshr.hh:169
    #1 0x000003e0b84c in gem5::MSHR::MSHR(gem5::MSHR const&) gem5/mem/cache/mshr.hh:74
    #2 0x000003e0d83b in void std::_Construct<gem5::MSHR, gem5::MSHR const&>(gem5::MSHR*, gem5::MSHR const&) /spec/compilers/gcc-15.1.0/include/c++/15.1.0/bits/stl_construct.h:133
    #3 0x000003e0d83b in gem5::MSHR* std::__do_uninit_fill_n<gem5::MSHR*, unsigned long, gem5::MSHR>(gem5::MSHR*, unsigned long, gem5::MSHR const&) /spec/compilers/gcc-15.1.0/include/c++/15.1.0/bits/stl_uninitialized.h:470
powerjg pushed a commit that referenced this pull request Mar 9, 2026
Static storage duration objects that has non-trivial destructor are bad.
And a function-local static reference of the form static T& t = *new T;
is allowed
Reference for the style guide:
https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables

Background:
There's a segmentation fault on the arm server if I run the gem5
simulation with --dry-run, do m5.instantiation() but no m5.simulation().

Stack trace:
Thread 1 "gem5.opt" received signal SIGSEGV, Segmentation fault.
__GI_strcmp () at ../sysdeps/aarch64/strcmp.S:136
warning: 136    ../sysdeps/aarch64/strcmp.S: No such file or directory
(gdb) bt
#0  __GI_strcmp () at ../sysdeps/aarch64/strcmp.S:136
#1 0x0000aaaab415f424 in sc_gem5::(anonymous namespace)::findEventIn
(events=std::vector of length 2, capacity 2 = {...}, name="event_0") at
/usr/include/c++/14/bits/basic_string.h:227
#2 sc_gem5::(anonymous namespace)::popEvent (events=0xaaaac00aed50
<sc_gem5::topLevelEvents()::topLevelEvents>, name="event_0") at
src/systemc/core/event.cc:68
#3 sc_gem5::Event::~Event (this=0xaaaac1d8b000, __in_chrg=<optimized
out>) at src/systemc/core/event.cc:150
#4 0x0000aaaab417e95c in sc_core::sc_event::~sc_event (this=<optimized
out>, __in_chrg=<optimized out>) at src/systemc/core/sc_event.cc:321
#5  0x0000aaaabf7b39e0 in scx::async_request::~async_request() ()
gem5#6 0x0000aaaabf7b12d4 in scx::scheduler_mapping::~scheduler_mapping() ()
gem5#7 0x0000aaaabf7b1498 in scx::scheduler_mapping::~scheduler_mapping() ()
gem5#8 0x0000aaaabf7adfb4 in scx::scx_simcontroller::~scx_simcontroller() ()
gem5#9 0x0000ffffe7b5946c in __run_exit_handlers (status=0,
listp=0xffffe7cd0660 <__exit_funcs>,
run_list_atexit=run_list_atexit@entry=true,
run_dtors=run_dtors@entry=true) at ./stdlib/exit.c:118
gem5#10 0x0000ffffe7b59560 [PAC] in __GI_exit (status=<optimized out>) at
./stdlib/exit.c:148
gem5#11 0x0000ffffe7b42220 [PAC] in __libc_start_call_main
(main=main@entry=0xaaaab6af43a0 <main(int, char**)>, argc=argc@entry=15,
argv=argv@entry=0xffffffffeee8) at
../sysdeps/nptl/libc_start_call_main.h:74
gem5#12 0x0000ffffe7b422fc [PAC] in __libc_start_main_impl
(main=0xaaaab6af43a0 <main(int, char**)>, argc=15, argv=0xffffffffeee8,
init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
    stack_end=<optimized out>) at ../csu/libc-start.c:360
gem5#13 0x0000aaaab4003b30 [PAC] in _start ()

The issue seems to be the destruction order. There's a static
topLevelEvents() that will be used in Event() ctor with sc_event. The
segmentation fault happens when topLevelEvents already be destruct
before ~Event calling destructor that will use topLevelEvents.
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.

2 participants