lkml.org 
[lkml]   [2002]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: spinlock assertion macros
    Date
    On Thursday 11 July 2002 01:36, Jesse Barnes wrote:

    +#define spin_assert_unlocked(lock) if (spin_is_locked(lock)) { printk("lock assertion failure: lock at %s:%d should be unlocked!\n", __FILE__, __LINE__); }

    I suppose what would at least be as helpful is to check if _any_
    lock is held, e.g. when calling a potentially sleeping function.

    Something along these lines:

    #ifdef CONFIG_DEBUG_SPINLOCK
    extern char *volatile last_spinlock[NR_CPUS];

    #define spin_assert_unlocked_all() ({ \
    char *lock = last_spinlock[smp_processor_id()]; \
    if (lock) { \
    printk (KERN_CRIT "%s:%d: lock %s is held\n", \
    __func__, __LINE__, lock); \
    BUG(); \
    } \
    })

    #define spin_lock(lock) ({ \
    last_spinlock[smp_processor_id()] = __stringify(lock) "@" \
    __FILE__ ":" __stringify(__LINE__); \
    __really_spin_lock(lock); \
    })
    #endif

    probably, a per-cpu lock depth should be used to also catch
    spin_lock(foo_lock);
    spin_lock(bar_lock);
    spin_unlock(bar_lock);
    spin_assert_unlock_all();

    Arnd <><
    -
    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: 2005-03-22 13:27    [W:0.030 / U:1.100 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site