|
diff --git a/sys/netbt/bt_proto.c b/sys/netbt/bt_proto.c
|
|
index 0a1ca9b..54c5eb7 100644
|
|
--- a/sys/netbt/bt_proto.c
|
|
+++ b/sys/netbt/bt_proto.c
|
|
@@ -136,24 +136,24 @@ struct protosw btsw[] = {
|
|
static void
|
|
netbt_dispose(struct mbuf* m)
|
|
{
|
|
- zdestroy(l2cap_pdu_pool);
|
|
- zdestroy(l2cap_req_pool);
|
|
- zdestroy(rfcomm_credit_pool);
|
|
+ objcache_destroy(l2cap_pdu_pool);
|
|
+ objcache_destroy(l2cap_req_pool);
|
|
+ objcache_destroy(rfcomm_credit_pool);
|
|
}
|
|
|
|
static void
|
|
netbt_init(void)
|
|
{
|
|
- l2cap_pdu_pool = zinit("l2cap_pdu", sizeof(struct l2cap_pdu), 1,
|
|
- ZONE_DESTROYABLE, 1);
|
|
+ l2cap_pdu_pool = objcache_create_simple(M_L2CAPPDU,
|
|
+ sizeof(struct l2cap_pdu));
|
|
if (l2cap_pdu_pool == NULL)
|
|
goto fail;
|
|
- l2cap_req_pool = zinit("l2cap_req", sizeof(struct l2cap_req), 1,
|
|
- ZONE_DESTROYABLE, 1);
|
|
+ l2cap_req_pool = objcache_create_simple(M_L2CAPREQ,
|
|
+ sizeof(struct l2cap_req));
|
|
if (l2cap_req_pool == NULL)
|
|
goto fail;
|
|
- rfcomm_credit_pool = zinit("rfcomm_credit",
|
|
- sizeof(struct rfcomm_credit), 1, ZONE_DESTROYABLE, 1);
|
|
+ rfcomm_credit_pool = objcache_create_simple(M_RFCOMMCREDIT,
|
|
+ sizeof(struct rfcomm_credit));
|
|
if (rfcomm_credit_pool == NULL)
|
|
goto fail;
|
|
return;
|
|
diff --git a/sys/netbt/hci_link.c b/sys/netbt/hci_link.c
|
|
index 8995ff1..68fbdd8 100644
|
|
--- a/sys/netbt/hci_link.c
|
|
+++ b/sys/netbt/hci_link.c
|
|
@@ -549,7 +549,7 @@ hci_acl_send(struct mbuf *m, struct hci_link *link,
|
|
return ENETDOWN;
|
|
}
|
|
|
|
- pdu = zalloc(l2cap_pdu_pool);
|
|
+ pdu = objcache_get(l2cap_pdu_pool, M_WAITOK);
|
|
if (pdu == NULL)
|
|
goto nomem;
|
|
|
|
@@ -594,7 +594,7 @@ nomem:
|
|
if (m) m_freem(m);
|
|
if (pdu) {
|
|
IF_DRAIN(&pdu->lp_data);
|
|
- zfree(l2cap_pdu_pool, pdu);
|
|
+ objcache_dtor(l2cap_pdu_pool, pdu);
|
|
}
|
|
|
|
return ENOMEM;
|
|
@@ -740,7 +740,7 @@ hci_acl_complete(struct hci_link *link, int num)
|
|
l2cap_start(chan);
|
|
}
|
|
|
|
- zfree(l2cap_pdu_pool, pdu);
|
|
+ objcache_dtor(l2cap_pdu_pool, pdu);
|
|
}
|
|
} else {
|
|
pdu->lp_pending -= num;
|
|
@@ -965,7 +965,7 @@ hci_link_free(struct hci_link *link, int err)
|
|
if (pdu->lp_pending)
|
|
link->hl_unit->hci_num_acl_pkts += pdu->lp_pending;
|
|
|
|
- zfree(l2cap_pdu_pool, pdu);
|
|
+ objcache_dtor(l2cap_pdu_pool, pdu);
|
|
}
|
|
|
|
KKASSERT(TAILQ_EMPTY(&link->hl_txq));
|
|
diff --git a/sys/netbt/l2cap.h b/sys/netbt/l2cap.h
|
|
index fe2286a..24d1bed 100644
|
|
--- a/sys/netbt/l2cap.h
|
|
+++ b/sys/netbt/l2cap.h
|
|
@@ -72,6 +72,7 @@
|
|
#define _NETBT_L2CAP_H_
|
|
|
|
#include <sys/types.h>
|
|
+#include <sys/objcache.h>
|
|
|
|
/**************************************************************************
|
|
**************************************************************************
|
|
@@ -354,17 +355,18 @@ typedef union {
|
|
#define L2CAP_LM_SECURE (1<<2) /* want secured link */
|
|
|
|
#ifdef _KERNEL
|
|
-#include <vm/vm_zone.h>
|
|
|
|
#include <net/if.h> /* for struct ifqueue */
|
|
|
|
LIST_HEAD(l2cap_channel_list, l2cap_channel);
|
|
|
|
/* global variables */
|
|
+MALLOC_DECLARE(M_L2CAPREQ);
|
|
+MALLOC_DECLARE(M_L2CAPPDU);
|
|
extern struct l2cap_channel_list l2cap_active_list;
|
|
extern struct l2cap_channel_list l2cap_listen_list;
|
|
-extern vm_zone_t l2cap_pdu_pool;
|
|
-extern vm_zone_t l2cap_req_pool;
|
|
+extern struct objcache *l2cap_pdu_pool;
|
|
+extern struct objcache *l2cap_req_pool;
|
|
extern const l2cap_qos_t l2cap_default_qos;
|
|
|
|
/* sysctl variables */
|
|
diff --git a/sys/netbt/l2cap_misc.c b/sys/netbt/l2cap_misc.c
|
|
index 0b63067..21c6216 100644
|
|
--- a/sys/netbt/l2cap_misc.c
|
|
+++ b/sys/netbt/l2cap_misc.c
|
|
@@ -48,8 +48,10 @@ struct l2cap_channel_list
|
|
struct l2cap_channel_list
|
|
l2cap_listen_list = LIST_HEAD_INITIALIZER(l2cap_listen_list);
|
|
|
|
-vm_zone_t l2cap_req_pool;
|
|
-vm_zone_t l2cap_pdu_pool;
|
|
+MALLOC_DEFINE(M_L2CAPREQ, "l2cap_req", "l2cap_req objcache");
|
|
+MALLOC_DEFINE(M_L2CAPPDU, "l2cap_pdu", "l2cap_pdu objcache");
|
|
+struct objcache *l2cap_req_pool;
|
|
+struct objcache *l2cap_pdu_pool;
|
|
|
|
const l2cap_qos_t l2cap_default_qos = {
|
|
0, /* flags */
|
|
@@ -122,7 +124,7 @@ l2cap_request_alloc(struct l2cap_channel *chan, uint8_t code)
|
|
if (req && req->lr_id == next_id)
|
|
return ENFILE;
|
|
|
|
- req = zalloc(l2cap_req_pool);
|
|
+ req = objcache_get(l2cap_req_pool, M_WAITOK);
|
|
if (req == NULL)
|
|
return ENOMEM;
|
|
|
|
@@ -170,7 +172,7 @@ l2cap_request_free(struct l2cap_req *req)
|
|
return;
|
|
|
|
TAILQ_REMOVE(&link->hl_reqs, req, lr_next);
|
|
- zfree(l2cap_req_pool, req);
|
|
+ objcache_dtor(l2cap_req_pool, req);
|
|
}
|
|
|
|
/*
|
|
diff --git a/sys/netbt/l2cap_socket.c b/sys/netbt/l2cap_socket.c
|
|
index 164bf17..cf5e3e5 100644
|
|
--- a/sys/netbt/l2cap_socket.c
|
|
+++ b/sys/netbt/l2cap_socket.c
|
|
@@ -49,8 +49,6 @@
|
|
|
|
#include <sys/msgport2.h>
|
|
|
|
-#include <vm/vm_zone.h>
|
|
-
|
|
#include <netbt/bluetooth.h>
|
|
#include <netbt/hci.h> /* XXX for EPASSTHROUGH */
|
|
#include <netbt/l2cap.h>
|
|
diff --git a/sys/netbt/rfcomm.h b/sys/netbt/rfcomm.h
|
|
index ff9c324..591164f 100644
|
|
--- a/sys/netbt/rfcomm.h
|
|
+++ b/sys/netbt/rfcomm.h
|
|
@@ -65,6 +65,7 @@
|
|
#define _NETBT_RFCOMM_H_
|
|
|
|
#include <sys/types.h>
|
|
+#include <sys/objcache.h>
|
|
|
|
/*************************************************************************
|
|
*************************************************************************
|
|
@@ -426,7 +427,8 @@ int rfcomm_setopt(struct rfcomm_dlc *, int, void *);
|
|
int rfcomm_setopt2(struct rfcomm_dlc *, int, struct socket *, struct sockopt *);
|
|
int rfcomm_getopt(struct rfcomm_dlc *, int, void *);
|
|
|
|
-extern vm_zone_t rfcomm_credit_pool;
|
|
+MALLOC_DECLARE(M_RFCOMMCREDIT);
|
|
+extern struct objcache *rfcomm_credit_pool;
|
|
#endif /* _KERNEL */
|
|
|
|
#endif /* _NETBT_RFCOMM_H_ */
|
|
diff --git a/sys/netbt/rfcomm_session.c b/sys/netbt/rfcomm_session.c
|
|
index 58531e3..a0d12f2 100644
|
|
--- a/sys/netbt/rfcomm_session.c
|
|
+++ b/sys/netbt/rfcomm_session.c
|
|
@@ -95,7 +95,9 @@ struct rfcomm_session_list
|
|
struct rfcomm_session_list
|
|
rfcomm_session_listen = LIST_HEAD_INITIALIZER(rfcomm_session_listen);
|
|
|
|
-vm_zone_t rfcomm_credit_pool;
|
|
+
|
|
+MALLOC_DEFINE(M_RFCOMMCREDIT, "rfcomm_credit", "rfcomm_credit cache");
|
|
+struct objcache *rfcomm_credit_pool;
|
|
|
|
/*
|
|
* RFCOMM System Parameters (see section 5.3)
|
|
@@ -159,8 +161,9 @@ static const uint8_t crctable[256] = { /* reversed, 8-bit, poly=0x07 */
|
|
void
|
|
rfcomm_init(void)
|
|
{
|
|
- rfcomm_credit_pool = zinit("rfcomm_credit",
|
|
- sizeof(struct rfcomm_credit), 0, 0, 0);
|
|
+ rfcomm_credit_pool = objcache_create_simple(
|
|
+ M_RFCOMMCREDIT,
|
|
+ sizeof(struct rfcomm_credit));
|
|
}
|
|
|
|
/*
|
|
@@ -242,7 +245,7 @@ rfcomm_session_free(struct rfcomm_session *rs)
|
|
/* throw away any remaining credit notes */
|
|
while ((credit = STAILQ_FIRST(&rs->rs_credits)) != NULL) {
|
|
STAILQ_REMOVE_HEAD(&rs->rs_credits, rc_next);
|
|
- zfree(rfcomm_credit_pool, credit);
|
|
+ objcache_dtor(rfcomm_credit_pool, credit);
|
|
}
|
|
|
|
KKASSERT(STAILQ_EMPTY(&rs->rs_credits));
|
|
@@ -481,7 +484,7 @@ rfcomm_session_complete(void *arg, int count)
|
|
}
|
|
|
|
STAILQ_REMOVE_HEAD(&rs->rs_credits, rc_next);
|
|
- zfree(rfcomm_credit_pool, credit);
|
|
+ objcache_dtor(rfcomm_credit_pool, credit);
|
|
}
|
|
|
|
/*
|
|
@@ -1458,13 +1461,13 @@ rfcomm_session_send_frame(struct rfcomm_session *rs, int type, int dlci)
|
|
struct mbuf *m;
|
|
uint8_t fcs, cr;
|
|
|
|
- credit = zalloc(rfcomm_credit_pool);
|
|
+ credit = objcache_get(rfcomm_credit_pool, M_NOWAIT);
|
|
if (credit == NULL)
|
|
return ENOMEM;
|
|
|
|
m = m_gethdr(MB_DONTWAIT, MT_DATA);
|
|
if (m == NULL) {
|
|
- zfree(rfcomm_credit_pool, credit);
|
|
+ objcache_dtor(rfcomm_credit_pool, credit);
|
|
return ENOMEM;
|
|
}
|
|
|
|
@@ -1529,7 +1532,7 @@ rfcomm_session_send_uih(struct rfcomm_session *rs, struct rfcomm_dlc *dlc,
|
|
/*
|
|
* Make a credit note for the completion notification
|
|
*/
|
|
- credit = zalloc(rfcomm_credit_pool);
|
|
+ credit = objcache_get(rfcomm_credit_pool, M_NOWAIT);
|
|
if (credit == NULL)
|
|
goto nomem;
|
|
|
|
@@ -1620,7 +1623,7 @@ nomem:
|
|
|
|
fail:
|
|
if (credit != NULL)
|
|
- zfree(rfcomm_credit_pool, credit);
|
|
+ objcache_dtor(rfcomm_credit_pool, credit);
|
|
|
|
return err;
|
|
}
|
|
diff --git a/sys/netbt/rfcomm_socket.c b/sys/netbt/rfcomm_socket.c
|
|
index 3357d13..5f68c2c 100644
|
|
--- a/sys/netbt/rfcomm_socket.c
|
|
+++ b/sys/netbt/rfcomm_socket.c
|
|
@@ -50,8 +50,6 @@
|
|
|
|
#include <sys/msgport2.h>
|
|
|
|
-#include <vm/vm_zone.h>
|
|
-
|
|
#include <netbt/bluetooth.h>
|
|
#include <netbt/hci.h> /* XXX for EPASSTHROUGH */
|
|
#include <netbt/rfcomm.h>
|
|
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
|
|
index 3181c89..a45c9c8 100644
|
|
--- a/sys/vm/swap_pager.c
|
|
+++ b/sys/vm/swap_pager.c
|
|
@@ -107,6 +107,7 @@
|
|
#include <sys/blist.h>
|
|
#include <sys/lock.h>
|
|
#include <sys/thread2.h>
|
|
+#include <sys/objcache.h>
|
|
|
|
#include "opt_swap.h"
|
|
#include <vm/vm.h>
|
|
@@ -116,7 +117,6 @@
|
|
#include <vm/vm_pageout.h>
|
|
#include <vm/swap_pager.h>
|
|
#include <vm/vm_extern.h>
|
|
-#include <vm/vm_zone.h>
|
|
#include <vm/vnode_pager.h>
|
|
|
|
#include <sys/buf2.h>
|
|
@@ -191,7 +191,11 @@ SYSCTL_INT(_vm, OID_AUTO, swap_size,
|
|
SYSCTL_INT(_vm, OID_AUTO, report_swap_allocs,
|
|
CTLFLAG_RW, &vm_report_swap_allocs, 0, "");
|
|
|
|
-vm_zone_t swap_zone;
|
|
+MALLOC_DEFINE(M_SWAPZONE, "SWAP ZONE", "SWAP ZONE objcache");
|
|
+struct objcache_malloc_args swap_zone_malloc_args = {
|
|
+ sizeof(struct swblock), M_SWAPZONE
|
|
+};
|
|
+struct objcache *swap_zone;
|
|
|
|
/*
|
|
* Red-Black tree for swblock entries
|
|
@@ -390,12 +394,13 @@ swap_pager_swap_init(void)
|
|
n2 = n;
|
|
|
|
do {
|
|
- swap_zone = zinit(
|
|
- "SWAPMETA",
|
|
- sizeof(struct swblock),
|
|
- n,
|
|
- ZONE_INTERRUPT,
|
|
- 1);
|
|
+ swap_zone = objcache_create(
|
|
+ "SWAPMETA",
|
|
+ 0,
|
|
+ n, NULL, NULL, NULL,
|
|
+ objcache_malloc_alloc,
|
|
+ objcache_malloc_free,
|
|
+ &swap_zone_malloc_args);
|
|
if (swap_zone != NULL)
|
|
break;
|
|
/*
|
|
@@ -2166,7 +2171,7 @@ retry:
|
|
if (swap == NULL) {
|
|
int i;
|
|
|
|
- swap = zalloc(swap_zone);
|
|
+ swap = objcache_get(swap_zone, M_WAITOK);
|
|
if (swap == NULL) {
|
|
vm_wait(0);
|
|
goto retry;
|
|
@@ -2295,7 +2300,7 @@ swp_pager_meta_free_callback(struct swblock *swap, void *data)
|
|
--mycpu->gd_vmtotal.t_vm;
|
|
if (--swap->swb_count == 0) {
|
|
swp_pager_remove(object, swap);
|
|
- zfree(swap_zone, swap);
|
|
+ objcache_dtor(swap_zone, swap);
|
|
--object->swblock_count;
|
|
break;
|
|
}
|
|
@@ -2341,7 +2346,7 @@ swp_pager_meta_free_all(vm_object_t object)
|
|
}
|
|
if (swap->swb_count != 0)
|
|
panic("swap_pager_meta_free_all: swb_count != 0");
|
|
- zfree(swap_zone, swap);
|
|
+ objcache_dtor(swap_zone, swap);
|
|
--object->swblock_count;
|
|
lwkt_yield();
|
|
}
|
|
@@ -2392,7 +2397,7 @@ swp_pager_meta_ctl(vm_object_t object, vm_pindex_t index, int flags)
|
|
--mycpu->gd_vmtotal.t_vm;
|
|
if (--swap->swb_count == 0) {
|
|
swp_pager_remove(object, swap);
|
|
- zfree(swap_zone, swap);
|
|
+ objcache_dtor(swap_zone, swap);
|
|
--object->swblock_count;
|
|
}
|
|
}
|