tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: rfc: fix double locking in the pool cache subroutines



On Fri, Jul 11, 2008 at 3:22 PM, Andrew Doran <ad%netbsd.org@localhost> wrote:
>> I'm using the NetBSD-current (yesterday snapshot) on OMAP/H4.
>> When I try to start one of the libMicro (0.4.0) test called close_tcp
>> I've got the locking panic (I've switched on the LOCKDEBUG option).
>>
>> # tcc -p -e $PWD close_tcp
>> tcc: journal file is /root/micro/results/0010e/journal
>> 07:50:48  Execute /ts/close_tcp/close_tcp-tc
>> Mutex error: lockdebug_wantlock: locking against myself
>>
>> lock address : 0x0000000081ca9a00 type     :     sleep/adaptive
>> initialized  : 0x0000000080410264
>> shared holds :                  0 exclusive:                  1
>> shares wanted:                  0 exclusive:                  1
>> current cpu  :                  0 last held:                  0
>> current lwp  : 0x0000000081cad4c0 last held: 0x0000000081cad4c0
>> last locked  : 0x000000008040f660 unlocked : 0x000000008040f704
>> owner field  : 0x0000000081cad4c0 wait/spin:                0/0
>
> That does not make sense. What do the 'last locked', 'last unlocked'
> and 'initialized' addresses resolve to? Can you post the backtrace
> from the panic?

