From owner-p4-projects@FreeBSD.ORG Thu Oct 27 19:42:36 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5C59116A465; Thu, 27 Oct 2005 19:42:36 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1C45F16A462 for ; Thu, 27 Oct 2005 19:42:36 +0000 (GMT) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id DBDD643D53 for ; Thu, 27 Oct 2005 19:42:35 +0000 (GMT) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j9RJgZ9l023364 for ; Thu, 27 Oct 2005 19:42:35 GMT (envelope-from millert@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j9RJgZaM023359 for perforce@freebsd.org; Thu, 27 Oct 2005 19:42:35 GMT (envelope-from millert@freebsd.org) Date: Thu, 27 Oct 2005 19:42:35 GMT Message-Id: <200510271942.j9RJgZaM023359@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to millert@freebsd.org using -f From: Todd Miller To: Perforce Change Reviews Cc: Subject: PERFORCE change 85946 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Oct 2005 19:42:37 -0000 http://perforce.freebsd.org/chv.cgi?CH=85946 Change 85946 by millert@millert_ibook on 2005/10/27 19:41:45 Add sebsd_malloc_init() to populate the free list with a large number of small allocations (512). This prevents a panic due to free list exhaustion caused by non-blocking allocation early on in avc_init(). Not very nice but a workaround until we have a better solution. Affected files ... .. //depot/projects/trustedbsd/sedarwin7/src/sedarwin/sedarwin/sebsd.c#16 edit Differences ... ==== //depot/projects/trustedbsd/sedarwin7/src/sedarwin/sedarwin/sebsd.c#16 (text+ko) ==== @@ -76,6 +76,27 @@ #include #include +/* + * XXX + * Hack to populate the free list with lots of small allocations. + * Needed to make non-blocking allocations work early on in the + * boot sequence. Otherwise we crash in avc_init(). + * XXX + * +void +sebsd_malloc_init(void) +{ + int i; + void *prealloc[512]; + + for (i = 0; i < 512; i++) { + if ((prealloc[i] = kalloc(64)) == NULL) + break; + } + while (i--) + kfree(prealloc[i], 64); +} + void * sebsd_malloc(size_t size, int flags) { @@ -132,6 +153,7 @@ { printf("sebsd:: init\n"); + sebsd_malloc_init(); avc_init(); //sebsd_register_sysctls(); if (security_init()) {