You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the emulator currently operates using sequential emulation, the
execution time for the boot process is relatively long, which can result
in the generation of RCU CPU stall warnings.
To address this issue, there are several potential solutions:
1. Scale the frequency to slow down emulator time during the boot
process, thereby eliminating RCU CPU stall warnings.
2. During the boot process, avoid using 'clock_gettime' to update ticks
and instead manage the tick increment relationship manually.
3. Implement multi-threaded emulation to accelerate the emulator's
execution speed.
For the third point, while implementing multi-threaded emulation can
significantly accelerate the emulator's execution speed, it cannot
guarantee that this issue will not reappear as the number of cores
increases in the future. Therefore, a better approach is to use methods
1 and 2 to allow the emulator to set an expected time for completing the
boot process.
The scale method requires three pieces of information to be implemented:
- the cost of 'semu_timer_clocksource'
- percentage of 'semu_timer_clocksource' within the boot process
- the number of times 'semu_timer_clocksource' is called.
In contrast, the increment method only requires the third information to
be implemented, making its implementation simpler.
Furthermore, through statistical analysis, we found that the other two
values (cost and percentage) exhibit different distributions across
different environments. Therefore, using the scale method would require
an additional profiling step when the emulator starts, adding complexity
to the implementation.
Finally, since the increment method does not obtain real-time timestamps
during the boot process, its overhead is lower compared to the scale
method. Because 'semu_timer_clocksource' is called frequently, this
reduction in overhead accumulates and results in a noticeable
performance improvement.
Therefore, this commit opts for the increment method to address this
issue. This commit divides time into emulator time and real time. During
the boot process, the timer manage the ticks increment to slow down the
growth of emulator time, eliminating RCU CPU stall warnings. After the
boot process is complete, the growth of emulator time aligns with real
time.
According to Using RCU’s CPU Stall Detector [1], the grace period for
RCU CPU stalls is typically set to 21 seconds. By dividing this value by
two as the expected completion time, we can provide a sufficient buffer
to reduce the impact of errors and avoid RCU CPU stall warnings.
By statistic, the number of times 'semu_timer_clocksource' called is
approximately 'SMP count * 2.15 * 1e8'. By the time the boot process is
completed, the emulator will have a total of 'boot seconds * frequency'
ticks. Therefore, each time, '(boot seconds * frequency) / (2.15 * 1e8 *
SMP count)' ticks need to be added.
Close#51
[1] https://docs.kernel.org/RCU/stallwarn.html#config-rcu-cpu-stall-timeout
0 commit comments