venus: abort when stuck

This gives

  MESA-VIRTIO: debug: stuck in ring seqno wait with iter at 4096
  MESA-VIRTIO: debug: stuck in ring seqno wait with iter at 8192
  MESA-VIRTIO: debug: stuck in ring seqno wait with iter at 12288
  MESA-VIRTIO: debug: stuck in ring seqno wait with iter at 16384
  MESA-VIRTIO: debug: aborting
  Aborted

which should be more friendly than printing the messages forever.

On my i7-7820HQ, this aborts after roughly 4+8+16+32=60 seconds

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15200>
This commit is contained in:
Chia-I Wu 2022-02-28 14:28:36 -08:00 committed by Marge Bot
parent ccf4bcd162
commit bbbbf39559
2 changed files with 10 additions and 1 deletions

View File

@ -22,6 +22,7 @@ static const struct debug_control vn_debug_options[] = {
{ "result", VN_DEBUG_RESULT },
{ "vtest", VN_DEBUG_VTEST },
{ "wsi", VN_DEBUG_WSI },
{ "no_abort", VN_DEBUG_NO_ABORT },
{ NULL, 0 },
};
@ -79,6 +80,7 @@ vn_relax(uint32_t *iter, const char *reason)
const uint32_t busy_wait_order = 4;
const uint32_t base_sleep_us = 10;
const uint32_t warn_order = 12;
const uint32_t abort_order = 14;
(*iter)++;
if (*iter < (1 << busy_wait_order)) {
@ -89,9 +91,15 @@ vn_relax(uint32_t *iter, const char *reason)
/* warn occasionally if we have slept at least 1.28ms for 2048 times (plus
* another 2047 shorter sleeps)
*/
if (unlikely(*iter % (1 << warn_order) == 0))
if (unlikely(*iter % (1 << warn_order) == 0)) {
vn_log(NULL, "stuck in %s wait with iter at %d", reason, *iter);
if (*iter >= (1 << abort_order) && !VN_DEBUG(NO_ABORT)) {
vn_log(NULL, "aborting");
abort();
}
}
const uint32_t shift = util_last_bit(*iter) - busy_wait_order - 1;
os_time_sleep(base_sleep_us << shift);
}

View File

@ -137,6 +137,7 @@ enum vn_debug {
VN_DEBUG_RESULT = 1ull << 1,
VN_DEBUG_VTEST = 1ull << 2,
VN_DEBUG_WSI = 1ull << 3,
VN_DEBUG_NO_ABORT = 1ull << 4,
};
typedef uint64_t vn_object_id;