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

2016-04-22 Thread Thomas Gleixner
On Fri, 22 Apr 2016, changbin...@intel.com wrote:
> From: "Du, Changbin" 
> 
> 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(>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


  


--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2016-04-22 Thread changbin . du
From: "Du, Changbin" 

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.

Signed-off-by: Du, Changbin 
---
 lib/debugobjects.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index a9cee16..2f07c8c 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -415,7 +415,7 @@ int debug_object_activate(void *addr, struct 
debug_obj_descr *descr)
state = obj->state;
raw_spin_unlock_irqrestore(>lock, flags);
ret = debug_object_fixup(descr->fixup_activate, addr, 
state);
-   return ret ? -EINVAL : 0;
+   return ret ? 0 : -EINVAL;
 
case ODEBUG_STATE_DESTROYED:
debug_print_object(obj, "activate");
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html