[openib-general] [PATCH] ib_mad.c: Use mad cache for receive
Hal Rosenstock
halr at voltaire.com
Thu Sep 16 07:00:36 PDT 2004
ib_mad.c: Use mad cache for receive
Index: ib_mad.c
===================================================================
--- ib_mad.c (revision 849)
+++ ib_mad.c (working copy)
@@ -374,11 +374,11 @@
*/
list_for_each_entry(entry, &mad_recv_wc->recv_buf->list, list) {
/* Free previous receive buffer */
- kfree(buffer);
+ kmem_cache_free(ib_mad_cache, buffer);
buffer = (void *)entry - sizeof(struct ib_mad_private_header);
}
/* Free last buffer */
- kfree(buffer);
+ kmem_cache_free(ib_mad_cache, buffer);
}
EXPORT_SYMBOL(ib_free_recv_mad);
@@ -959,9 +959,9 @@
* By prepending this header, there is one rather
* than two memory allocations.
*/
- mad_priv = kmalloc(sizeof *mad_priv,
- (in_atomic() || irqs_disabled()) ?
- GFP_ATOMIC : GFP_KERNEL);
+ mad_priv = kmem_cache_alloc(ib_mad_cache,
+ (in_atomic() || irqs_disabled()) ?
+ GFP_ATOMIC : GFP_KERNEL);
if (!mad_priv) {
printk(KERN_ERR "No memory for receive buffer\n");
return -ENOMEM;
@@ -1005,7 +1005,7 @@
port_priv->recv_posted_mad_count[convert_qpnum(qp->qp_num)]--;
spin_unlock_irqrestore(&port_priv->recv_list_lock, flags);
- kfree(mad_priv);
+ kmem_cache_free(ib_mad_cache, mad_priv);
printk(KERN_NOTICE "ib_post_recv failed\n");
return -EINVAL;
}
More information about the general
mailing list