Date: Tue, 18 Jan 2011 21:22:24 +0300 From: Sergey Kandaurov <pluknet@gmail.com> To: John Baldwin <jhb@freebsd.org> Cc: freebsd-current@freebsd.org, Robert Watson <rwatson@freebsd.org> Subject: Re: uma_zalloc_arg: zone "256" with non-sleepable exclusive rw ifnet_rw @ /usr/src/sys/net/if.c:414 Message-ID: <AANLkTi=DtUa5%2BfhOrOW_N11rn6WVp8fHZvL%2BOE6n-S6c@mail.gmail.com> In-Reply-To: <201101180954.46903.jhb@freebsd.org> References: <AANLkTi=dZ4vOSx82Wp%2BqAwmT97mucqwtf6dDu4pnOCR2@mail.gmail.com> <201101180954.46903.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 18 January 2011 17:54, John Baldwin <jhb@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()? =A0This compiles, but I haven't boote= d it > yet: > > Index: if.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- if.c =A0 =A0 =A0 =A0(revision 217400) > +++ if.c =A0 =A0 =A0 =A0(working copy) > @@ -266,6 +266,7 @@ ifindex_alloc_locked(u_short *idxp) > > =A0 =A0 =A0 =A0IFNET_WLOCK_ASSERT(); > > +retry: > =A0 =A0 =A0 =A0/* > =A0 =A0 =A0 =A0 * Try to find an empty slot below V_if_index. =A0If we fa= il, take the > =A0 =A0 =A0 =A0 * next slot. > @@ -278,10 +279,11 @@ ifindex_alloc_locked(u_short *idxp) > =A0 =A0 =A0 =A0/* Catch if_index overflow. */ > =A0 =A0 =A0 =A0if (idx < 1) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (ENOSPC); > - =A0 =A0 =A0 if (idx > V_if_index) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 V_if_index =3D idx; > - =A0 =A0 =A0 if (V_if_index >=3D V_if_indexlim) > + =A0 =A0 =A0 if (idx > V_if_index) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if_grow(); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto retry; > + =A0 =A0 =A0 } > + =A0 =A0 =A0 V_if_index =3D idx; > =A0 =A0 =A0 =A0*idxp =3D idx; > =A0 =A0 =A0 =A0return (0); > =A0} > @@ -385,16 +387,25 @@ VNET_SYSUNINIT(vnet_if_uninit, SI_SUB_INIT_IF, SI_ > =A0static void > =A0if_grow(void) > =A0{ > + =A0 =A0 =A0 int oldlim; > =A0 =A0 =A0 =A0u_int n; > =A0 =A0 =A0 =A0struct ifindex_entry *e; > > - =A0 =A0 =A0 V_if_indexlim <<=3D 1; > - =A0 =A0 =A0 n =3D V_if_indexlim * sizeof(*e); > + =A0 =A0 =A0 IFNET_WLOCK_ASSERT(); > + =A0 =A0 =A0 oldlim =3D V_if_indexlim; > + =A0 =A0 =A0 IFNET_WUNLOCK(); > + =A0 =A0 =A0 n =3D (oldlim << 1) * sizeof(*e); > =A0 =A0 =A0 =A0e =3D malloc(n, M_IFNET, M_WAITOK | M_ZERO); > + =A0 =A0 =A0 IFNET_WLOCK(); > + =A0 =A0 =A0 if (V_if_indexlim !=3D oldlim) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 free(e, M_IFNET); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return; > + =A0 =A0 =A0 } > =A0 =A0 =A0 =A0if (V_ifindex_table !=3D NULL) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0memcpy((caddr_t)e, (caddr_t)V_ifindex_tabl= e, n/2); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0free((caddr_t)V_ifindex_table, M_IFNET); > =A0 =A0 =A0 =A0} > + =A0 =A0 =A0 V_if_indexlim <<=3D 1; > =A0 =A0 =A0 =A0V_ifindex_table =3D e; > =A0} vnet_if_init() calls if_grow() without lock. panic: Lock (null) not exclusively locked @ /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 --=20 wbr, pluknet
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTi=DtUa5%2BfhOrOW_N11rn6WVp8fHZvL%2BOE6n-S6c>