tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

malloc(9) -> kmem(9) for wapbl



Here the patch removing malloc(9) from wapbl...
Index: vfs_wapbl.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_wapbl.c,v
retrieving revision 1.50
diff -u -p -r1.50 vfs_wapbl.c
--- vfs_wapbl.c 27 Jan 2012 19:48:40 -0000      1.50
+++ vfs_wapbl.c 28 Jan 2012 16:17:15 -0000
@@ -63,16 +63,9 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,
 
 #include <miscfs/specfs/specdev.h>
 
-#if 0 /* notyet */
-#define        wapbl_malloc(s) kmem_intr_alloc((s), KM_SLEEP)
-#define        wapbl_free(a, s) kmem_intr_free((a), (s))
-#define        wapbl_calloc(n, s) kmem_intr_zalloc((n)*(s), KM_SLEEP)
-#else
-MALLOC_JUSTDEFINE(M_WAPBL, "wapbl", "write-ahead physical block logging");
-#define        wapbl_malloc(s) malloc((s), M_WAPBL, M_WAITOK)
-#define        wapbl_free(a, s) free((a), M_WAPBL)
-#define        wapbl_calloc(n, s) malloc((n)*(s), M_WAPBL, M_WAITOK | M_ZERO)
-#endif
+#define        wapbl_malloc(s) kmem_alloc((s), KM_SLEEP)
+#define        wapbl_free(a, s) kmem_free((a), (s))
+#define        wapbl_calloc(n, s) kmem_zalloc((n)*(s), KM_SLEEP)
 
 static struct sysctllog *wapbl_sysctl;
 static int wapbl_flush_disk_cache = 1;
@@ -220,6 +213,8 @@ static inline size_t wapbl_space_used(si
 
 #ifdef _KERNEL
 
+static struct pool wapbl_entry_pool;
+
 #define        WAPBL_INODETRK_SIZE 83
 static int wapbl_ino_pool_refcount;
 static struct pool wapbl_ino_pool;
@@ -310,7 +305,10 @@ wapbl_sysctl_init(void)
 static void
 wapbl_init(void)
 {
-       //malloc_type_attach(M_WAPBL);
+
+       pool_init(&wapbl_entry_pool, sizeof(struct wapbl_entry), 0, 0, 0,
+           "wapblentrypl", &pool_allocator_kmem, IPL_VM);
+
        wapbl_sysctl_init();
 }
 
@@ -318,8 +316,12 @@ wapbl_init(void)
 static int
 wapbl_fini(bool interface)
 {
+
        if (aio_sysctl != NULL)
                 sysctl_teardown(&aio_sysctl);
+
+       pool_destroy(&wapbl_entry_pool);
+
        return 0;
 }
 #endif
@@ -657,7 +659,7 @@ wapbl_discard(struct wapbl *wl)
 #ifdef WAPBL_DEBUG_BUFBYTES
                        KASSERT(we->we_unsynced_bufbytes == 0);
 #endif
-                       wapbl_free(we, sizeof(*we));
+                       pool_put(&wapbl_entry_pool, we);
                }
        }
 
@@ -1239,7 +1241,7 @@ wapbl_biodone(struct buf *bp)
 #ifdef WAPBL_DEBUG_BUFBYTES
                        KASSERT(we->we_unsynced_bufbytes == 0);
 #endif
-                       wapbl_free(we, sizeof(*we));
+                       pool_put(&wapbl_entry_pool, we);
                }
 
                brelse(bp, 0);
@@ -1331,7 +1333,7 @@ wapbl_biodone(struct buf *bp)
                        if (we->we_error)
                                errcnt++;
                        SIMPLEQ_REMOVE_HEAD(&wl->wl_entries, we_entries);
-                       wapbl_free(we, sizeof(*we));
+                       pool_put(&wapbl_entry_pool, we);
                }
 
                if (delta) {
@@ -1472,7 +1474,7 @@ wapbl_flush(struct wapbl *wl, int waitfo
        if (error)
                goto out2;
 
-       we = wapbl_calloc(1, sizeof(*we));
+       we = pool_get(&wapbl_entry_pool, PR_WAITOK);
 
 #ifdef WAPBL_DEBUG_BUFBYTES
        WAPBL_PRINTF(WAPBL_PRINT_FLUSH,


Home | Main Index | Thread Index | Old Index