mirror of
https://github.com/php/php-src.git
synced 2024-12-02 22:34:55 +08:00
Synchronize zend_jit_stop_counter_handlers()
Avoid stopping counters repeatedly from different threads/processes. Fixes GH-11609 Closes GH-11806
This commit is contained in:
parent
3148da8ee1
commit
b80bebc278
3
NEWS
3
NEWS
@ -2,6 +2,9 @@ PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 8.3.0beta3
|
||||
|
||||
- Opcache:
|
||||
. Avoid resetting JIT counter handlers from multiple processes/threads.
|
||||
(ilutov)
|
||||
|
||||
03 Aug 2023, PHP 8.3.0beta2
|
||||
|
||||
|
@ -261,6 +261,7 @@ typedef struct _zend_accel_shared_globals {
|
||||
LONGLONG restart_in;
|
||||
#endif
|
||||
bool restart_in_progress;
|
||||
bool jit_counters_stopped;
|
||||
|
||||
/* Preloading */
|
||||
zend_persistent_script *preload_script;
|
||||
|
@ -63,6 +63,7 @@ static int zend_jit_trace_startup(bool reattached)
|
||||
ZEND_JIT_EXIT_COUNTERS = 0;
|
||||
ZCSG(jit_traces) = zend_jit_traces;
|
||||
ZCSG(jit_exit_groups) = zend_jit_exit_groups;
|
||||
ZCSG(jit_counters_stopped) = false;
|
||||
} else {
|
||||
zend_jit_traces = ZCSG(jit_traces);
|
||||
if (!zend_jit_traces) {
|
||||
@ -7255,16 +7256,23 @@ static void zend_jit_stop_persistent_script(zend_persistent_script *script)
|
||||
/* Get all scripts which are accelerated by JIT */
|
||||
static void zend_jit_stop_counter_handlers(void)
|
||||
{
|
||||
if (ZCSG(jit_counters_stopped)) {
|
||||
return;
|
||||
}
|
||||
|
||||
zend_shared_alloc_lock();
|
||||
/* mprotect has an extreme overhead, avoid calls to it for every function. */
|
||||
SHM_UNPROTECT();
|
||||
for (uint32_t i = 0; i < ZCSG(hash).max_num_entries; i++) {
|
||||
zend_accel_hash_entry *cache_entry;
|
||||
for (cache_entry = ZCSG(hash).hash_table[i]; cache_entry; cache_entry = cache_entry->next) {
|
||||
zend_persistent_script *script;
|
||||
if (cache_entry->indirect) continue;
|
||||
script = (zend_persistent_script *)cache_entry->data;
|
||||
zend_jit_stop_persistent_script(script);
|
||||
if (!ZCSG(jit_counters_stopped)) {
|
||||
ZCSG(jit_counters_stopped) = true;
|
||||
for (uint32_t i = 0; i < ZCSG(hash).max_num_entries; i++) {
|
||||
zend_accel_hash_entry *cache_entry;
|
||||
for (cache_entry = ZCSG(hash).hash_table[i]; cache_entry; cache_entry = cache_entry->next) {
|
||||
zend_persistent_script *script;
|
||||
if (cache_entry->indirect) continue;
|
||||
script = (zend_persistent_script *)cache_entry->data;
|
||||
zend_jit_stop_persistent_script(script);
|
||||
}
|
||||
}
|
||||
}
|
||||
SHM_PROTECT();
|
||||
@ -8438,6 +8446,7 @@ static void zend_jit_trace_restart(void)
|
||||
ZEND_JIT_COUNTER_NUM = 0;
|
||||
ZEND_JIT_EXIT_NUM = 0;
|
||||
ZEND_JIT_EXIT_COUNTERS = 0;
|
||||
ZCSG(jit_counters_stopped) = false;
|
||||
|
||||
zend_jit_trace_init_caches();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user