From 25c1a77f45cf8839a3ed0fb1299bba7c2e67a73c Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Wed, 20 Sep 2023 13:52:16 -0400 Subject: [PATCH] EX-8270 ptlrpc: simplify pools_should_grow This patch is a prelude to replacing "pools_should_grow()" with a "grow_pool" function. (The odd plural will be removed shortly.) Test-Parameters: trivial Signed-off-by: Patrick Farrell Change-Id: I0accbce2c36fa97684fbee364057b8ff2f9ae12d Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52434 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/ptlrpc/sec_bulk.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/lustre/ptlrpc/sec_bulk.c b/lustre/ptlrpc/sec_bulk.c index 0170cc5..b017125 100644 --- a/lustre/ptlrpc/sec_bulk.c +++ b/lustre/ptlrpc/sec_bulk.c @@ -595,8 +595,7 @@ static inline void pools_wakeup(unsigned int pool) wake_up_all(&page_pools[pool]->ppp_waitq); } -static int pools_should_grow(int page_needed, time64_t now, - unsigned int pool_index) +static int pools_should_grow(int needed, unsigned int pool_index) { /* * don't grow if someone else is growing the pools right now, @@ -608,7 +607,7 @@ static int pools_should_grow(int page_needed, time64_t now, return 0; /* if total pages is not enough, we need to grow */ - if (page_pools[pool_index]->ppp_total_pages < page_needed) + if (page_pools[pool_index]->ppp_total_pages < needed) return 1; /* @@ -683,7 +682,6 @@ static inline int __sptlrpc_pool_get_pages(void *array, unsigned int count, wait_queue_entry_t waitlink; unsigned long this_idle = -1; u64 tick_ns = 0; - time64_t now; int p_idx, g_idx; int i, rc = 0; @@ -698,12 +696,10 @@ again: if (tick_ns == 0) tick_ns = ktime_get_ns(); - now = ktime_get_real_seconds(); - page_pool->ppp_st_missings++; page_pool->ppp_pages_short += count; - if (pools_should_grow(count, now, pool_idx)) { + if (pools_should_grow(count, pool_idx)) { page_pool->ppp_growing = 1; spin_unlock(&page_pool->ppp_lock); @@ -946,25 +942,22 @@ EXPORT_SYMBOL(sptlrpc_pool_put_pages); */ int sptlrpc_pool_add_user(void) { - int need_grow = 0; spin_lock(&page_pools[PAGES_POOL]->ppp_lock); - if (page_pools[PAGES_POOL]->ppp_growing == 0 && - page_pools[PAGES_POOL]->ppp_total_pages == 0) { + /* ask for 1 page - so if the pool is empty, it will grow + * (this might also grow an in-use pool if it's full, which is fine) + */ + if (pools_should_grow(1, PAGES_POOL)) { page_pools[PAGES_POOL]->ppp_growing = 1; - need_grow = 1; - } - spin_unlock(&page_pools[PAGES_POOL]->ppp_lock); - + spin_unlock(&page_pools[PAGES_POOL]->ppp_lock); - if (need_grow) { pool_add_pages(PTLRPC_MAX_BRW_PAGES * 2, PAGES_POOL); spin_lock(&page_pools[PAGES_POOL]->ppp_lock); page_pools[PAGES_POOL]->ppp_growing = 0; pools_wakeup(PAGES_POOL); - spin_unlock(&page_pools[PAGES_POOL]->ppp_lock); } + spin_unlock(&page_pools[PAGES_POOL]->ppp_lock); return 0; } EXPORT_SYMBOL(sptlrpc_pool_add_user); -- 1.8.3.1