15
15
#include <linux/delay.h>
16
16
#include <linux/rwsem.h>
17
17
#include <linux/mm.h>
18
+ #include <linux/rcupdate.h>
19
+ #include <linux/slab.h>
18
20
19
21
#define __param (type , name , init , msg ) \
20
22
static type name = init; \
@@ -35,14 +37,18 @@ __param(int, test_loop_count, 1000000,
35
37
36
38
__param (int , run_test_mask , INT_MAX ,
37
39
"Set tests specified in the mask.\n\n"
38
- "\t\tid: 1, name: fix_size_alloc_test\n"
39
- "\t\tid: 2, name: full_fit_alloc_test\n"
40
- "\t\tid: 4, name: long_busy_list_alloc_test\n"
41
- "\t\tid: 8, name: random_size_alloc_test\n"
42
- "\t\tid: 16, name: fix_align_alloc_test\n"
43
- "\t\tid: 32, name: random_size_align_alloc_test\n"
44
- "\t\tid: 64, name: align_shift_alloc_test\n"
45
- "\t\tid: 128, name: pcpu_alloc_test\n"
40
+ "\t\tid: 1, name: fix_size_alloc_test\n"
41
+ "\t\tid: 2, name: full_fit_alloc_test\n"
42
+ "\t\tid: 4, name: long_busy_list_alloc_test\n"
43
+ "\t\tid: 8, name: random_size_alloc_test\n"
44
+ "\t\tid: 16, name: fix_align_alloc_test\n"
45
+ "\t\tid: 32, name: random_size_align_alloc_test\n"
46
+ "\t\tid: 64, name: align_shift_alloc_test\n"
47
+ "\t\tid: 128, name: pcpu_alloc_test\n"
48
+ "\t\tid: 256, name: kvfree_rcu_1_arg_vmalloc_test\n"
49
+ "\t\tid: 512, name: kvfree_rcu_2_arg_vmalloc_test\n"
50
+ "\t\tid: 1024, name: kvfree_rcu_1_arg_slab_test\n"
51
+ "\t\tid: 2048, name: kvfree_rcu_2_arg_slab_test\n"
46
52
/* Add a new test case description here. */
47
53
);
48
54
@@ -316,6 +322,83 @@ pcpu_alloc_test(void)
316
322
return rv ;
317
323
}
318
324
325
+ struct test_kvfree_rcu {
326
+ struct rcu_head rcu ;
327
+ unsigned char array [20 ];
328
+ };
329
+
330
+ static int
331
+ kvfree_rcu_1_arg_vmalloc_test (void )
332
+ {
333
+ struct test_kvfree_rcu * p ;
334
+ int i ;
335
+
336
+ for (i = 0 ; i < test_loop_count ; i ++ ) {
337
+ p = vmalloc (1 * PAGE_SIZE );
338
+ if (!p )
339
+ return -1 ;
340
+
341
+ p -> array [0 ] = 'a' ;
342
+ kvfree_rcu (p );
343
+ }
344
+
345
+ return 0 ;
346
+ }
347
+
348
+ static int
349
+ kvfree_rcu_2_arg_vmalloc_test (void )
350
+ {
351
+ struct test_kvfree_rcu * p ;
352
+ int i ;
353
+
354
+ for (i = 0 ; i < test_loop_count ; i ++ ) {
355
+ p = vmalloc (1 * PAGE_SIZE );
356
+ if (!p )
357
+ return -1 ;
358
+
359
+ p -> array [0 ] = 'a' ;
360
+ kvfree_rcu (p , rcu );
361
+ }
362
+
363
+ return 0 ;
364
+ }
365
+
366
+ static int
367
+ kvfree_rcu_1_arg_slab_test (void )
368
+ {
369
+ struct test_kvfree_rcu * p ;
370
+ int i ;
371
+
372
+ for (i = 0 ; i < test_loop_count ; i ++ ) {
373
+ p = kmalloc (sizeof (* p ), GFP_KERNEL );
374
+ if (!p )
375
+ return -1 ;
376
+
377
+ p -> array [0 ] = 'a' ;
378
+ kvfree_rcu (p );
379
+ }
380
+
381
+ return 0 ;
382
+ }
383
+
384
+ static int
385
+ kvfree_rcu_2_arg_slab_test (void )
386
+ {
387
+ struct test_kvfree_rcu * p ;
388
+ int i ;
389
+
390
+ for (i = 0 ; i < test_loop_count ; i ++ ) {
391
+ p = kmalloc (sizeof (* p ), GFP_KERNEL );
392
+ if (!p )
393
+ return -1 ;
394
+
395
+ p -> array [0 ] = 'a' ;
396
+ kvfree_rcu (p , rcu );
397
+ }
398
+
399
+ return 0 ;
400
+ }
401
+
319
402
struct test_case_desc {
320
403
const char * test_name ;
321
404
int (* test_func )(void );
@@ -330,6 +413,10 @@ static struct test_case_desc test_case_array[] = {
330
413
{ "random_size_align_alloc_test" , random_size_align_alloc_test },
331
414
{ "align_shift_alloc_test" , align_shift_alloc_test },
332
415
{ "pcpu_alloc_test" , pcpu_alloc_test },
416
+ { "kvfree_rcu_1_arg_vmalloc_test" , kvfree_rcu_1_arg_vmalloc_test },
417
+ { "kvfree_rcu_2_arg_vmalloc_test" , kvfree_rcu_2_arg_vmalloc_test },
418
+ { "kvfree_rcu_1_arg_slab_test" , kvfree_rcu_1_arg_slab_test },
419
+ { "kvfree_rcu_2_arg_slab_test" , kvfree_rcu_2_arg_slab_test },
333
420
/* Add a new test case here. */
334
421
};
335
422
0 commit comments