Whamcloud - gitweb
EX-8270 ptlrpc: remove PAGES_PER_POOL macro
authorPatrick Farrell <pfarrell@whamcloud.com>
Thu, 21 Sep 2023 15:47:59 +0000 (11:47 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 22 Sep 2023 23:56:15 +0000 (23:56 +0000)
The page pool code *also* likes to refer to each page of
pointers it uses to track items in it as a "POOL", which is
incredibly confusing.

Start unwinding this by removing the PAGES_PER_POOL macro.

Test-Parameters: trivial
Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Ie29434f53eeb945b8d35df7c1212ae3f51a2aafa
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52457
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/ptlrpc/sec_bulk.c

index 619b5f6..5286193 100644 (file)
@@ -70,7 +70,6 @@ MODULE_PARM_DESC(pool_max_memory_mb,
  */
 
 #define PTRS_PER_PAGE   (PAGE_SIZE / sizeof(void *))
-#define PAGES_PER_POOL  (PTRS_PER_PAGE)
 
 #define IDLE_IDX_MAX            (100)
 #define IDLE_IDX_WEIGHT         (3)
@@ -148,7 +147,8 @@ int encrypt_page_pools_seq_show(struct seq_file *m, void *v)
        struct ptlrpc_page_pool *pool = page_pools[0];
 
        spin_lock(&pool->ppp_lock);
-       seq_printf(m, "physical pages:          %lu\n"
+       seq_printf(m,
+               "physical pages:          %lu\n"
                "pages per pool:          %lu\n"
                "max pages:               %lu\n"
                "max pools:               %u\n"
@@ -167,7 +167,7 @@ int encrypt_page_pools_seq_show(struct seq_file *m, void *v)
                "max waitqueue depth:     %u\n"
                "max wait time ms:        %lld\n"
                "out of mem:              %lu\n",
-               cfs_totalram_pages(), PAGES_PER_POOL,
+               cfs_totalram_pages(), PTRS_PER_PAGE,
                pool->ppp_max_pages,
                pool->ppp_max_pools,
                pool->ppp_total_pages,
@@ -200,9 +200,8 @@ int page_pools_seq_show(struct seq_file *m, void *v)
        struct ptlrpc_page_pool *pool;
 
        seq_printf(m, "physical_pages: %lu\n"
-                     "pages per pool: %lu\n\n"
                      "pools:\n",
-                     cfs_totalram_pages(), PAGES_PER_POOL);
+                     cfs_totalram_pages());
 
        for (pool_order = 0; pool_order < POOLS_COUNT; pool_order++) {
                pool = page_pools[pool_order];
@@ -262,17 +261,17 @@ static void pool_release_free_pages(long npages, struct ptlrpc_page_pool *pool)
        LASSERT(pool->ppp_free_pages <= pool->ppp_total_pages);
 
        /* max pool index before the release */
-       p_idx_max2 = (pool->ppp_total_pages - 1) / PAGES_PER_POOL;
+       p_idx_max2 = (pool->ppp_total_pages - 1) / PTRS_PER_PAGE;
 
        pool->ppp_free_pages -= npages;
        pool->ppp_total_pages -= npages;
 
        /* max pool index after the release */
        p_idx_max1 = pool->ppp_total_pages == 0 ? -1 :
-               ((pool->ppp_total_pages - 1) / PAGES_PER_POOL);
+               ((pool->ppp_total_pages - 1) / PTRS_PER_PAGE);
 
-       p_idx = pool->ppp_free_pages / PAGES_PER_POOL;
-       g_idx = pool->ppp_free_pages % PAGES_PER_POOL;
+       p_idx = pool->ppp_free_pages / PTRS_PER_PAGE;
+       g_idx = pool->ppp_free_pages % PTRS_PER_PAGE;
        LASSERT(pool->ppp_pools[p_idx]);
 
        while (npages--) {
@@ -287,7 +286,7 @@ static void pool_release_free_pages(long npages, struct ptlrpc_page_pool *pool)
 
                pool->ppp_pools[p_idx][g_idx] = NULL;
 
-               if (++g_idx == PAGES_PER_POOL) {
+               if (++g_idx == PTRS_PER_PAGE) {
                        p_idx++;
                        g_idx = 0;
                }
@@ -388,7 +387,7 @@ static int pool_shrink(struct shrinker *shrinker, struct shrink_control *sc)
 static inline
 int npages_to_npools(unsigned long npages)
 {
-       return (int) ((npages + PAGES_PER_POOL - 1) / PAGES_PER_POOL);
+       return (int) ((npages + PTRS_PER_PAGE - 1) / PTRS_PER_PAGE);
 }
 
 /*
@@ -402,7 +401,7 @@ static unsigned long pool_cleanup(void ***pools, int npools,
 
        for (i = 0; i < npools; i++) {
                if (pools[i]) {
-                       for (j = 0; j < PAGES_PER_POOL; j++) {
+                       for (j = 0; j < PTRS_PER_PAGE; j++) {
                                if (pools[i][j]) {
                                        if (pool->ppp_order == 0) {
                                                __free_page(pools[i][j]);
@@ -449,15 +448,15 @@ static void pool_insert(void ***pools, int npools, int npages,
         * free slots are those left by rent pages, and the extra ones with
         * index >= total_pages, locate at the tail of last pool.
         */
-       freeslot = page_pool->ppp_total_pages % PAGES_PER_POOL;
+       freeslot = page_pool->ppp_total_pages % PTRS_PER_PAGE;
        if (freeslot != 0)
-               freeslot = PAGES_PER_POOL - freeslot;
+               freeslot = PTRS_PER_PAGE - freeslot;
        freeslot += page_pool->ppp_total_pages - page_pool->ppp_free_pages;
 
-       op_idx = page_pool->ppp_free_pages / PAGES_PER_POOL;
-       og_idx = page_pool->ppp_free_pages % PAGES_PER_POOL;
+       op_idx = page_pool->ppp_free_pages / PTRS_PER_PAGE;
+       og_idx = page_pool->ppp_free_pages % PTRS_PER_PAGE;
        np_idx = npools - 1;
-       ng_idx = (npages - 1) % PAGES_PER_POOL;
+       ng_idx = (npages - 1) % PTRS_PER_PAGE;
 
        while (freeslot) {
                LASSERT(page_pool->ppp_pools[op_idx][og_idx] == NULL);
@@ -468,7 +467,7 @@ static void pool_insert(void ***pools, int npools, int npages,
 
                freeslot--;
 
-               if (++og_idx == PAGES_PER_POOL) {
+               if (++og_idx == PTRS_PER_PAGE) {
                        op_idx++;
                        og_idx = 0;
                }
@@ -476,17 +475,17 @@ static void pool_insert(void ***pools, int npools, int npages,
                        if (np_idx == 0)
                                break;
                        np_idx--;
-                       ng_idx = PAGES_PER_POOL - 1;
+                       ng_idx = PTRS_PER_PAGE - 1;
                }
        }
 
        /*
         * (2) add pools if needed.
         */
-       cur_npools = (page_pool->ppp_total_pages + PAGES_PER_POOL - 1) /
-                     PAGES_PER_POOL;
+       cur_npools = (page_pool->ppp_total_pages + PTRS_PER_PAGE - 1) /
+                     PTRS_PER_PAGE;
        end_npools = (page_pool->ppp_total_pages + npages +
-                     PAGES_PER_POOL - 1) / PAGES_PER_POOL;
+                     PTRS_PER_PAGE - 1) / PTRS_PER_PAGE;
        LASSERT(end_npools <= page_pool->ppp_max_pools);
 
        np_idx = 0;
@@ -552,7 +551,7 @@ static int pool_add_pages(int npages, struct ptlrpc_page_pool *page_pool)
                if (pools[i] == NULL)
                        goto out_pools;
 
-               for (j = 0; j < PAGES_PER_POOL && alloced < npages; j++) {
+               for (j = 0; j < PTRS_PER_PAGE && alloced < npages; j++) {
                        if (pool_order == 0)
                                pools[i][j] = alloc_page(GFP_NOFS |
                                        __GFP_HIGHMEM);
@@ -751,8 +750,8 @@ again:
        /* proceed with rest of allocation */
        page_pool->ppp_free_pages -= count;
 
-       p_idx = page_pool->ppp_free_pages / PAGES_PER_POOL;
-       g_idx = page_pool->ppp_free_pages % PAGES_PER_POOL;
+       p_idx = page_pool->ppp_free_pages / PTRS_PER_PAGE;
+       g_idx = page_pool->ppp_free_pages % PTRS_PER_PAGE;
 
        for (i = 0; i < count; i++) {
                void **pagep = page_from(array, i);
@@ -762,7 +761,7 @@ again:
                *pagep = page_pool->ppp_pools[p_idx][g_idx];
                page_pool->ppp_pools[p_idx][g_idx] = NULL;
 
-               if (++g_idx == PAGES_PER_POOL) {
+               if (++g_idx == PTRS_PER_PAGE) {
                        p_idx++;
                        g_idx = 0;
                }
@@ -853,8 +852,8 @@ static int __sptlrpc_pool_put_pages(void *array, unsigned int count,
 
        spin_lock(&page_pool->ppp_lock);
 
-       p_idx = page_pool->ppp_free_pages / PAGES_PER_POOL;
-       g_idx = page_pool->ppp_free_pages % PAGES_PER_POOL;
+       p_idx = page_pool->ppp_free_pages / PTRS_PER_PAGE;
+       g_idx = page_pool->ppp_free_pages % PTRS_PER_PAGE;
 
        if (page_pool->ppp_free_pages + count > page_pool->ppp_total_pages)
                GOTO(out_unlock, rc = -EPROTO);
@@ -869,7 +868,7 @@ static int __sptlrpc_pool_put_pages(void *array, unsigned int count,
                        GOTO(out_unlock, rc = -EPROTO);
 
                page_pool->ppp_pools[p_idx][g_idx] = *pagep;
-               if (++g_idx == PAGES_PER_POOL) {
+               if (++g_idx == PTRS_PER_PAGE) {
                        p_idx++;
                        g_idx = 0;
                }