closures: Improve warnings on bad put
Subsystems (2)
Kent Overstreet
maintainerPATCH 1/1 closures: Improve warnings on bad put
Print out cl->fn - this narrows down the codepaths to look at.
See https://syzkaller.appspot.com/bug?extid=0ea2c41a649240197795
Signed-off-by Kent Overstreet <[email protected]>
--- lib/closure.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
lib/closure.c +7 -5
@@ -13,23 +13,25 @@#include <linux/seq_file.h> #include <linux/sched/debug.h> -static inline void closure_put_after_sub_checks (int flags) +static inline void closure_put_after_sub_checks (struct closure *cl,int flags) {int r = flags &CLOSURE_REMAINING_MASK ;if (WARN (flags &CLOSURE_GUARD_MASK , -"closure has guard bits set: %x (%u)" , +"closure %ps has guard bits set: %x (%u)" , + cl->fn, flags &CLOSURE_GUARD_MASK , (unsigned )__fls (r))) r &= ~CLOSURE_GUARD_MASK ;WARN (!r && (flags & ~CLOSURE_DESTRUCTOR ), -"closure ref hit 0 with incorrect flags set: %x (%u)" , +"closure %ps ref hit 0 with incorrect flags set: %x (%u)" , + cl->fn, flags & ~CLOSURE_DESTRUCTOR , (unsigned )__fls (flags)); }static inline void closure_put_after_sub (struct closure *cl,int flags) { -closure_put_after_sub_checks (flags); +closure_put_after_sub_checks (cl, flags);if (!(flags &CLOSURE_REMAINING_MASK )) {smp_acquire__after_ctrl_dep ();
@@ -167,7 +169,7 @@ void __sched closure_return_sync(struct closure *cl)unsigned flags =atomic_sub_return_release (1 +CLOSURE_RUNNING -CLOSURE_DESTRUCTOR , &cl->remaining); -closure_put_after_sub_checks (flags); +closure_put_after_sub_checks (cl, flags);if (unlikely (flags &CLOSURE_REMAINING_MASK )) {while (1 ) {
Signature · 1 line
2.50.0