ADDRESSES
last locked:
/home/andy/prj/netbsd/netbsd-current/sys/kern/subr_pool.c:2526
...
pool_cache_put_slow(pool_cache_cpu_t *cc, int s, void *object)
{
...
        /* Lock the cache. */
>>>>>   if (__predict_false(!mutex_tryenter(&pc->pc_lock))) {
                ncsw = curlwp->l_ncsw;
                mutex_enter(&pc->pc_lock);
...

last unlocked:
/home/andy/prj/netbsd/netbsd-current/sys/kern/subr_pool.c:2575
...
pool_cache_put_slow(pool_cache_cpu_t *cc, int s, void *object)
{
...
        /*
         * If there's a empty group, release our full group back
         * to the cache.  Install the empty group to the local CPU
         * and return.
         */
        if (pcg != NULL) {
...
>>>>>           mutex_exit(&pc->pc_lock);
                return true;
...

initialized:
/home/andy/prj/netbsd/netbsd-current/sys/kern/subr_pool.c:2068
...
pool_cache_bootstrap(pool_cache_t pc, size_t size, u_int align,
    u_int align_offset, u_int flags, const char *wchan,
    struct pool_allocator *palloc, int ipl,
    int (*ctor)(void *, void *, int), void (*dtor)(void *, void *),
    void *arg)
{
...
        pool_init(pp, size, align, align_offset, flags, wchan, palloc, ipl);
        mutex_init(&pc->pc_lock, MUTEX_DEFAULT, ipl);
...
>>>>>   pc->pc_emptygroups = NULL;
        pc->pc_fullgroups = NULL;
        pc->pc_partgroups = NULL;
...

BACKTRACE

netbsd:panic+0x14
        scp=0x80412980 rlv=0x8040b448 (netbsd:lockdebug_abort1+0x90)
        rsp=0x8210dc1c rfp=0x8210dc3c
netbsd:lockdebug_abort1+0xc
        scp=0x8040b3c4 rlv=0x8040b568 (netbsd:lockdebug_wantlock+0x10c)
        rsp=0x8210dc40 rfp=0x8210dc6c
        r8=0x00000000 r7=0x81cad4c0
        r6=0x81ca9a00 r5=0x00000001 r4=0x80556678
netbsd:lockdebug_wantlock+0x10
        scp=0x8040b46c rlv=0x803e6224 (netbsd:mutex_vector_enter+0x168)
        rsp=0x8210dc70 rfp=0x8210dc94
        r10=0x8040f600 r9=0xffffffff
        r8=0x80559770 r7=0x81cad4c0 r6=0x81ca9a00 r5=0x81ca9a00
        r4=0x00000000
netbsd:mutex_vector_enter+0xc
        scp=0x803e60c8 rlv=0x8040f600 (netbsd:pool_cache_invalidate+0x1c)
        rsp=0x8210dc98 rfp=0x8210dcb4
        r10=0xffffffff r8=0x00000000
        r7=0x00000022 r6=0x00000020 r5=0x81ca9a00 r4=0x81ca990c
netbsd:pool_cache_invalidate+0xc
        scp=0x8040f5f0 rlv=0x80410f04 (netbsd:pool_reclaim+0x3c)
        rsp=0x8210dcb8 rfp=0x8210dce4
        r7=0x00000022 r6=0x00000020
        r5=0x8051e6a0 r4=0x81ca990c
netbsd:pool_reclaim+0xc
        scp=0x80410ed4 rlv=0x80411218 (netbsd:pool_reclaim_callback+0x38)
        rsp=0x8210dce8 rfp=0x8210dcfc
        r10=0xffffffff r8=0x00000000
        r7=0x00000022 r6=0x00000020 r5=0x8051e6a0 r4=0x81ca990c
netbsd:pool_reclaim_callback+0x10
        scp=0x804111f0 rlv=0x80406fd4 (netbsd:callback_run_roundrobin+0x5c)
        rsp=0x8210dd00 rfp=0x8210dd20
        r5=0x80543aec r4=0x81ca99e8
netbsd:callback_run_roundrobin+0xc
        scp=0x80406f84 rlv=0x803b1700 (netbsd:uvm_map_prepare+0x198)
        rsp=0x8210dd24 rfp=0x8210dd6c
        r8=0x00000000 r7=0xffffffff
        r6=0x8127d174 r5=0x00000000 r4=0x80543a4c
netbsd:uvm_map_prepare+0xc
        scp=0x803b1574 rlv=0x803b5e24 (netbsd:uvm_map+0xc0)
        rsp=0x8210dd70 rfp=0x8210ddcc
        r10=0x8210dd88 r9=0x8210ddf4
        r8=0xffffffff r7=0xffffffff r6=0x8127d174 r5=0x00e01727
        r4=0x80543a4c
netbsd:uvm_map+0xc
        scp=0x803b5d70 rlv=0x803ad704 (netbsd:uvm_km_alloc+0xc0)
        rsp=0x8210ddd0 rfp=0x8210de20
        r10=0x81ca9a00 r9=0x00000000
        r8=0x00000000 r7=0x8054698c r6=0x80546918 r5=0xffffffff
        r4=0xffffffff
netbsd:uvm_km_alloc+0xc
        scp=0x803ad650 rlv=0x8040e838 (netbsd:pool_grow+0x34)
        rsp=0x8210de24 rfp=0x8210de4c
        r10=0x81ca9a00 r9=0x00000000
        r8=0x00000000 r7=0x8054698c r6=0x80546918 r5=0x00000002
        r4=0x8051e664
netbsd:pool_grow+0xc
        scp=0x8040e810 rlv=0x8040e244 (netbsd:pool_get+0x12c)
        rsp=0x8210de50 rfp=0x8210de78
        r10=0x81ca9a00 r9=0x00000000
        r8=0x00000000 r7=0x00000000 r6=0x00000002 r5=0x8054698c
        r4=0x80546918
netbsd:pool_get+0xc
        scp=0x8040e124 rlv=0x8040f7f0 (netbsd:pool_cache_put_slow+0x194)
        rsp=0x8210de7c rfp=0x8210deb4
        r10=0x81ca9a00 r8=0x00000000
        r7=0x81ca9a8c r6=0x81ca990c r5=0x00000000 r4=0x00000000
netbsd:pool_cache_put_slow+0xc
        scp=0x8040f668 rlv=0x8040f9e8 (netbsd:pool_cache_put_paddr+0xf0)
        rsp=0x8210deb8 rfp=0x8210dee0
        r10=0x8051f2c0 r9=0x81161ba0
        r8=0xffffffff r7=0x813f4c90 r6=0x00000001 r5=0x81ca9a8c
        r4=0x81ca990c
netbsd:pool_cache_put_paddr+0xc
        scp=0x8040f904 rlv=0x8030426c (netbsd:in_pcbdetach+0x30)
        rsp=0x8210dee4 rfp=0x8210defc
        r10=0x813fcd4c r9=0x8055a060
        r8=0x8055a060 r7=0x813ef2dc r6=0x813ef208 r5=0x00000000
        r4=0x813fcd4c
netbsd:in_pcbdetach+0xc
        scp=0x80304248 rlv=0x8031a2e4 (netbsd:tcp_close+0x164)
        rsp=0x8210df00 rfp=0x8210df30
        r6=0x813ef208 r5=0x00000004
        r4=0x813ef2b8
netbsd:tcp_close+0xc
        scp=0x8031a18c rlv=0x8031a9fc (netbsd:tcp_timer_2msl+0x70)
        rsp=0x8210df34 rfp=0x8210df48
        r10=0x80544f14 r9=0x80544714
        r8=0x8031a98c r7=0x813ef208 r6=0x80543eac r5=0x8055a060
        r4=0x813ef208
netbsd:tcp_timer_2msl+0xc
        scp=0x8031a998 rlv=0x803ff79c (netbsd:callout_softclock+0x1bc)
        rsp=0x8210df4c rfp=0x8210df78
        r5=0x813ef290 r4=0x00000104
netbsd:callout_softclock+0x10
        scp=0x803ff5f0 rlv=0x803f3f20 (netbsd:softint_dispatch+0xb8)
        rsp=0x8210df7c rfp=0x8210dfb0
        r10=0x00000000 r9=0x00000000
        r8=0x8051f2c0 r7=0x00000001 r6=0x81cad4c0 r5=0x8207e074
        r4=0x8207e224
netbsd:softint_dispatch+0x10
        scp=0x803f3e78 rlv=0x80477f20 (netbsd:softint_switch+0x54)
        rsp=0x8210dfb4 rfp=0x8207df34
        r10=0x00000000 r8=0x00000000
        r7=0x8051f2c0 r6=0x20000193 r5=0x81cad4c0 r4=0x81cadbe0
Bad frame pointer: 0x8207df34


-- 
With Best Regards,
Andy Shevchenko


Home | Main Index | Thread Index | Old Index