Date: Sat, 26 Jan 2008 03:20:43 GMT From: Scot Hetzel <swhetzel@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/119993: ddb capture buffer too small for textdumps Message-ID: <200801260320.m0Q3KhqA096306@www.freebsd.org> Resent-Message-ID: <200801260330.m0Q3U1r0027154@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 119993 >Category: kern >Synopsis: ddb capture buffer too small for textdumps >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jan 26 03:30:01 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Scot Hetzel >Release: 8.0-CURRENT >Organization: >Environment: FreeBSD hp010.hetzel.org 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Sat Jan 19 00:03:54 CST 2008 root@hp010.hetzel.org:/usr/src/sys/amd64/compile/DV8135NR amd64 >Description: While trying to debug a kernel panic, I decided to try the new textdump feature and scripted ddb. I increased debug.ddb.capture.bufsize to it's maximum size (512K). When the kerne paniced, the kdb.enter.panic script ran but had its output truncated to 512K. debug.ddb.capture.bufsize: 49152 debug.ddb.capture.maxbufsize: 524288 The problem is that sys/ddb/db_capture.c has fixed DB_CAPTURE_MAXBUFSIZE to 512K. I was able to get the full output by increasing DB_CAPTURE_MAXBUFSIZE to 5M (3M would have been enough, as ddb.txt was only 2.7M). >How-To-Repeat: Add the following to the kernel config file: options DEBUG_VFS_LOCKS options KTR options KTR_COMPILE=(KTR_SPARE2) options KTR_MASK=(KTR_SPARE2) options KTR_ENTRIES=32768 and then build/install the kernel. After the reboot, use ddb to add the following scripts: /sbin/ddb script lockinfo="show locks; show alllocks; show lockedvnods" /sbin/ddb script kdb.enter.panic="textdump set; capture on; show ktr ; run lockinfo ; show pcpu; bt; ps; alltrace; capture off; call doadump; reset" sysctl debug.ddb.capture.bufsize=524288 Then do something that causes the kernel to panic. >Fix: Apply the attached patch which adds two kernel options to allow the capture buffer size to be changed in the kernel config file: options DB_CAPTURE_DEFAULTBUFSIZE=2*1024*1024 options DB_CAPTURE_MAXBUFSIZE=5*1024*1024 Should DB_CAPTURE* be changed to DDB_CAPTURE*? Will require a change in ddb/db_capture.c also. Note: DB_CAPTURE_DEFAULTBUFSIZE can also be set by sysctl. Patch attached with submission follows: Index: conf/options =================================================================== RCS file: /home/ncvs/src/sys/conf/options,v retrieving revision 1.615 diff -u -r1.615 options --- conf/options 7 Jan 2008 21:40:09 -0000 1.615 +++ conf/options 25 Jan 2008 23:52:31 -0000 @@ -49,6 +49,8 @@ # Debugging options. DDB DDB_NUMSYM opt_ddb.h +DB_CAPTURE_DEFAULTBUFSIZE opt_ddb.h +DB_CAPTURE_MAXBUFSIZE opt_ddb.h GDB KDB opt_global.h KDB_TRACE opt_kdb.h Index: ddb/db_capture.c =================================================================== RCS file: /home/ncvs/src/sys/ddb/db_capture.c,v retrieving revision 1.2 diff -u -r1.2 db_capture.c --- ddb/db_capture.c 26 Dec 2007 11:32:32 -0000 1.2 +++ ddb/db_capture.c 25 Jan 2008 23:50:46 -0000 @@ -46,6 +46,8 @@ #include <ddb/ddb.h> #include <ddb/db_lex.h> +#include <opt_ddb.h> + /* * While it would be desirable to use a small block-sized buffer and dump * incrementally to disk in fixed-size blocks, it's not possible to enter @@ -55,8 +57,12 @@ */ static MALLOC_DEFINE(M_DB_CAPTURE, "db_capture", "DDB capture buffer"); +#ifndef DB_CAPTURE_DEFAULTBUFSIZE #define DB_CAPTURE_DEFAULTBUFSIZE 48*1024 +#endif +#ifndef DB_CAPTURE_MAXBUFSIZE #define DB_CAPTURE_MAXBUFSIZE 512*1024 +#endif #define DB_CAPTURE_FILENAME "ddb.txt" /* Captured DDB output. */ static char *db_capture_buf; >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801260320.m0Q3KhqA096306>