IB/hfi1: Place struct mmu_rb_handler on cache line start
authorPatrick Kelsey <pat.kelsey@cornelisnetworks.com>
Fri, 7 Apr 2023 16:52:49 +0000 (12:52 -0400)
committerLeon Romanovsky <leon@kernel.org>
Sun, 9 Apr 2023 10:27:34 +0000 (13:27 +0300)
commit866694afd644cd5ee32411713c3d802fcca22ebb
treef7b2f29645181be847f80c6f021d105558e9b752
parent00cbce5cbf88459cd1aa1d60d0f1df15477df127
IB/hfi1: Place struct mmu_rb_handler on cache line start

Place struct mmu_rb_handler on cache line start like so:

struct mmu_rb_handler *h;
void *free_ptr;
int ret;

free_ptr = kzalloc(sizeof(*h) + cache_line_size() - 1, GFP_KERNEL);
if (!free_ptr)
return -ENOMEM;

h = PTR_ALIGN(free_ptr, cache_line_size());

Additionally, move struct mmu_rb_handler fields "root" and "ops_args" to
start after the next cacheline using the "____cacheline_aligned_in_smp"
annotation.

Allocating an additional cache_line_size() - 1 bytes to place
struct mmu_rb_handler on a cache line start does increase memory
consumption.

However, few struct mmu_rb_handler are created when hfi1 is in use.
As mmu_rb_handler->root and mmu_rb_handler->ops_args are accessed
frequently, the advantage of having them both within a cache line is
expected to outweigh the disadvantage of the additional memory
consumption per struct mmu_rb_handler.

Signed-off-by: Brendan Cunningham <bcunningham@cornelisnetworks.com>
Signed-off-by: Patrick Kelsey <pat.kelsey@cornelisnetworks.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Link: https://lore.kernel.org/r/168088636963.3027109.16959757980497822530.stgit@252.162.96.66.static.eigbox.net
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/hfi1/mmu_rb.c
drivers/infiniband/hw/hfi1/mmu_rb.h