| 1397 | } |
| 1398 | |
| 1399 | void cbm_work_note_path(cbm_work_kind_t kind, void *site, const char *path, bool failed) { |
| 1400 | if (!cbm_memev_enabled()) { |
| 1401 | return; |
| 1402 | } |
| 1403 | tl_state_t *st = tl_get(); |
| 1404 | if (!st || st->busy) { |
| 1405 | return; |
| 1406 | } |
| 1407 | st->busy = true; |
| 1408 | uint64_t h = mix(path_hash(path) ^ ((uint64_t)kind << 58)) | 1U; |
| 1409 | uint64_t repeat = 0; |
| 1410 | uint32_t idx = (uint32_t)(h & (MEMEV_PATH_CAP - 1)); |
| 1411 | for (uint32_t probe = 0; probe < MEMEV_PATH_CAP; probe++) { |
| 1412 | uint64_t seen = atomic_load_explicit(&g_path_hashes[idx], memory_order_relaxed); |
| 1413 | if (seen == h) { |
| 1414 | repeat = 1; |
| 1415 | break; |
| 1416 | } |
| 1417 | if (seen == 0) { |
| 1418 | uint64_t expect = 0; |
| 1419 | if (atomic_compare_exchange_strong_explicit( |
| 1420 | &g_path_hashes[idx], &expect, h, memory_order_relaxed, memory_order_relaxed)) { |
| 1421 | break; |
| 1422 | } |
| 1423 | if (expect == h) { |
| 1424 | repeat = 1; |
| 1425 | break; |
| 1426 | } |
| 1427 | } |
| 1428 | idx = (idx + 1) & (MEMEV_PATH_CAP - 1); |
| 1429 | } |
| 1430 | work_add(st, kind, (uintptr_t)site, 0, failed ? 1 : 0, 0, repeat); |
| 1431 | st->busy = false; |
| 1432 | } |
| 1433 | |
| 1434 | void cbm_work_note_ht(cbm_work_kind_t kind, void *site, const void *table, const char *key, |
| 1435 | uint64_t generation, bool hit) { |
no test coverage detected