Whamcloud - gitweb
LU-18086 obdclass: page_pools shrinker fix 14/55914/7
authorSergey Cheremencev <scherementsev@ddn.com>
Tue, 9 Jul 2024 02:43:29 +0000 (05:43 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 30 Aug 2024 06:00:16 +0000 (06:00 +0000)
commit14fc034e983e36f09d1308262c0d53872d5cfba0
treedc53fd20e48c5fdb3fe95f3171afb43fba34a467
parent75f55f99a328923ec9fb5bb4ca3418aa11bbe336
LU-18086 obdclass: page_pools shrinker fix

page_pool shrinker should consider opp_free_pages
as a number of memory regions with the size of
2^pool_order pages. Otherwise it starts shrinking
only when becomes too large, for example 2GB instead
of 64MB. It often might be the reason of OOM especially
when compressed files with different chunk-sizes
have been written. In a such case several pools
created for different chunk sizes might hold gigabytes
of memory without any chance to release it.

Fix element_size to return correct element size instead
of number of pages. Because of that elements in
page_pools had below sizes:

  order 0 = 4096
  order 1 = 2
  order 2 = 4
  ....
  order 17 = 131072

This made possible to have elements with sizes 2,4,8,...
bytes that have been allocated with OBD_VMALLOC.
Now all sizes are miltiple of PAGE_SIZE:

  order 0 = 4096
  order 1 = 8192
  ...
  order 5 = 131072

Change the logic around opp_idle_idx.

1. Recalculate opp_idle_idx in __sptlrpc_pool_put_pages the
   same way as it done in __sptlrpc_pool_get_pages. It is
   possible that opp_idle_idx might become 0 or very small
   (less than 10). If there is no new allocations it would
   be impossible to free anything from the pool during 40
   seconds(CACHE_QUIESCENT_PERIOD) despite the large amount
   of free elements ready to shrinking.
2. In pool_shrink_count when opp_idle_idx == IDLE_IDX_MAX,
   it means no one accessed pool for CACHE_QUIESCENT_PERIOD
   (40 seconds), i.e. we may release as much as possible
   pages. Earlier in a such case pool_shrink_count always
   returned 0. Another words it was impossible to shrink
   anything from the pool if there was no allocations for 40s.

Signed-off-by: Sergey Cheremencev <scherementsev@ddn.com>
Signed-off-by: Artem Blagodarenko <ablagodarenko@ddn.com>
Change-Id: I6b55ba67b0d21cdffdb57034e8e66063745f796e
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55914
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