Re: uma_zalloc_arg: zone "256" with non-sleepable exclusive rw ifnet_rw @ /usr/src/sys/net/if.c:414

From: Sergey Kandaurov <pluknet_at_gmail.com>
Date: Tue, 18 Jan 2011 21:22:24 +0300
On 18 January 2011 17:54, John Baldwin <jhb_at_freebsd.org> wrote:
> On Monday, January 17, 2011 12:55:26 pm Sergey Kandaurov wrote:
>> Hi,
>>
>> I see this "malloc with non-sleepable" on current during boot.
>> It's strange that I don't see it if I boot via pxe/nfs.
>>
>> if_alloc() calls ifindex_alloc_locked() under IFNET_WLOCK() which
>> might call if_grow().
>> Looks like a regression from r196553.
>
> I'm guessing that ifindex_alloc() should drop the lock and retry the
> allocation after calling if_grow()?  This compiles, but I haven't booted it
> yet:
>
> Index: if.c
> ===================================================================
> --- if.c        (revision 217400)
> +++ if.c        (working copy)
> _at__at_ -266,6 +266,7 _at__at_ ifindex_alloc_locked(u_short *idxp)
>
>        IFNET_WLOCK_ASSERT();
>
> +retry:
>        /*
>         * Try to find an empty slot below V_if_index.  If we fail, take the
>         * next slot.
> _at__at_ -278,10 +279,11 _at__at_ ifindex_alloc_locked(u_short *idxp)
>        /* Catch if_index overflow. */
>        if (idx < 1)
>                return (ENOSPC);
> -       if (idx > V_if_index)
> -               V_if_index = idx;
> -       if (V_if_index >= V_if_indexlim)
> +       if (idx > V_if_index) {
>                if_grow();
> +               goto retry;
> +       }
> +       V_if_index = idx;
>        *idxp = idx;
>        return (0);
>  }
> _at__at_ -385,16 +387,25 _at__at_ VNET_SYSUNINIT(vnet_if_uninit, SI_SUB_INIT_IF, SI_
>  static void
>  if_grow(void)
>  {
> +       int oldlim;
>        u_int n;
>        struct ifindex_entry *e;
>
> -       V_if_indexlim <<= 1;
> -       n = V_if_indexlim * sizeof(*e);
> +       IFNET_WLOCK_ASSERT();
> +       oldlim = V_if_indexlim;
> +       IFNET_WUNLOCK();
> +       n = (oldlim << 1) * sizeof(*e);
>        e = malloc(n, M_IFNET, M_WAITOK | M_ZERO);
> +       IFNET_WLOCK();
> +       if (V_if_indexlim != oldlim) {
> +               free(e, M_IFNET);
> +               return;
> +       }
>        if (V_ifindex_table != NULL) {
>                memcpy((caddr_t)e, (caddr_t)V_ifindex_table, n/2);
>                free((caddr_t)V_ifindex_table, M_IFNET);
>        }
> +       V_if_indexlim <<= 1;
>        V_ifindex_table = e;
>  }

vnet_if_init() calls if_grow() without lock.

panic: Lock (null) not exclusively locked _at_ /usr/src/sys/net/if.c:394

db> bt
Tracing pid 0 tid 100000 td 0xffffffff80ccff40
kdb_enter() at kdb_enter+0x3d
panic() at panic+0x180
assert_sx() at assert_sx
if_grow() at if_grow+0x2a
vnet_if_init() at vnet_if_init+0x35
mi_startup() at mi_startup+0x77
btext() at btext+0x2c


-- 
wbr,
pluknet
Received on Tue Jan 18 2011 - 17:22:25 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:10 UTC