From owner-freebsd-hackers Fri Jul 21 13:46: 7 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from bingnet2.cc.binghamton.edu (bingnet2.cc.binghamton.edu [128.226.1.18]) by hub.freebsd.org (Postfix) with ESMTP id DF4A937BF0B for ; Fri, 21 Jul 2000 13:45:55 -0700 (PDT) (envelope-from zzhang@cs.binghamton.edu) Received: from sol.cs.binghamton.edu (sol.cs.binghamton.edu [128.226.123.100]) by bingnet2.cc.binghamton.edu (8.9.3/8.9.3) with ESMTP id QAA19655 for ; Fri, 21 Jul 2000 16:45:53 -0400 (EDT) Date: Fri, 21 Jul 2000 16:43:30 -0400 (EDT) From: Zhihui Zhang To: freebsd-hackers@FreeBSD.ORG Subject: Re: KLD, kernel threads, zone allocator In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, 17 Jul 2000, Zhihui Zhang wrote: > > I am writing a KLD that gives me kernel fault each time I run 'ps' command > after 'make unload'. The KLD has a system call to create several kernel > threads by calling kthread_create(). During unload, I set flags to each > threads so that they will call exit1() upon wakeup (sleep on a timeout). > Before the last thread calls exit1(), it wakeup the kld unload process so > that make 'unload' can finish. Is there anything wrong or better > solutions? > > I also use vm_zone to allocate some data structes within the KLD. When > unloading, I can use zfree() to free them except the zone header that I > can not free(some_zone, M_ZONE). This is because M_ZONE is defined as > *static* in vm_zone.c I wonder if this will cause memory leak after > several loading and unloading the KLD. > > Finally, I want to know how to save the panic screen without hand writing > it down. Any info on debugging under db> after fault? > > Any help is appreciated. Thanks to those who have helped me privately. It is not a good idea to use zone allocator with KLD. You must clear everything before unloading the KLD. Any kernel threads can be reparented to initproc to avoid 'ps' panic. -Zhihui To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message