On 2024/6/18 22:45, wang wei wrote: > >>+ >>+static struct objpool_head ptr_pool; >>+static int nr_objs = 512; >>+static atomic_t nthreads; >>+static struct completion wait; >>+static struct page_frag_cache test_frag; >>+ >>+static int nr_test = 5120000; >>+module_param(nr_test, int, 0600); > > > "S_IRUSR | S_IWUSR" is better than "0600". Yes, it is better. But as we do the testing in module init, it seems we could just use module_param(nr_test, int, 0) instead. > > >>+MODULE_PARM_DESC(nr_test, "number of iterations to test"); >>+ >>+static bool test_align; >>+module_param(test_align, bool, 0600); >>+MODULE_PARM_DESC(test_align, "use align API for testing"); >>+ >>+static int test_alloc_len = 2048; >>+module_param(test_alloc_len, int, 0600); >>+MODULE_PARM_DESC(test_alloc_len, "alloc len for testing"); >>+ >>+static int test_push_cpu; >>+module_param(test_push_cpu, int, 0600); >>+MODULE_PARM_DESC(test_push_cpu, "test cpu for pushing fragment"); >>+ >>+static int test_pop_cpu; >>+module_param(test_pop_cpu, int, 0600); >>+MODULE_PARM_DESC(test_pop_cpu, "test cpu for popping fragment"); >>+ >>+static int page_frag_pop_thread(void *arg) >>+{ >>+ struct objpool_head *pool = arg; >>+ int nr = nr_test; >>+ >>+ pr_info("page_frag pop test thread begins on cpu %d\n", >>+ smp_processor_id()); >>+ >>+ while (nr > 0) { >>+ void *obj = objpool_pop(pool); >>+ >>+ if (obj) { >>+ nr--; >>+ page_frag_free(obj); >>+ } else { >>+ cond_resched(); >>+ } >>+ } >>+ >>+ if (atomic_dec_and_test(&nthreads)) >>+ complete(&wait); >>+ >>+ pr_info("page_frag pop test thread exits on cpu %d\n", >>+ smp_processor_id()); >>+ >>+ return 0; >>+} >>+ >>+static int page_frag_push_thread(void *arg) >>+{ >>+ struct objpool_head *pool = arg; >>+ int nr = nr_test; >>+ >>+ pr_info("page_frag push test thread begins on cpu %d\n", >>+ smp_processor_id()); >>+ >>+ while (nr > 0) { >>+ void *va; >>+ int ret; >>+ >>+ if (test_align) >>+ va = page_frag_alloc_align(&test_frag, test_alloc_len, >>+ GFP_KERNEL, SMP_CACHE_BYTES); > > > Every page fragment max size is PAGE_FRAG_CACHE_MAX_SIZE, hence the value of test_alloc_len needs to be checked. > yes, that needs to be checked. limit the test_alloc_len to PGAE_SIZE seems better, as we may fail back to order 0 page. >