>+
>+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".


>+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.


>+ else >+ va = page_frag_alloc(&test_frag, test_alloc_len, GFP_KERNEL); >+ >+ if (!va) >+ continue; >+ >+ ret = objpool_push(va, pool); >+ if (ret) { >+ page_frag_free(va); >+ cond_resched(); >+ } else { >+ nr--; >+ } >+ } >+ >+ pr_info("page_frag push test thread exits on cpu %d\n", >+ smp_processor_id()); >+ >+ if (atomic_dec_and_test(&nthreads)) >+ complete(&wait); >+ >+ return 0; >+}