Re: [PATCH 2/7] debugobjects: correct the usage of fixup call results

From: Thomas Gleixner
Date: Fri Apr 22 2016 - 05:06:56 EST


On Fri, 22 Apr 2016, changbin.du@xxxxxxxxx wrote:
> From: "Du, Changbin" <changbin.du@xxxxxxxxx>
>
> If debug_object_fixup() return non-zero when problem has been
> fixed. But the code got it backwards, it taks 0 as fixup
> successfully. So fix it.

Wrong.

> @@ -415,7 +415,7 @@ int debug_object_activate(void *addr, struct debug_obj_descr *descr)
> state = obj->state;
> raw_spin_unlock_irqrestore(&db->lock, flags);
> ret = debug_object_fixup(descr->fixup_activate, addr, state);
> - return ret ? -EINVAL : 0;
> + return ret ? 0 : -EINVAL;

So you need to look at the fixup_activate() callbacks.

timer_fixup_activate()

The only state handled there is ODEBUG_STATE_NOTAVAILABLE. This can happen
for two reasons:

1) timer is statically allocated and initialized. That's a legitimate reason
and it does not count as a fixup

2) timer has not been initialized, so we have no idea what to do with it. We
set it up with a dummy callback and return 1 because that is a fixup.

So the return check for ret != 0 is correct. #2 is invalid

hrtimer_fixup_activate()

There is not much we can do about it.

work_fixup_activate()

That's similar to timer_fixup_activate(). We need to handle the statically
allocated work gracefully.

rcuhead_fixup_activate()

Handles the ODEBUG_STATE_NOTAVAILABLE case by tracking it. Not a fixup,
returns 0.

The other states are invalid and there is not much we can do about
that. Returns 1.

I agree that this is not really intuitive, but it's correct as it is. I'm
happy to take patches which make it simpler to understand. Just blindly
changing everything to bool does not fall into that category.

Thanks,

tglx