lkml.org 
[lkml]   [2007]   [Jul]   [5]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
    /
    DateThu, 5 Jul 2007 10:53:04 +0200
    FromIngo Molnar <>
    SubjectRe: [PATCH] debug work struct cancel deadlocks with lockdep
    * Johannes Berg <johannes@sipsolutions.net> wrote:
    
    > This adds a lockdep_map for each work struct in order to debug
    > deadlocks like
    >   my_function -> lock(); ...; cancel_work_sync(my_work)
    > vs.
    >   run_workqueue() -> my_work.f() -> ...; lock(); ...
    > 
    > which will deadlock if my_work.f() is invoked already but my_function()
    > has acquired the lock already.
    > 
    > Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
    
    Acked-by: Ingo Molnar <mingo@elte.hu>
    
    > +#ifdef CONFIG_LOCKDEP
    > +/*
    > + * HACK! This really should call lockdep_init_map() but can't
    > + * because there's no requirement to initialise work structs
    > + * at runtime. This works because subclass == 0.
    > + *
    > + * NB: because we have to copy the lockdep_map, setting .key
    > + * here is required!
    > + */
    
    why do you consider this a hack? A static object is a static object, and 
    its own address is its key. That's what we have for like 80% of all the 
    spinlocks in the kernel. Static initialization is not as flexible as 
    dynamic initialization, but the lockdep engine handles it. Am i missing 
    something?
    
    > +#define __WORK_INIT_LOCKDEP_MAP(n, k)				\
    > +	.lockdep_map = {					\
    > +		.name = n,					\
    > +		.key = (void*) k,				\
    > +	},
    
    s/void*/void *
    
    	Ingo
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    
    
    \
     
     \ /
      Last update: 2007-07-05 10:55    [from the cache]
    ©2003-2008