[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [Qemu-block] [PATCH 3/5] coroutines: abort if we try to
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [Qemu-block] [PATCH 3/5] coroutines: abort if we try to enter a still-sleeping coroutine |
Date: |
Mon, 20 Nov 2017 11:43:34 +0000 |
User-agent: |
Mutt/1.9.1 (2017-09-22) |
On Sun, Nov 19, 2017 at 09:46:44PM -0500, Jeff Cody wrote:
> diff --git a/include/qemu/coroutine_int.h b/include/qemu/coroutine_int.h
> index 931cdc9..b071217 100644
> --- a/include/qemu/coroutine_int.h
> +++ b/include/qemu/coroutine_int.h
> @@ -56,6 +56,8 @@ struct Coroutine {
>
> int scheduled;
>
> + int sleeping;
s/int/bool/
BTW an alternative to adding individual bools is to implement a finite
state machine for the entire coroutine lifecycle. A single function can
validate all state transitions:
void check_state_transition(CoState old, CoState new,
const char *action)
{
const char *errmsg = fsm[old][new];
if (!errmsg) {
return; /* valid transition! */
}
fprintf(stderr, "Cannot %s coroutine from %s state\n",
action, state_name[old]);
abort();
}
Specifying fsm[][] forces us to think through all possible state
transitions. This approach is proactive whereas adding bool flags is
reactive since it only covers a subset of states that were encountered
after crashes. I'm not sure if it's worth it though :).
signature.asc
Description: PGP signature
- [Qemu-devel] [PATCH 1/5] blockjob: do not allow coroutine double entry or entry-after-completion, (continued)
- [Qemu-devel] [PATCH 2/5] coroutine: abort if we try to enter coroutine scheduled for another ctx, Jeff Cody, 2017/11/19
- [Qemu-devel] [PATCH 4/5] qemu-iotests: add option in common.qemu for mismatch only, Jeff Cody, 2017/11/19
- [Qemu-devel] [PATCH 3/5] coroutines: abort if we try to enter a still-sleeping coroutine, Jeff Cody, 2017/11/19
- Re: [Qemu-devel] [Qemu-block] [PATCH 3/5] coroutines: abort if we try to enter a still-sleeping coroutine,
Stefan Hajnoczi <=
- Re: [Qemu-devel] [PATCH 3/5] coroutines: abort if we try to enter a still-sleeping coroutine, Paolo Bonzini, 2017/11/20
- Re: [Qemu-devel] [PATCH 3/5] coroutines: abort if we try to enter a still-sleeping coroutine, Jeff Cody, 2017/11/20
- Re: [Qemu-devel] [PATCH 3/5] coroutines: abort if we try to enter a still-sleeping coroutine, Paolo Bonzini, 2017/11/20
- Re: [Qemu-devel] [PATCH 3/5] coroutines: abort if we try to enter a still-sleeping coroutine, Jeff Cody, 2017/11/20
- Re: [Qemu-devel] [PATCH 3/5] coroutines: abort if we try to enter a still-sleeping coroutine, Paolo Bonzini, 2017/11/20
- Re: [Qemu-devel] [PATCH 3/5] coroutines: abort if we try to enter a still-sleeping coroutine, Jeff Cody, 2017/11/20
[Qemu-devel] [PATCH 5/5] qemu-iotest: add test for blockjob coroutine race condition, Jeff Cody, 2017/11/19