mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
util/async: add a human-readable name to BHs for debugging
It can be difficult to debug issues with BHs in production environments. Although BHs can usually be identified by looking up their ->cb() function pointer, this requires debug information for the program. It is also not possible to print human-readable diagnostics about BHs because they have no identifier. This patch adds a name to each BH. The name is not unique per instance but differentiates between cb() functions, which is usually enough. It's done by changing aio_bh_new() and friends to macros that stringify cb. The next patch will use the name field when reporting leaked BHs. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20210414200247.917496-2-stefanha@redhat.com>
This commit is contained in:
parent
711c0418c8
commit
0f08586c71
5 changed files with 43 additions and 11 deletions
|
@ -292,19 +292,44 @@ void aio_context_acquire(AioContext *ctx);
|
|||
void aio_context_release(AioContext *ctx);
|
||||
|
||||
/**
|
||||
* aio_bh_schedule_oneshot: Allocate a new bottom half structure that will run
|
||||
* only once and as soon as possible.
|
||||
* aio_bh_schedule_oneshot_full: Allocate a new bottom half structure that will
|
||||
* run only once and as soon as possible.
|
||||
*
|
||||
* @name: A human-readable identifier for debugging purposes.
|
||||
*/
|
||||
void aio_bh_schedule_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque);
|
||||
void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* aio_bh_new: Allocate a new bottom half structure.
|
||||
* aio_bh_schedule_oneshot: Allocate a new bottom half structure that will run
|
||||
* only once and as soon as possible.
|
||||
*
|
||||
* A convenience wrapper for aio_bh_schedule_oneshot_full() that uses cb as the
|
||||
* name string.
|
||||
*/
|
||||
#define aio_bh_schedule_oneshot(ctx, cb, opaque) \
|
||||
aio_bh_schedule_oneshot_full((ctx), (cb), (opaque), (stringify(cb)))
|
||||
|
||||
/**
|
||||
* aio_bh_new_full: Allocate a new bottom half structure.
|
||||
*
|
||||
* Bottom halves are lightweight callbacks whose invocation is guaranteed
|
||||
* to be wait-free, thread-safe and signal-safe. The #QEMUBH structure
|
||||
* is opaque and must be allocated prior to its use.
|
||||
*
|
||||
* @name: A human-readable identifier for debugging purposes.
|
||||
*/
|
||||
QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque);
|
||||
QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* aio_bh_new: Allocate a new bottom half structure
|
||||
*
|
||||
* A convenience wrapper for aio_bh_new_full() that uses the cb as the name
|
||||
* string.
|
||||
*/
|
||||
#define aio_bh_new(ctx, cb, opaque) \
|
||||
aio_bh_new_full((ctx), (cb), (opaque), (stringify(cb)))
|
||||
|
||||
/**
|
||||
* aio_notify: Force processing of pending events.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue