|
Nicolas Morey |
bc9efe |
From 9fe8fec5e43d5a80f43cbf61aaada1b047a1eb61 Mon Sep 17 00:00:00 2001
|
|
Nicolas Morey |
bc9efe |
From: Patrick Kelsey <pat.kelsey@cornelisnetworks.com>
|
|
Nicolas Morey |
bc9efe |
Date: Fri, 7 Apr 2023 12:52:39 -0400
|
|
Nicolas Morey |
bc9efe |
Subject: [PATCH 1/1] IB/hfi1: Fix SDMA mmu_rb_node not being evicted in LRU
|
|
Nicolas Morey |
bc9efe |
order
|
|
Nicolas Morey |
bc9efe |
Git-commit: 9fe8fec5e43d5a80f43cbf61aaada1b047a1eb61
|
|
Nicolas Morey |
bc9efe |
Patch-mainline: v6.4-rc1
|
|
Nicolas Morey |
bc9efe |
References: git-fixes
|
|
Nicolas Morey |
bc9efe |
|
|
Nicolas Morey |
bc9efe |
hfi1_mmu_rb_remove_unless_exact() did not move mmu_rb_node objects in
|
|
Nicolas Morey |
bc9efe |
mmu_rb_handler->lru_list after getting a cache hit on an mmu_rb_node.
|
|
Nicolas Morey |
bc9efe |
|
|
Nicolas Morey |
bc9efe |
As a result, hfi1_mmu_rb_evict() was not guaranteed to evict truly
|
|
Nicolas Morey |
bc9efe |
least-recently used nodes.
|
|
Nicolas Morey |
bc9efe |
|
|
Nicolas Morey |
bc9efe |
This could be a performance issue for an application when that
|
|
Nicolas Morey |
bc9efe |
application:
|
|
Nicolas Morey |
bc9efe |
- Uses some long-lived buffers frequently.
|
|
Nicolas Morey |
bc9efe |
- Uses a large number of buffers once.
|
|
Nicolas Morey |
bc9efe |
- Hits the mmu_rb_handler cache size or pinned-page limits, forcing
|
|
Nicolas Morey |
bc9efe |
mmu_rb_handler cache entries to be evicted.
|
|
Nicolas Morey |
bc9efe |
|
|
Nicolas Morey |
bc9efe |
In this case, the one-time use buffers cause the long-lived buffer
|
|
Nicolas Morey |
bc9efe |
entries to eventually filter to the end of the LRU list where
|
|
Nicolas Morey |
bc9efe |
hfi1_mmu_rb_evict() will consider evicting a frequently-used long-lived
|
|
Nicolas Morey |
bc9efe |
entry instead of evicting one of the one-time use entries.
|
|
Nicolas Morey |
bc9efe |
|
|
Nicolas Morey |
bc9efe |
Fix this by inserting new mmu_rb_node at the tail of
|
|
Nicolas Morey |
bc9efe |
mmu_rb_handler->lru_list and move mmu_rb_ndoe to the tail of
|
|
Nicolas Morey |
bc9efe |
mmu_rb_handler->lru_list when the mmu_rb_node is a hit in
|
|
Nicolas Morey |
bc9efe |
hfi1_mmu_rb_remove_unless_exact(). Change hfi1_mmu_rb_evict() to evict
|
|
Nicolas Morey |
bc9efe |
from the head of mmu_rb_handler->lru_list instead of the tail.
|
|
Nicolas Morey |
bc9efe |
|
|
Nicolas Morey |
bc9efe |
Fixes: 0636e9ab8355 ("IB/hfi1: Add cache evict LRU list")
|
|
Nicolas Morey |
bc9efe |
Signed-off-by: Brendan Cunningham <bcunningham@cornelisnetworks.com>
|
|
Nicolas Morey |
bc9efe |
Signed-off-by: Patrick Kelsey <pat.kelsey@cornelisnetworks.com>
|
|
Nicolas Morey |
bc9efe |
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
|
|
Nicolas Morey |
bc9efe |
Link: https://lore.kernel.org/r/168088635931.3027109.10423156330761536044.stgit@252.162.96.66.static.eigbox.net
|
|
Nicolas Morey |
bc9efe |
Signed-off-by: Leon Romanovsky <leon@kernel.org>
|
|
Nicolas Morey |
bc9efe |
Acked-by: Nicolas Morey <nmorey@suse.com>
|
|
Nicolas Morey |
bc9efe |
---
|
|
Nicolas Morey |
bc9efe |
drivers/infiniband/hw/hfi1/mmu_rb.c | 13 ++++++-------
|
|
Nicolas Morey |
bc9efe |
1 file changed, 6 insertions(+), 7 deletions(-)
|
|
Nicolas Morey |
bc9efe |
|
|
Nicolas Morey |
bc9efe |
diff --git a/drivers/infiniband/hw/hfi1/mmu_rb.c b/drivers/infiniband/hw/hfi1/mmu_rb.c
|
|
Nicolas Morey |
bc9efe |
index 7333646021bb..af46ff203342 100644
|
|
Nicolas Morey |
bc9efe |
--- a/drivers/infiniband/hw/hfi1/mmu_rb.c
|
|
Nicolas Morey |
bc9efe |
+++ b/drivers/infiniband/hw/hfi1/mmu_rb.c
|
|
Nicolas Morey |
bc9efe |
@@ -130,7 +130,7 @@ int hfi1_mmu_rb_insert(struct mmu_rb_handler *handler,
|
|
Nicolas Morey |
bc9efe |
goto unlock;
|
|
Nicolas Morey |
bc9efe |
}
|
|
Nicolas Morey |
bc9efe |
__mmu_int_rb_insert(mnode, &handler->root);
|
|
Nicolas Morey |
bc9efe |
- list_add(&mnode->list, &handler->lru_list);
|
|
Nicolas Morey |
bc9efe |
+ list_add_tail(&mnode->list, &handler->lru_list);
|
|
Nicolas Morey |
bc9efe |
|
|
Nicolas Morey |
bc9efe |
ret = handler->ops->insert(handler->ops_arg, mnode);
|
|
Nicolas Morey |
bc9efe |
if (ret) {
|
|
Nicolas Morey |
bc9efe |
@@ -181,8 +181,10 @@ bool hfi1_mmu_rb_remove_unless_exact(struct mmu_rb_handler *handler,
|
|
Nicolas Morey |
bc9efe |
spin_lock_irqsave(&handler->lock, flags);
|
|
Nicolas Morey |
bc9efe |
node = __mmu_rb_search(handler, addr, len);
|
|
Nicolas Morey |
bc9efe |
if (node) {
|
|
Nicolas Morey |
bc9efe |
- if (node->addr == addr && node->len == len)
|
|
Nicolas Morey |
bc9efe |
+ if (node->addr == addr && node->len == len) {
|
|
Nicolas Morey |
bc9efe |
+ list_move_tail(&node->list, &handler->lru_list);
|
|
Nicolas Morey |
bc9efe |
goto unlock;
|
|
Nicolas Morey |
bc9efe |
+ }
|
|
Nicolas Morey |
bc9efe |
__mmu_int_rb_remove(node, &handler->root);
|
|
Nicolas Morey |
bc9efe |
list_del(&node->list); /* remove from LRU list */
|
|
Nicolas Morey |
bc9efe |
ret = true;
|
|
Nicolas Morey |
bc9efe |
@@ -206,8 +208,7 @@ void hfi1_mmu_rb_evict(struct mmu_rb_handler *handler, void *evict_arg)
|
|
Nicolas Morey |
bc9efe |
INIT_LIST_HEAD(&del_list);
|
|
Nicolas Morey |
bc9efe |
|
|
Nicolas Morey |
bc9efe |
spin_lock_irqsave(&handler->lock, flags);
|
|
Nicolas Morey |
bc9efe |
- list_for_each_entry_safe_reverse(rbnode, ptr, &handler->lru_list,
|
|
Nicolas Morey |
bc9efe |
- list) {
|
|
Nicolas Morey |
bc9efe |
+ list_for_each_entry_safe(rbnode, ptr, &handler->lru_list, list) {
|
|
Nicolas Morey |
bc9efe |
if (handler->ops->evict(handler->ops_arg, rbnode, evict_arg,
|
|
Nicolas Morey |
bc9efe |
&stop)) {
|
|
Nicolas Morey |
bc9efe |
__mmu_int_rb_remove(rbnode, &handler->root);
|
|
Nicolas Morey |
bc9efe |
@@ -219,9 +220,7 @@ void hfi1_mmu_rb_evict(struct mmu_rb_handler *handler, void *evict_arg)
|
|
Nicolas Morey |
bc9efe |
}
|
|
Nicolas Morey |
bc9efe |
spin_unlock_irqrestore(&handler->lock, flags);
|
|
Nicolas Morey |
bc9efe |
|
|
Nicolas Morey |
bc9efe |
- while (!list_empty(&del_list)) {
|
|
Nicolas Morey |
bc9efe |
- rbnode = list_first_entry(&del_list, struct mmu_rb_node, list);
|
|
Nicolas Morey |
bc9efe |
- list_del(&rbnode->list);
|
|
Nicolas Morey |
bc9efe |
+ list_for_each_entry_safe(rbnode, ptr, &del_list, list) {
|
|
Nicolas Morey |
bc9efe |
handler->ops->remove(handler->ops_arg, rbnode);
|
|
Nicolas Morey |
bc9efe |
}
|
|
Nicolas Morey |
bc9efe |
}
|
|
Nicolas Morey |
bc9efe |
--
|
|
Nicolas Morey |
bc9efe |
2.39.1.1.gbe015eda0162
|
|
Nicolas Morey |
bc9efe |
|