From owner-freebsd-hackers@FreeBSD.ORG Mon Feb 14 14:50:27 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 291B416A4CE for ; Mon, 14 Feb 2005 14:50:27 +0000 (GMT) Received: from cyrus.watson.org (cyrus.watson.org [204.156.12.53]) by mx1.FreeBSD.org (Postfix) with ESMTP id E83B043D2D for ; Mon, 14 Feb 2005 14:50:26 +0000 (GMT) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by cyrus.watson.org (Postfix) with SMTP id 7D54F46B33; Mon, 14 Feb 2005 09:50:26 -0500 (EST) Date: Mon, 14 Feb 2005 14:49:09 +0000 (GMT) From: Robert Watson X-Sender: robert@fledge.watson.org To: Ashwin Chandra In-Reply-To: <000c01c5126f$354f81c0$58e243a4@ash> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-hackers@freebsd.org Subject: Re: Kernel Monitor? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Feb 2005 14:50:27 -0000 On Mon, 14 Feb 2005, Ashwin Chandra wrote: > Im having issues with the following code running as a kernel thread. > when i do the prinft (which i traced with kgdb) it crashes...but those > two variables that i print out, are fine if i do comparisons or store > them into variables...only printing them causes a panic. anyone have any > ideas in what im doing wrong? Looks like you arne't acquiring the allproc_lock before walking the process list, which means the process list could change while the code is running. That might be one source of a problem. I think you also don't need Giant there. Also, you probably want to check that the process isn't in the PRS_NEW state, otherwise it might not be fully initialized. You don't mention what crash, btw -- is it a page fault? If so, is the faulting address close to 0 (NULL)? Robert N M Watson > static void kernmon(void); > static void kernmon_thread(void); > static void kern_print(void); > > static struct kproc_desc kernmon_kp = { > "kernmon", > kernmon_thread, > NULL > }; > > SYSINIT(kernmon, SI_SUB_KERN_MON, SI_ORDER_FIRST, kproc_start, &kernmon_kp) > > static void > kernmon(void) > { > kern_print(); > } > > static void > kernmon_thread(void) > { > int nowake = 0; > for (;;) { > kernmon(); > tsleep(&nowake, curthread->td_priority, "-", 7*hz); > > } > } > > static void > kern_print(void) > { > struct proc *p; > > FOREACH_PROC_IN_SYSTEM(p) { > mtx_lock(&Giant); > PROC_LOCK(p); > printf("%d %d\n", (int)p->p_stats->p_ru.ru_isrss, (int)p->p_stats->p_ru.ru_idrss); > PROC_UNLOCK(p); > mtx_unlock(&Giant); > } > > > } > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >