diff options
author | Sebastian Sanchez <sebastian.sanchez@intel.com> | 2016-10-25 13:12:28 -0700 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-11-15 16:37:27 -0500 |
commit | 2474d775d9e2f935ff6840c8b21b4262afacc821 (patch) | |
tree | 488fd7bff5f3edf1eafec2434ff6b3564cb1202c /drivers/infiniband/hw/hfi1/pio.c | |
parent | fe4d924396a861937256293ff4a84b76b84854d8 (diff) | |
download | blackbird-obmc-linux-2474d775d9e2f935ff6840c8b21b4262afacc821.tar.gz blackbird-obmc-linux-2474d775d9e2f935ff6840c8b21b4262afacc821.zip |
IB/hfi1: Get rid of divide in pio buffer allocator
The div instruction shows costly in profiles.
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Sebastian Sanchez <sebastian.sanchez@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/hw/hfi1/pio.c')
-rw-r--r-- | drivers/infiniband/hw/hfi1/pio.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c index 385e4dcf2cd3..516fac38d31e 100644 --- a/drivers/infiniband/hw/hfi1/pio.c +++ b/drivers/infiniband/hw/hfi1/pio.c @@ -1249,6 +1249,7 @@ int sc_enable(struct send_context *sc) sc->free = 0; sc->alloc_free = 0; sc->fill = 0; + sc->fill_wrap = 0; sc->sr_head = 0; sc->sr_tail = 0; sc->flags = 0; @@ -1392,7 +1393,7 @@ struct pio_buf *sc_buffer_alloc(struct send_context *sc, u32 dw_len, unsigned long flags; unsigned long avail; unsigned long blocks = dwords_to_blocks(dw_len); - unsigned long start_fill; + u32 fill_wrap; int trycount = 0; u32 head, next; @@ -1435,8 +1436,11 @@ retry: head = sc->sr_head; /* "allocate" the buffer */ - start_fill = sc->fill; sc->fill += blocks; + fill_wrap = sc->fill_wrap; + sc->fill_wrap += blocks; + if (sc->fill_wrap >= sc->credits) + sc->fill_wrap = sc->fill_wrap - sc->credits; /* * Fill the parts that the releaser looks at before moving the head. @@ -1465,8 +1469,7 @@ retry: spin_unlock_irqrestore(&sc->alloc_lock, flags); /* finish filling in the buffer outside the lock */ - pbuf->start = sc->base_addr + ((start_fill % sc->credits) - * PIO_BLOCK_SIZE); + pbuf->start = sc->base_addr + fill_wrap * PIO_BLOCK_SIZE; pbuf->size = sc->credits * PIO_BLOCK_SIZE; pbuf->end = sc->base_addr + pbuf->size; pbuf->block_count = blocks; |