Whamcloud - gitweb
LU-18086 obdclass: change POOLS_COUNT 15/55915/8
authorSergey Cheremencev <scherementsev@ddn.com>
Thu, 25 Jul 2024 22:22:44 +0000 (01:22 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 30 Aug 2024 06:00:25 +0000 (06:00 +0000)
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 <scherementsev@ddn.com>
Signed-off-by: Artem Blagodarenko <ablagodarenko@ddn.com>
Change-Id: I872f4bdda392d7675b26b2f59ac2520208a96fa0
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55915
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/page_pools.c

index 7b56427..0f86607 100644 (file)
 #include <lustre_dlm.h>
 #include <lustre_sec.h>
 
-/* 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)