Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Oct 2005 19:42:35 GMT
From:      Todd Miller <millert@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 85946 for review
Message-ID:  <200510271942.j9RJgZaM023359@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <vm/vm_kern.h>
 #include <kern/kalloc.h>
 
+/*
+ * 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()) {



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