Date: Tue, 15 Feb 2005 15:20:20 +0200 From: Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua> To: Ashwin Chandra <ashcs@ucla.edu> Cc: freebsd-hackers@freebsd.org Subject: Re: Kernel monitor, the return Message-ID: <20050215132020.GA376@pm514-9.comsys.ntu-kpi.kiev.ua> In-Reply-To: <000801c51327$0e2bf020$58e243a4@ash> References: <000801c51327$0e2bf020$58e243a4@ash>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Feb 14, 2005 at 10:24:50PM -0800, Ashwin Chandra wrote: > In trying to create a simple kernel thread that prints out all > the processes data and stack size, i still get a panic fault > (vm_fault on no entry) at the printf statement...ive narrowed > it down to the ru_idrss variable that is causing the problem, Definitely ru_idrss cannot cause any error, may be you made such desition, because arguments are pushed to the stack in the reverse order. p->p_stats pointer causes the error. > im not sure why (I think that) If some process is not running, then you cannot use p->p_stats without additional checks for memory p->p_stats points to, since p->p_stats points to u_stats in struct user{}, which can be swapped out if a process is not running. Actually you can read this in the comment before struct user{} in /sys/sys/user.h. >. I thought maybe I was not locking properly or > obseriving correct mutexes, but I have tried everything. You'll get an error at some time, because of incorrect usage (really not usage) of locks. > If anyone > knows why the fault is occurring at the printf, please let me know. =) Following code works on my system: ---- sx_slock(&allproc_lock); FOREACH_PROC_IN_SYSTEM(p) { mtx_lock_spin(&sched_lock); PROC_LOCK(p); printf("proc %ld:", (long)p->p_pid); if ((p->p_sflag & PS_INMEM) && p->p_stats != NULL) printf(" ru_isrss %ld, rui_idrss %ld\n", p->p_stats->p_ru.ru_isrss, p->p_stats->p_ru.ru_idrss); else { if (!(p->p_sflag & PS_INMEM)) printf(" !PS_INMEM"); if (p->p_stats == NULL) printf(" p_stats == NULL"); } printf("\n"); PROC_UNLOCK(p); mtx_unlock(&sched_lock); } sx_sunlock(&allproc_lock); ---- Follow this code: vm_glue.c:vm_proc_new() allocates memory for u-area with MAP_NOFAULT vm_glue.c:vm_proc_swapout() calls pmap_qremove() for u-area vm_glue.c:vm_proc_swapin() fills u-area and calls pmap_qenter() for it vm_fault.c:vm_failt() panics if a page fault occurred for vm_map_entry which has MAP_ENTRY_NOFAULT, you got this panic I think. ps: not related to topic, but I think that ru_idrss and ru_isrss are not something you need, according to first lines of your letter.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050215132020.GA376>