@@ -83,13 +83,17 @@
/* default timeout */
#define DEFAULT_PEER_TIMEOUT 180
+#define LNET_LND_DEFAULT_TIMEOUT 5
+
+bool lnet_is_route_alive(struct lnet_route *route);
#define LNET_SMALL_MD_SIZE offsetof(struct lnet_libmd, md_iov.iov[1])
extern struct kmem_cache *lnet_mes_cachep; /* MEs kmem_cache */
extern struct kmem_cache *lnet_small_mds_cachep; /* <= LNET_SMALL_MD_SIZE bytes
* MDs kmem_cache
*/
-#define LNET_LND_DEFAULT_TIMEOUT 5
+extern struct kmem_cache *lnet_rspt_cachep;
+extern struct kmem_cache *lnet_msg_cachep;
bool lnet_is_route_alive(struct lnet_route *route);
bool lnet_is_gateway_alive(struct lnet_peer *gw);
@@ -417,19 +421,22 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec,
{
struct lnet_rsp_tracker *rspt;
- rspt = kzalloc(sizeof(*rspt), GFP_NOFS);
+ rspt = kmem_cache_zalloc(lnet_rspt_cachep, GFP_NOFS);
if (rspt) {
lnet_net_lock(cpt);
the_lnet.ln_counters[cpt]->lct_health.lch_rst_alloc++;
lnet_net_unlock(cpt);
}
+ CDEBUG(D_MALLOC, "rspt alloc %p\n", rspt);
return rspt;
}
static inline void
lnet_rspt_free(struct lnet_rsp_tracker *rspt, int cpt)
{
- kfree(rspt);
+ CDEBUG(D_MALLOC, "rspt free %p\n", rspt);
+
+ kmem_cache_free(lnet_rspt_cachep, rspt);
lnet_net_lock(cpt);
the_lnet.ln_counters[cpt]->lct_health.lch_rst_alloc--;
lnet_net_unlock(cpt);
@@ -494,9 +494,11 @@ static int lnet_discover(struct lnet_process_id id, u32 force,
struct kmem_cache *lnet_small_mds_cachep; /* <= LNET_SMALL_MD_SIZE bytes
* MDs kmem_cache
*/
+struct kmem_cache *lnet_rspt_cachep; /* response tracker cache */
+struct kmem_cache *lnet_msg_cachep;
static int
-lnet_descriptor_setup(void)
+lnet_slab_setup(void)
{
/* create specific kmem_cache for MEs and small MDs (i.e., originally
* allocated in <size-xxx> kmem_cache).
@@ -512,12 +514,30 @@ static int lnet_discover(struct lnet_process_id id, u32 force,
if (!lnet_small_mds_cachep)
return -ENOMEM;
+ lnet_rspt_cachep = kmem_cache_create("lnet_rspt",
+ sizeof(struct lnet_rsp_tracker),
+ 0, 0, NULL);
+ if (!lnet_rspt_cachep)
+ return -ENOMEM;
+
+ lnet_msg_cachep = kmem_cache_create("lnet_msg",
+ sizeof(struct lnet_msg),
+ 0, 0, NULL);
+ if (!lnet_msg_cachep)
+ return -ENOMEM;
+
return 0;
}
static void
-lnet_descriptor_cleanup(void)
+lnet_slab_cleanup(void)
{
+ kmem_cache_destroy(lnet_msg_cachep);
+ lnet_msg_cachep = NULL;
+
+ kmem_cache_destroy(lnet_rspt_cachep);
+ lnet_rspt_cachep = NULL;
+
kmem_cache_destroy(lnet_small_mds_cachep);
lnet_small_mds_cachep = NULL;
@@ -1081,7 +1101,7 @@ struct list_head **
LNetInvalidateEQHandle(&the_lnet.ln_mt_eqh);
init_completion(&the_lnet.ln_started);
- rc = lnet_descriptor_setup();
+ rc = lnet_slab_setup();
if (rc != 0)
goto failed;
@@ -1188,7 +1208,7 @@ struct list_head **
the_lnet.ln_counters = NULL;
}
lnet_destroy_remote_nets_table();
- lnet_descriptor_cleanup();
+ lnet_slab_cleanup();
return 0;
}
@@ -4186,7 +4186,7 @@ void lnet_monitor_thr_stop(void)
}
}
- msg = kzalloc(sizeof(*msg), GFP_NOFS);
+ msg = kmem_cache_zalloc(lnet_msg_cachep, GFP_NOFS);
if (!msg) {
CERROR("%s, src %s: Dropping %s (out of memory)\n",
libcfs_nid2str(from_nid), libcfs_nid2str(src_nid),
@@ -4194,7 +4194,7 @@ void lnet_monitor_thr_stop(void)
goto drop;
}
- /* msg zeroed by kzalloc()
+ /* msg zeroed by kmem_cache_zalloc().
* i.e. flags all clear, pointers NULL etc
*/
msg->msg_type = type;
@@ -4475,7 +4475,7 @@ void lnet_monitor_thr_stop(void)
return -EIO;
}
- msg = kzalloc(sizeof(*msg), GFP_NOFS);
+ msg = kmem_cache_zalloc(lnet_msg_cachep, GFP_NOFS);
if (!msg) {
CERROR("Dropping PUT to %s: ENOMEM on struct lnet_msg\n",
libcfs_id2str(target));
@@ -4571,7 +4571,7 @@ struct lnet_msg *
* CAVEAT EMPTOR: 'getmsg' is the original GET, which is freed when
* lnet_finalize() is called on it, so the LND must call this first
*/
- struct lnet_msg *msg = kzalloc(sizeof(*msg), GFP_NOFS);
+ struct lnet_msg *msg;
struct lnet_libmd *getmd = getmsg->msg_md;
struct lnet_process_id peer_id = getmsg->msg_target;
int cpt;
@@ -4579,6 +4579,7 @@ struct lnet_msg *
LASSERT(!getmsg->msg_target_is_router);
LASSERT(!getmsg->msg_routing);
+ msg = kmem_cache_zalloc(lnet_msg_cachep, GFP_NOFS);
if (!msg) {
CERROR("%s: Dropping REPLY from %s: can't allocate msg\n",
libcfs_nid2str(ni->ni_nid), libcfs_id2str(peer_id));
@@ -4708,7 +4709,7 @@ struct lnet_msg *
return -EIO;
}
- msg = kzalloc(sizeof(*msg), GFP_NOFS);
+ msg = kmem_cache_zalloc(lnet_msg_cachep, GFP_NOFS);
if (!msg) {
CERROR("Dropping GET to %s: ENOMEM on struct lnet_msg\n",
libcfs_id2str(target));