mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-09-21 12:11:49 +08:00
closures: fix closure_sync + closure debugging
originally, stack closures were only used synchronously, and with the original implementation of closure_sync() the ref never hit 0; thus, closure_put_after_sub() assumes that if the ref hits 0 it's on the debug list, in debug mode. that's no longer true with the current implementation of closure_sync, so we need a new magic so closure_debug_destroy() doesn't pop an assert. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
0435773239
commit
29f1c1ae6d
@ -159,6 +159,7 @@ struct closure {
|
|||||||
#ifdef CONFIG_DEBUG_CLOSURES
|
#ifdef CONFIG_DEBUG_CLOSURES
|
||||||
#define CLOSURE_MAGIC_DEAD 0xc054dead
|
#define CLOSURE_MAGIC_DEAD 0xc054dead
|
||||||
#define CLOSURE_MAGIC_ALIVE 0xc054a11e
|
#define CLOSURE_MAGIC_ALIVE 0xc054a11e
|
||||||
|
#define CLOSURE_MAGIC_STACK 0xc05451cc
|
||||||
|
|
||||||
unsigned int magic;
|
unsigned int magic;
|
||||||
struct list_head all;
|
struct list_head all;
|
||||||
@ -323,12 +324,18 @@ static inline void closure_init_stack(struct closure *cl)
|
|||||||
{
|
{
|
||||||
memset(cl, 0, sizeof(struct closure));
|
memset(cl, 0, sizeof(struct closure));
|
||||||
atomic_set(&cl->remaining, CLOSURE_REMAINING_INITIALIZER);
|
atomic_set(&cl->remaining, CLOSURE_REMAINING_INITIALIZER);
|
||||||
|
#ifdef CONFIG_DEBUG_CLOSURES
|
||||||
|
cl->magic = CLOSURE_MAGIC_STACK;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void closure_init_stack_release(struct closure *cl)
|
static inline void closure_init_stack_release(struct closure *cl)
|
||||||
{
|
{
|
||||||
memset(cl, 0, sizeof(struct closure));
|
memset(cl, 0, sizeof(struct closure));
|
||||||
atomic_set_release(&cl->remaining, CLOSURE_REMAINING_INITIALIZER);
|
atomic_set_release(&cl->remaining, CLOSURE_REMAINING_INITIALIZER);
|
||||||
|
#ifdef CONFIG_DEBUG_CLOSURES
|
||||||
|
cl->magic = CLOSURE_MAGIC_STACK;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,6 +244,9 @@ void closure_debug_destroy(struct closure *cl)
|
|||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
|
if (cl->magic == CLOSURE_MAGIC_STACK)
|
||||||
|
return;
|
||||||
|
|
||||||
BUG_ON(cl->magic != CLOSURE_MAGIC_ALIVE);
|
BUG_ON(cl->magic != CLOSURE_MAGIC_ALIVE);
|
||||||
cl->magic = CLOSURE_MAGIC_DEAD;
|
cl->magic = CLOSURE_MAGIC_DEAD;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user