IB/hfi1: Improve local kmem_cache_alloc performance
authorMichael J. Ruhl <michael.j.ruhl@intel.com>
Tue, 22 Aug 2017 01:26:45 +0000 (18:26 -0700)
committerDoug Ledford <dledford@redhat.com>
Mon, 28 Aug 2017 23:12:18 +0000 (19:12 -0400)
Performance analysis shows that the cache callback function
sdma_kmem_cache_ctor contributes to 1/2 of the kmem_cache_allocs
time.

Since all of the fields in the allocated data structure are initialized
in the code path, remove the _ctor function.

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hfi1/user_sdma.c
drivers/infiniband/hw/hfi1/verbs_txreq.c
drivers/infiniband/hw/hfi1/vnic_sdma.c

index aae1f40016e40bcf856fb45c8697a5ca7ec84de3..9b89df584943ace330adf27eab009289c7c24f12 100644 (file)
@@ -331,13 +331,6 @@ static void activate_packet_queue(struct iowait *wait, int reason)
        wake_up(&wait->wait_dma);
 };
 
-static void sdma_kmem_cache_ctor(void *obj)
-{
-       struct user_sdma_txreq *tx = obj;
-
-       memset(tx, 0, sizeof(*tx));
-}
-
 int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt,
                                struct hfi1_filedata *fd)
 {
@@ -391,7 +384,7 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt,
                                            sizeof(struct user_sdma_txreq),
                                            L1_CACHE_BYTES,
                                            SLAB_HWCACHE_ALIGN,
-                                           sdma_kmem_cache_ctor);
+                                           NULL);
        if (!pq->txreq_cache) {
                dd_dev_err(dd, "[%u] Failed to allocate TxReq cache\n",
                           uctxt->ctxt);
index 5d23172c470fd27b5f3ae66c8bb1d02cca4054b1..873e48ea923fc42acc9cb2d5d3d7055dd07a1790 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2016 Intel Corporation.
+ * Copyright(c) 2016 - 2017 Intel Corporation.
  *
  * This file is provided under a dual BSD/GPLv2 license.  When using or
  * redistributing this file, you may do so under either license.
@@ -119,13 +119,6 @@ out:
        return tx;
 }
 
-static void verbs_txreq_kmem_cache_ctor(void *obj)
-{
-       struct verbs_txreq *tx = (struct verbs_txreq *)obj;
-
-       memset(tx, 0, sizeof(*tx));
-}
-
 int verbs_txreq_init(struct hfi1_ibdev *dev)
 {
        char buf[TXREQ_LEN];
@@ -135,7 +128,7 @@ int verbs_txreq_init(struct hfi1_ibdev *dev)
        dev->verbs_txreq_cache = kmem_cache_create(buf,
                                                   sizeof(struct verbs_txreq),
                                                   0, SLAB_HWCACHE_ALIGN,
-                                                  verbs_txreq_kmem_cache_ctor);
+                                                  NULL);
        if (!dev->verbs_txreq_cache)
                return -ENOMEM;
        return 0;
index 7815d7405462ceb4c0acc1de399879998477ab29..c3c96c5869ed454680b619caef88a3fd369d5579 100644 (file)
@@ -303,22 +303,15 @@ void hfi1_vnic_sdma_init(struct hfi1_vnic_vport_info *vinfo)
        }
 }
 
-static void hfi1_vnic_txreq_kmem_cache_ctor(void *obj)
-{
-       struct vnic_txreq *tx = (struct vnic_txreq *)obj;
-
-       memset(tx, 0, sizeof(*tx));
-}
-
 int hfi1_vnic_txreq_init(struct hfi1_devdata *dd)
 {
        char buf[HFI1_VNIC_TXREQ_NAME_LEN];
 
        snprintf(buf, sizeof(buf), "hfi1_%u_vnic_txreq_cache", dd->unit);
        dd->vnic.txreq_cache = kmem_cache_create(buf,
-                                         sizeof(struct vnic_txreq),
-                                         0, SLAB_HWCACHE_ALIGN,
-                                         hfi1_vnic_txreq_kmem_cache_ctor);
+                                                sizeof(struct vnic_txreq),
+                                                0, SLAB_HWCACHE_ALIGN,
+                                                NULL);
        if (!dd->vnic.txreq_cache)
                return -ENOMEM;
        return 0;