From owner-svn-src-all@FreeBSD.ORG Thu Apr 23 21:09:47 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 82CF8106566C; Thu, 23 Apr 2009 21:09:47 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 575C68FC16; Thu, 23 Apr 2009 21:09:47 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3NL9lLx099405; Thu, 23 Apr 2009 21:09:47 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3NL9lQ8099404; Thu, 23 Apr 2009 21:09:47 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200904232109.n3NL9lQ8099404@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 23 Apr 2009 21:09:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191439 - head/sys/vm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Apr 2009 21:09:48 -0000 Author: kib Date: Thu Apr 23 21:09:47 2009 New Revision: 191439 URL: http://svn.freebsd.org/changeset/base/191439 Log: Do not call vm_page_lookup() from the ddb routine, namely from "show vmopag" implementation. The vm_page_lookup() code modifies splay tree of the object pages, and asserts that object lock is taken. First issue could cause kernel data corruption, and second one instantly panics the INVARIANTS-enabled kernel. Take the advantage of the fact that object->memq is ordered by page index, and iterate over memq to calculate the runs. While there, make the code slightly more style-compliant by moving variables declarations to the right place. Discussed with: jhb, alc Reviewed by: alc MFC after: 2 weeks Modified: head/sys/vm/vm_object.c Modified: head/sys/vm/vm_object.c ============================================================================== --- head/sys/vm/vm_object.c Thu Apr 23 20:24:19 2009 (r191438) +++ head/sys/vm/vm_object.c Thu Apr 23 21:09:47 2009 (r191439) @@ -2196,16 +2196,13 @@ vm_object_print( DB_SHOW_COMMAND(vmopag, vm_object_print_pages) { vm_object_t object; - int nl = 0; - int c; + vm_pindex_t fidx; + vm_paddr_t pa; + vm_page_t m, prev_m; + int rcount, nl, c; + nl = 0; TAILQ_FOREACH(object, &vm_object_list, object_list) { - vm_pindex_t idx, fidx; - vm_pindex_t osize; - vm_paddr_t pa = -1; - int rcount; - vm_page_t m; - db_printf("new object: %p\n", (void *)object); if (nl > 18) { c = cngetc(); @@ -2216,12 +2213,12 @@ DB_SHOW_COMMAND(vmopag, vm_object_print_ nl++; rcount = 0; fidx = 0; - osize = object->size; - if (osize > 128) - osize = 128; - for (idx = 0; idx < osize; idx++) { - m = vm_page_lookup(object, idx); - if (m == NULL) { + pa = -1; + TAILQ_FOREACH(m, &object->memq, listq) { + if (m->pindex > 128) + break; + if ((prev_m = TAILQ_PREV(m, pglist, listq)) != NULL && + prev_m->pindex + 1 != m->pindex) { if (rcount) { db_printf(" index(%ld)run(%d)pa(0x%lx)\n", (long)fidx, rcount, (long)pa); @@ -2234,10 +2231,7 @@ DB_SHOW_COMMAND(vmopag, vm_object_print_ nl++; rcount = 0; } - continue; - } - - + } if (rcount && (VM_PAGE_TO_PHYS(m) == pa + rcount * PAGE_SIZE)) { ++rcount; @@ -2254,7 +2248,7 @@ DB_SHOW_COMMAND(vmopag, vm_object_print_ } nl++; } - fidx = idx; + fidx = m->pindex; pa = VM_PAGE_TO_PHYS(m); rcount = 1; }