Whamcloud - gitweb
EX-8270 ptlrpc: rename 'pools' to 'ptr_pages'
authorPatrick Farrell <pfarrell@whamcloud.com>
Thu, 21 Sep 2023 16:25:51 +0000 (12:25 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 22 Sep 2023 23:56:47 +0000 (23:56 +0000)
This finalizes the removal of the overloading of 'pools'
to also mean pointers of pages to items in each page pool.

This patch is currently the last in the series so it gets
full testing.  (This may change, but it's true now.)

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: I0f4aba95f573f4afdc6f5d92f22fd67391fa6dab
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52461
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 d6e6df0..a413cab 100644 (file)
@@ -78,7 +78,7 @@ MODULE_PARM_DESC(pool_max_memory_mb,
 
 static struct ptlrpc_page_pool {
        unsigned long ppp_max_pages;   /* maximum pages can hold, const */
-       unsigned int ppp_max_ptr_pages;   /* number of pools, const */
+       unsigned int ppp_max_ptr_pages;   /* number of ptr_pages, const */
 
        /*
         * wait queue in case of not enough free pages.
@@ -92,11 +92,11 @@ static struct ptlrpc_page_pool {
                                       */
 
        /*
-        * indicating how idle the pools are, from 0 to MAX_IDLE_IDX
+        * indicating how idle the pool is, from 0 to MAX_IDLE_IDX
         * this is counted based on each time when getting pages from
-        * the pools, not based on time. which means in case that system
+        * the pool, not based on time. which means in case that system
         * is idled for a while but the idle_idx might still be low if no
-        * activities happened in the pools.
+        * activities happened in the pool.
         */
        unsigned long ppp_idle_idx;
 
@@ -106,7 +106,7 @@ static struct ptlrpc_page_pool {
 
        /* in-pool pages bookkeeping */
        spinlock_t ppp_lock; /* protect following fields */
-       unsigned long ppp_total_pages; /* total pages in pools */
+       unsigned long ppp_total_pages; /* total pages in pool */
        unsigned long ppp_free_pages;  /* current pages available */
 
        /* statistics */
@@ -292,7 +292,7 @@ static void pool_release_free_pages(long npages, struct ptlrpc_page_pool *pool)
                }
        }
 
-       /* free unused pools */
+       /* free unused ptr_pages */
        while (p_idx_max1 < p_idx_max2) {
                LASSERT(pool->ppp_ptr_pages[p_idx_max2]);
                OBD_FREE(pool->ppp_ptr_pages[p_idx_max2], PAGE_SIZE);
@@ -393,27 +393,27 @@ int npages_to_nptr_pages(unsigned long npages)
 /*
  * return how many pages cleaned up.
  */
-static unsigned long pool_cleanup(void ***pools, int nptr_pages,
+static unsigned long pool_cleanup(void ***ptr_pages, int nptr_pages,
                                  struct ptlrpc_page_pool *pool)
 {
        unsigned long cleaned = 0;
        int i, j;
 
        for (i = 0; i < nptr_pages; i++) {
-               if (pools[i]) {
+               if (ptr_pages[i]) {
                        for (j = 0; j < PTRS_PER_PAGE; j++) {
-                               if (pools[i][j]) {
+                               if (ptr_pages[i][j]) {
                                        if (pool->ppp_order == 0) {
-                                               __free_page(pools[i][j]);
+                                               __free_page(ptr_pages[i][j]);
                                        } else {
-                                               OBD_FREE_LARGE(pools[i][j],
+                                               OBD_FREE_LARGE(ptr_pages[i][j],
                                                        element_size(pool));
                                        }
                                        cleaned++;
                                }
                        }
-                       OBD_FREE(pools[i], PAGE_SIZE);
-                       pools[i] = NULL;
+                       OBD_FREE(ptr_pages[i], PAGE_SIZE);
+                       ptr_pages[i] = NULL;
                }
        }
 
@@ -421,14 +421,14 @@ static unsigned long pool_cleanup(void ***pools, int nptr_pages,
 }
 
 /*
- * merge @nptr_pages pointed by @pools which contains @npages new pages
+ * merge @nptr_pages pointed by @ptr_pages which contains @npages new pages
  * into current pool.
  *
  * we have options to avoid most memory copy with some tricks. but we choose
  * the simplest way to avoid complexity. It's not frequently called.
  */
-static void pool_insert(void ***pools, int nptr_pages, int npages,
-                       struct ptlrpc_page_pool *page_pool)
+static void pool_insert_ptrs(void ***ptr_pages, int nptr_pages, int npages,
+                            struct ptlrpc_page_pool *page_pool)
 {
        int freeslot;
        int op_idx, np_idx, og_idx, ng_idx;
@@ -442,7 +442,7 @@ static void pool_insert(void ***pools, int nptr_pages, int npages,
        spin_lock(&page_pool->ppp_lock);
 
        /*
-        * (1) fill all the free slots of current pools.
+        * (1) fill all the free slots in current pool ptr_pages
         */
        /*
         * free slots are those left by rent pages, and the extra ones with
@@ -460,10 +460,11 @@ static void pool_insert(void ***pools, int nptr_pages, int npages,
 
        while (freeslot) {
                LASSERT(page_pool->ppp_ptr_pages[op_idx][og_idx] == NULL);
-               LASSERT(pools[np_idx][ng_idx] != NULL);
+               LASSERT(ptr_pages[np_idx][ng_idx] != NULL);
 
-               page_pool->ppp_ptr_pages[op_idx][og_idx] = pools[np_idx][ng_idx];
-               pools[np_idx][ng_idx] = NULL;
+               page_pool->ppp_ptr_pages[op_idx][og_idx] =
+                       ptr_pages[np_idx][ng_idx];
+               ptr_pages[np_idx][ng_idx] = NULL;
 
                freeslot--;
 
@@ -480,7 +481,7 @@ static void pool_insert(void ***pools, int nptr_pages, int npages,
        }
 
        /*
-        * (2) add pools if needed.
+        * (2) add ptr pages if needed.
         */
        cur_nptr_page = (page_pool->ppp_total_pages + PTRS_PER_PAGE - 1) /
                      PTRS_PER_PAGE;
@@ -492,21 +493,21 @@ static void pool_insert(void ***pools, int nptr_pages, int npages,
        while (cur_nptr_page < end_nptr_page) {
                LASSERT(page_pool->ppp_ptr_pages[cur_nptr_page] == NULL);
                LASSERT(np_idx < nptr_pages);
-               LASSERT(pools[np_idx] != NULL);
+               LASSERT(ptr_pages[np_idx] != NULL);
 
-               page_pool->ppp_ptr_pages[cur_nptr_page++] = pools[np_idx];
-               pools[np_idx++] = NULL;
+               page_pool->ppp_ptr_pages[cur_nptr_page++] = ptr_pages[np_idx];
+               ptr_pages[np_idx++] = NULL;
        }
 
        /*
-        * (3) free useless source pools
+        * (3) free useless source ptr pages
         */
        while (np_idx < nptr_pages) {
-               LASSERT(pools[np_idx] != NULL);
-               CDEBUG(D_SEC, "Free useless pool buffer: %i, %p\n", np_idx,
-                      pools[np_idx]);
-               OBD_FREE(pools[np_idx], PAGE_SIZE);
-               pools[np_idx++] = NULL;
+               LASSERT(ptr_pages[np_idx] != NULL);
+               CDEBUG(D_SEC, "Free useless ptr pages: %i, %p\n", np_idx,
+                      ptr_pages[np_idx]);
+               OBD_FREE(ptr_pages[np_idx], PAGE_SIZE);
+               ptr_pages[np_idx++] = NULL;
        }
 
        page_pool->ppp_total_pages += npages;
@@ -525,7 +526,7 @@ static void pool_insert(void ***pools, int nptr_pages, int npages,
 #define POOL_INIT_SIZE (PTLRPC_MAX_BRW_SIZE / 4)
 static int pool_add_pages(int npages, struct ptlrpc_page_pool *page_pool)
 {
-       void ***pools;
+       void ***ptr_pages;
        int nptr_pages, alloced = 0;
        int i, j, rc = -ENOMEM;
        unsigned int pool_order = page_pool->ppp_order;
@@ -542,39 +543,39 @@ static int pool_add_pages(int npages, struct ptlrpc_page_pool *page_pool)
        page_pool->ppp_st_grows++;
 
        nptr_pages = npages_to_nptr_pages(npages);
-       OBD_ALLOC_PTR_ARRAY(pools, nptr_pages);
-       if (pools == NULL)
+       OBD_ALLOC_PTR_ARRAY(ptr_pages, nptr_pages);
+       if (ptr_pages == NULL)
                goto out;
 
        for (i = 0; i < nptr_pages; i++) {
-               OBD_ALLOC(pools[i], PAGE_SIZE);
-               if (pools[i] == NULL)
-                       goto out_pools;
+               OBD_ALLOC(ptr_pages[i], PAGE_SIZE);
+               if (ptr_pages[i] == NULL)
+                       goto out_ptr_pages;
 
                for (j = 0; j < PTRS_PER_PAGE && alloced < npages; j++) {
                        if (pool_order == 0)
-                               pools[i][j] = alloc_page(GFP_NOFS |
+                               ptr_pages[i][j] = alloc_page(GFP_NOFS |
                                        __GFP_HIGHMEM);
                        else {
-                               OBD_ALLOC_LARGE(pools[i][j],
+                               OBD_ALLOC_LARGE(ptr_pages[i][j],
                                        element_size(page_pool));
                        }
-                       if (pools[i][j] == NULL)
-                               goto out_pools;
+                       if (ptr_pages[i][j] == NULL)
+                               goto out_ptr_pages;
 
                        alloced++;
                }
        }
        LASSERT(alloced == npages);
 
-       pool_insert(pools, nptr_pages, npages, page_pool);
-       CDEBUG(D_SEC, "added %d pages into pools\n", npages);
-       OBD_FREE_PTR_ARRAY(pools, nptr_pages);
+       pool_insert_ptrs(ptr_pages, nptr_pages, npages, page_pool);
+       CDEBUG(D_SEC, "added %d pages into pool\n", npages);
+       OBD_FREE_PTR_ARRAY(ptr_pages, nptr_pages);
        rc = 0;
 
-out_pools:
+out_ptr_pages:
        if (rc) {
-               pool_cleanup(pools, nptr_pages, page_pool);
+               pool_cleanup(ptr_pages, nptr_pages, page_pool);
        }
 out:
        if (rc) {
@@ -598,8 +599,8 @@ static inline void pool_wakeup(struct ptlrpc_page_pool *pool)
 static int pool_should_grow(int needed, struct ptlrpc_page_pool *pool)
 {
        /*
-        * don't grow if someone else is growing the pools right now,
-        * or the pools has reached its full capacity
+        * don't grow if someone else is growing the pool right now,
+        * or the pool has reached its full capacity
         */
        if (pool->ppp_growing || pool->ppp_total_pages == pool->ppp_max_pages)
                return 0;
@@ -619,7 +620,7 @@ static int pool_should_grow(int needed, struct ptlrpc_page_pool *pool)
         * length, idle index, etc. ?
         */
 
-       /* grow the pools in any other cases */
+       /* grow the pool in any other cases */
        return 1;
 }
 
@@ -973,8 +974,8 @@ static bool grow_pool_try(int needed, struct ptlrpc_page_pool *pool)
 
 /*
  * we don't do much stuff for add_user/del_user anymore, except adding some
- * initial pages in add_user() if current pools are empty, rest would be
- * handled by the pools's self-adaption.
+ * initial pages in add_user() if current pool is empty, rest would be
+ * handled by the pool self-adaption.
  */
 void sptlrpc_pool_add_user(void)
 {