Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Oct 2009 16:26:51 -0700
From:      Harsha <inpcb.harsha@gmail.com>
To:        Julian Elischer <julian@elischer.org>
Cc:        freebsd-current@freebsd.org, "Robert N. M. Watson" <rwatson@freebsd.org>, net@freebsd.org
Subject:   Re: Page fault in IFNET_WLOCK_ASSERT [if.c and pccbb.c]
Message-ID:  <e1b1c5880910181626g300213afj128bee62f424810a@mail.gmail.com>
In-Reply-To: <4ADAB8E0.3090502@elischer.org>
References:  <e1b1c5880910111226o65e0d1a9va975f4cd837271bb@mail.gmail.com> <alpine.BSF.2.00.0910112126050.48605@fledge.watson.org> <e1b1c5880910112138x1b46ff0eo39c10691a978c164@mail.gmail.com> <FE5F0845-B909-4B9B-A999-DAA7D8F4E56D@freebsd.org> <e1b1c5880910172328s6bc0c53ctc782b9993ffbdb00@mail.gmail.com> <4ADAB8E0.3090502@elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Oct 17, 2009 at 11:42 PM, Julian Elischer <julian@elischer.org> wro=
te:
> Harsha wrote:
>> <rwatson@freebsd.org> wrote:
>>>
>>> Looks like a NULL pointer dereference, so perhaps a more traditional bu=
g
>>> --
>>> could you convert ifindex_alloc_locked+0x71 to a line of code? You can =
do
>>> this using kgdb on the kernel symbols file, perhaps "l
>>> *ifindex_alloc_locked+0x71".
>>
>> It is the for loop in ifindex_alloc_locked() function-
>> =A0for (idx =3D 1; idx <=3D V_if_index; idx++)
>>
>> idx is a local variable, so I figured it is V_if_index is what is
>> causing the page fault. It does look like a NULL pointer reference - I
>> see that V_if_index comes from that =A0vnet instance's value and uses
>> the macro VNET_VNET_PTR() down the chain. Since the call chain is
>> coming from a new thread cbb_event_thread, I believe that this
>> thread's vnet context needs to be set using CURVNET_SET().
>
> but only if you have options VIMAGE defined. if not then CURVNET_SET()
> is a NOP
I do have the VIMAGE options turned on.

Can someone tell me what is the right way to add the vnet context to
cbb_event_thread?

I tried adding context in two locations-

1. In cbb_insert() as-
CURVNET_SET(TD_TO_VNET(curthread));

2. In if_alloc() as-
CURVNET_SET(TD_TO_VNET(curthread));

or as

ifp =3D malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO);
#ifdef VIMAGE
      ifp->if_vnet =3D curvnet;
      if (ifp->if_home_vnet =3D=3D NULL)
          ifp->if_home_vnet =3D curvnet;
      CURVNET_SET(ifp->if_vnet);
#endif

But in all the cases I get a warning/error about unused variable
'saved_vnet' like this-

cc1: warnings being treated as errors
/usr/src/sys/net/if.c: In function 'if_alloc':
/usr/src/sys/net/if.c:418: warning: unused variable 'saved_vnet'

The backtrace is in the link I posted earlier.

Thanks,
Harsha



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e1b1c5880910181626g300213afj128bee62f424810a>