Subject: Re: sockstat(1), kern.file2 and net.*.*.pcblist for sysctl
To: None <tech-kern@NetBSD.org>
From: Andrew Brown <atatat@atatdot.net>
List: tech-kern
Date: 02/27/2005 16:27:34
On Sun, Feb 27, 2005 at 02:15:04PM -0500, Andrew Brown wrote:
>From: Andrew Brown <atatat@atatdot.net>
>To: tech-kern@NetBSD.org
>...
>(3) i've not dug into too deeply (maybe it's not even a bug?), but
>it's a little more alarming.  basically, it appears that i have a lot
>of uninitialized simplelocks in my kernel.  picking a process (mostly)
>at random and running gdb against the running kernel shows:
>
>    (gdb) print allproc.lh_first->p_list.le_next->p_pid
>    $36 = 327
>    (gdb) print allproc.lh_first->p_list.le_next->p_cwdi->cwdi_slock
>    $37 = {lock_data = -904051956}
>    (gdb) print &allproc.lh_first->p_list.le_next->p_cwdi->cwdi_slock
>    $40 = (struct simplelock *) 0xca1c52dc
>    (gdb) x/x &allproc.lh_first->p_list.le_next->p_cwdi->cwdi_slock
>    0xca1c52dc:     0xca1d430c
>
>i don't have LOCKDEBUG in my kernel and i'm not a lock expert, but i
>would have expected a simple lock either to be 0 or 1.  the number of
>simplelocks i have that are not in this state is currently 65.

yes, the 0xca1d430c value vaguely resembles a kernel pointer (fwiw,
i'm running 2.99.14 on i386), but it's not.  some other values i see
are -5, 16779778, 470000000, 2145378283, -2049, 8913031, etc.

also:

    % ./rawdump | grep simplelock | sed 's/.*{//' | sort | uniq -c > 1
    % ./rawdump | grep simplelock | sed 's/.*{//' | sort | uniq -c > 2
    % ./rawdump | grep simplelock | sed 's/.*{//' | sort | uniq -c > 3
    % ./rawdump | grep simplelock | sed 's/.*{//' | sort | uniq -c > 4
    % wc -l 1 2 3 4
	  53 1
	  53 2
	  55 3
	  53 4
	 214 total
    % diff 1 2
    1c1
    <   11  -1 }
    ---
    >   12  -1 }
    11c11
    <    1  -262145 }
    ---
    >    1  -257 }
    19c19
    <    2  -536870913 }
    ---
    >    1  -536870913 }
    % diff 2 3
    1c1
    <   12  -1 }
    ---
    >   11  -1 }
    5a6
    >    1  -1111706020 }
    11c12
    <    1  -257 }
    ---
    >    1  -262145 }
    29a31
    >    1  -904051900 }
    36c38
    < 1032  0 }
    ---
    > 1031  0 }
    % diff 3 4
    1c1
    <   11  -1 }
    ---
    >   12  -1 }
    6d5
    <    1  -1111706020 }
    12c11
    <    1  -262145 }
    ---
    >    1  -257 }
    31d29
    <    1  -904051900 }
    38c36
    < 1031  0 }
    ---
    > 1032  0 }

so the values shift around a little (probaly due to me running all
those processes to get the numbers in the first place :-), but the
number of locks stays relatively fixed from moment to moment.

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
werdna@squooshy.com       * "information is power -- share the wealth."