Subject: Re: malloc_type_{attach|detach}
To: Jaromir Dolecek <jdolecek@netbsd.org>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 04/04/2003 11:22:51
On Fri, 4 Apr 2003, Jaromir Dolecek wrote:
> Hi,
>
> even through I've modified smbfs LKM code to call the malloc type
> attach/detach function, I still occassionally see a kernel panic
> from unrelated malloc call when I try to load/unload the smbfs LKM.
>
> It appears the functions are not protected from interrupts, so
> there is a race where interrupt can come in during time when
> the structures are not consistent.
>
> What should be done? Should the functions call splhigh() before
> accessing kmemstatistics, or should the caller take care of that?
I don't think splhigh() is the right one. But we already have an slp that
protects memory allocation, and we should be using it. From looking at man
9 spl (thanks Allen!), it's splvm() (its name used to be different).
Take care,
Bill