From: Sergey Cheremencev Date: Thu, 25 Jul 2024 22:22:44 +0000 (+0300) Subject: LU-18086 obdclass: change POOLS_COUNT X-Git-Tag: 2.15.91~56 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=e4b0c89ccb881e426ebee07a4cc1e73d187051d4;p=fs%2Flustre-release.git LU-18086 obdclass: change POOLS_COUNT POOLS_COUNT must guarantee that page_pools largest pool size is 2 * MAX_BRW_SIZE. Take into account that pool_order is a power of 2 number of pages. Previous logic assumed that pool_order is a power of 2 bytes. That said, there were 27 pools to provide 64MB*2 pool(the largest pool). As maximum pool pages is cfs_totalram_pages / POOLS_COUNT, it made pools too small. For example, for system with 3G RAM pool with order 0(1 page) maximum pool size would be about 100MB. It might cause -ENOMEM despite the fact there is enough memory in a system. Also added, that every pool must have at least one object. Signed-off-by: Sergey Cheremencev Signed-off-by: Artem Blagodarenko Change-Id: I872f4bdda392d7675b26b2f59ac2520208a96fa0 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55915 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/page_pools.c b/lustre/obdclass/page_pools.c index 7b56427..0f86607 100644 --- a/lustre/obdclass/page_pools.c +++ b/lustre/obdclass/page_pools.c @@ -45,10 +45,14 @@ #include #include -/* we have a pool for every power of 2 number of pages <= MAX_BRW_BITS. - * most pools will be unused, but that's OK - unused pools are very cheap +/* We have a pool for every power of 2 number of pages. Each pool must + * be able to provide at least one object of PTLRPC_MAX_BRW_SIZE * 2. + * Multiplying MAX_BRW_SIZE by 2 is a hack required to successfully + * compress and uncompress chunks in decompress/compress_request(ask + * Artem(ablagodarenko@ddn.com) for details why it failed). Most pools + * will be unused, but that's OK - unused pools are very cheap. */ -#define POOLS_COUNT (PTLRPC_MAX_BRW_BITS + 1) +#define POOLS_COUNT (PTLRPC_MAX_BRW_BITS - PAGE_SHIFT + 1) #define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT)) #define MiB_TO_PAGES(mb) ((mb) << (20 - PAGE_SHIFT)) /* deprecated - see pool_max_memory_mb below */ @@ -329,6 +333,10 @@ static unsigned long pool_shrink_count(struct shrinker *s, pool = page_pools[pool_order]; max_objects = PTLRPC_MAX_BRW_PAGES >> pool_order; + /* Always have at least one element */ + if (max_objects == 0) + max_objects = 1; + /* * if no pool access for a long time, we consider it's fully * idle. A little race here is fine. @@ -360,6 +368,9 @@ static unsigned long pool_shrink_scan(struct shrinker *s, pool_order = get_pool_index(s); pool = page_pools[pool_order]; max_objects = PTLRPC_MAX_BRW_PAGES >> pool_order; + /* Always have at least one element */ + if (max_objects == 0) + max_objects = 1; spin_lock(&pool->opp_lock); if (pool->opp_free_pages <= max_objects)