Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/rbtree: add random seed

Current test use pseudo rand function with fixed seed, which means the
test data is the same pattern each time.

Add random seed parameter to randomize the test.

Link: https://lkml.kernel.org/r/20250310074938.26756-4-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michel Lespinasse <michel@lespinasse.org>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Wei Yang and committed by
Andrew Morton
16b1936a 3e1d58cd

+15 -4
+1
include/linux/types.h
··· 92 92 typedef unsigned short ushort; 93 93 typedef unsigned int uint; 94 94 typedef unsigned long ulong; 95 + typedef unsigned long long ullong; 95 96 96 97 #ifndef __BIT_TYPES_DEFINED__ 97 98 #define __BIT_TYPES_DEFINED__
+2 -1
lib/interval_tree_test.c
··· 19 19 __param(bool, search_all, false, "Searches will iterate all nodes in the tree"); 20 20 21 21 __param(uint, max_endpoint, ~0, "Largest value for the interval's endpoint"); 22 + __param(ullong, seed, 3141592653589793238ULL, "Random seed"); 22 23 23 24 static struct rb_root_cached root = RB_ROOT_CACHED; 24 25 static struct interval_tree_node *nodes = NULL; ··· 138 137 return -ENOMEM; 139 138 } 140 139 141 - prandom_seed_state(&rnd, 3141592653589793238ULL); 140 + prandom_seed_state(&rnd, seed); 142 141 143 142 basic_check(); 144 143 search_check();
+2 -1
lib/rbtree_test.c
··· 14 14 __param(int, nnodes, 100, "Number of nodes in the rb-tree"); 15 15 __param(int, perf_loops, 1000, "Number of iterations modifying the rb-tree"); 16 16 __param(int, check_loops, 100, "Number of iterations modifying and verifying the rb-tree"); 17 + __param(ullong, seed, 3141592653589793238ULL, "Random seed"); 17 18 18 19 struct test_node { 19 20 u32 key; ··· 403 402 if (!nodes) 404 403 return -ENOMEM; 405 404 406 - prandom_seed_state(&rnd, 3141592653589793238ULL); 405 + prandom_seed_state(&rnd, seed); 407 406 408 407 basic_check(); 409 408 augmented_check();
+2
tools/include/linux/types.h
··· 42 42 typedef __u8 u8; 43 43 typedef __s8 s8; 44 44 45 + typedef unsigned long long ullong; 46 + 45 47 #ifdef __CHECKER__ 46 48 #define __bitwise __attribute__((bitwise)) 47 49 #else
+4 -1
tools/testing/rbtree/interval_tree_test.c
··· 18 18 fprintf(stderr, " -s: Number of iterations searching the tree\n"); 19 19 fprintf(stderr, " -a: Searches will iterate all nodes in the tree\n"); 20 20 fprintf(stderr, " -m: Largest value for the interval's endpoint\n"); 21 + fprintf(stderr, " -r: Random seed\n"); 21 22 exit(-1); 22 23 } 23 24 ··· 32 31 { 33 32 int opt; 34 33 35 - while ((opt = getopt(argc, argv, "n:p:q:s:am:")) != -1) { 34 + while ((opt = getopt(argc, argv, "n:p:q:s:am:r:")) != -1) { 36 35 if (opt == 'n') 37 36 nnodes = strtoul(optarg, NULL, 0); 38 37 else if (opt == 'p') ··· 45 44 search_all = true; 46 45 else if (opt == 'm') 47 46 max_endpoint = strtoul(optarg, NULL, 0); 47 + else if (opt == 'r') 48 + seed = strtoul(optarg, NULL, 0); 48 49 else 49 50 usage(); 50 51 }
+4 -1
tools/testing/rbtree/rbtree_test.c
··· 16 16 fprintf(stderr, " -n: Number of nodes in the rb-tree\n"); 17 17 fprintf(stderr, " -p: Number of iterations modifying the rb-tree\n"); 18 18 fprintf(stderr, " -c: Number of iterations modifying and verifying the rb-tree\n"); 19 + fprintf(stderr, " -r: Random seed\n"); 19 20 exit(-1); 20 21 } 21 22 ··· 30 29 { 31 30 int opt; 32 31 33 - while ((opt = getopt(argc, argv, "n:p:c:")) != -1) { 32 + while ((opt = getopt(argc, argv, "n:p:c:r:")) != -1) { 34 33 if (opt == 'n') 35 34 nnodes = strtoul(optarg, NULL, 0); 36 35 else if (opt == 'p') 37 36 perf_loops = strtoul(optarg, NULL, 0); 38 37 else if (opt == 'c') 39 38 check_loops = strtoul(optarg, NULL, 0); 39 + else if (opt == 'r') 40 + seed = strtoul(optarg, NULL, 0); 40 41 else 41 42 usage(); 42 43 }