Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Dec 2003 00:18:20 +0000
From:      David Malone <dwmalone@maths.tcd.ie>
To:        freebsd-current@freebsd.org
Subject:   Re: file descriptor leak in 5.2-RC
Message-ID:  <20031227001820.GA89334@walton.maths.tcd.ie>
In-Reply-To: <20031226190356.GD79023@e-Gitt.NET>
References:  <20031224154121.GA83770@e-Gitt.NET> <Pine.NEB.3.96L.1031224110359.66152B-100000@fledge.watson.org> <20031225204626.GA68589@e-Gitt.NET> <20031225215838.GB68589@e-Gitt.NET> <20031225222029.GC68589@e-Gitt.NET> <20031226002654.GB6757@e-Gitt.NET> <Pine.BSF.4.53.0312260145120.74127@e0-0.zab2.int.zabbadoz.net> <20031226162329.GA79023@e-Gitt.NET> <20031226190356.GD79023@e-Gitt.NET>

next in thread | previous in thread | raw e-mail | index | archive | help
> during the machine is running on high load and after going to single 
> user mode. You can clearly see, that even though kern.openfiles still 
> shows a high number, pstat -f only finds very few files.

Ahhh crud - the kern.file sysctl isn't completly calculated from
the list of all open files - it iterates through all the processes
to form the final list. Could you try rerunning pstat with the patch
below - it walks the full open file list, rather than checking each
process (this may leak open file info to people within jails on the
machine, hopefully that is not a problem for you...)

(You'll need to recompile your kernel, but not anything else...)

If the files start to show up here, then we can begin to figure out
where they're comming from.

	David.


Index: sys/kern/kern_descrip.c
===================================================================
RCS file: /cvs/FreeBSD-CVS/src/sys/kern/kern_descrip.c,v
retrieving revision 1.215
diff -u -r1.215 kern_descrip.c
--- sys/kern/kern_descrip.c	19 Oct 2003 20:41:06 -0000	1.215
+++ sys/kern/kern_descrip.c	27 Dec 2003 00:01:06 -0000
@@ -2312,6 +2312,24 @@
 	error = 0;
 	bzero(&xf, sizeof(xf));
 	xf.xf_size = sizeof(xf);
+	/* DMXXX */
+	sx_slock(&filelist_lock);
+	LIST_FOREACH(fp, &filehead, f_list) {
+		xf.xf_fd = 0;
+		xf.xf_file = fp;
+		xf.xf_data = fp->f_data;
+		xf.xf_type = fp->f_type;
+		xf.xf_count = fp->f_count;
+		xf.xf_msgcount = fp->f_msgcount;
+		xf.xf_offset = fp->f_offset;
+		xf.xf_flag = fp->f_flag;
+		error = SYSCTL_OUT(req, &xf, sizeof(xf));
+		if (error)
+			break;
+	}
+	sx_sunlock(&filelist_lock);
+	return (error);
+	/* DMXXX */
 	sx_slock(&allproc_lock);
 	LIST_FOREACH(p, &allproc, p_list) {
 		PROC_LOCK(p);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031227001820.GA89334>