blob: c40d6e636f33e2aafc8733c1e26024c591c569d0 [file] [log] [blame]
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +01001/*
2 * Resizable, Scalable, Concurrent Hash Table
3 *
Thomas Graf1aa661f2015-04-30 22:37:41 +00004 * Copyright (c) 2014-2015 Thomas Graf <tgraf@suug.ch>
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +01005 * Copyright (c) 2008-2014 Patrick McHardy <kaber@trash.net>
6 *
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +01007 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12/**************************************************************************
13 * Self Test
14 **************************************************************************/
15
16#include <linux/init.h>
17#include <linux/jhash.h>
18#include <linux/kernel.h>
Phil Sutterf4a3e902015-08-15 00:37:15 +020019#include <linux/kthread.h>
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +010020#include <linux/module.h>
21#include <linux/rcupdate.h>
22#include <linux/rhashtable.h>
Phil Sutterf4a3e902015-08-15 00:37:15 +020023#include <linux/semaphore.h>
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +010024#include <linux/slab.h>
Thomas Graf685a0152015-07-17 10:52:48 +020025#include <linux/sched.h>
Phil Sutterf4a3e902015-08-15 00:37:15 +020026#include <linux/vmalloc.h>
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +010027
Thomas Graf1aa661f2015-04-30 22:37:41 +000028#define MAX_ENTRIES 1000000
Thomas Graf67b7cbf2015-04-30 22:37:45 +000029#define TEST_INSERT_FAIL INT_MAX
Thomas Graf1aa661f2015-04-30 22:37:41 +000030
31static int entries = 50000;
32module_param(entries, int, 0);
33MODULE_PARM_DESC(entries, "Number of entries to add (default: 50000)");
34
35static int runs = 4;
36module_param(runs, int, 0);
37MODULE_PARM_DESC(runs, "Number of test runs per variant (default: 4)");
38
Phil Sutter95e435a2015-11-20 18:17:19 +010039static int max_size = 0;
Thomas Graf1aa661f2015-04-30 22:37:41 +000040module_param(max_size, int, 0);
Phil Sutter3b3bf802016-08-04 12:37:17 +020041MODULE_PARM_DESC(max_size, "Maximum table size (default: calculated)");
Thomas Graf1aa661f2015-04-30 22:37:41 +000042
43static bool shrinking = false;
44module_param(shrinking, bool, 0);
45MODULE_PARM_DESC(shrinking, "Enable automatic shrinking (default: off)");
46
47static int size = 8;
48module_param(size, int, 0);
49MODULE_PARM_DESC(size, "Initial size hint of table (default: 8)");
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +010050
Phil Sutterf4a3e902015-08-15 00:37:15 +020051static int tcount = 10;
52module_param(tcount, int, 0);
53MODULE_PARM_DESC(tcount, "Number of threads to spawn (default: 10)");
54
Phil Sutterd662e032015-11-20 18:17:20 +010055static bool enomem_retry = false;
56module_param(enomem_retry, bool, 0);
57MODULE_PARM_DESC(enomem_retry, "Retry insert even if -ENOMEM was returned (default: off)");
58
Phil Suttere859afe2017-07-21 16:51:31 +020059struct test_obj_val {
60 int id;
61 int tid;
62};
63
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +010064struct test_obj {
Phil Suttere859afe2017-07-21 16:51:31 +020065 struct test_obj_val value;
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +010066 struct rhash_head node;
67};
68
Phil Sutterf4a3e902015-08-15 00:37:15 +020069struct thread_data {
70 int id;
71 struct task_struct *task;
72 struct test_obj *objs;
73};
74
Thomas Graf1aa661f2015-04-30 22:37:41 +000075static struct rhashtable_params test_rht_params = {
Herbert Xub182aa62015-03-20 21:57:04 +110076 .head_offset = offsetof(struct test_obj, node),
77 .key_offset = offsetof(struct test_obj, value),
Phil Suttere859afe2017-07-21 16:51:31 +020078 .key_len = sizeof(struct test_obj_val),
Herbert Xub182aa62015-03-20 21:57:04 +110079 .hashfn = jhash,
Herbert Xub182aa62015-03-20 21:57:04 +110080 .nulls_base = (3U << RHT_BASE_SHIFT),
81};
82
Phil Sutterf4a3e902015-08-15 00:37:15 +020083static struct semaphore prestart_sem;
84static struct semaphore startup_sem = __SEMAPHORE_INITIALIZER(startup_sem, 0);
85
Florian Westphal7e936bd2017-09-20 01:12:11 +020086static int insert_retry(struct rhashtable *ht, struct test_obj *obj,
Phil Sutter9e9089e2015-11-20 18:17:18 +010087 const struct rhashtable_params params)
88{
Phil Sutterd662e032015-11-20 18:17:20 +010089 int err, retries = -1, enomem_retries = 0;
Phil Sutter9e9089e2015-11-20 18:17:18 +010090
91 do {
92 retries++;
93 cond_resched();
Florian Westphal7e936bd2017-09-20 01:12:11 +020094 err = rhashtable_insert_fast(ht, &obj->node, params);
Phil Sutterd662e032015-11-20 18:17:20 +010095 if (err == -ENOMEM && enomem_retry) {
96 enomem_retries++;
97 err = -EBUSY;
98 }
Phil Sutter9e9089e2015-11-20 18:17:18 +010099 } while (err == -EBUSY);
100
Phil Sutterd662e032015-11-20 18:17:20 +0100101 if (enomem_retries)
102 pr_info(" %u insertions retried after -ENOMEM\n",
103 enomem_retries);
104
Phil Sutter9e9089e2015-11-20 18:17:18 +0100105 return err ? : retries;
106}
107
Florian Westphal7e936bd2017-09-20 01:12:11 +0200108static int __init test_rht_lookup(struct rhashtable *ht, struct test_obj *array)
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100109{
110 unsigned int i;
111
Thomas Graf1aa661f2015-04-30 22:37:41 +0000112 for (i = 0; i < entries * 2; i++) {
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100113 struct test_obj *obj;
114 bool expected = !(i % 2);
Phil Suttere859afe2017-07-21 16:51:31 +0200115 struct test_obj_val key = {
116 .id = i,
117 };
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100118
Phil Suttere859afe2017-07-21 16:51:31 +0200119 if (array[i / 2].value.id == TEST_INSERT_FAIL)
Thomas Graf67b7cbf2015-04-30 22:37:45 +0000120 expected = false;
121
Herbert Xub182aa62015-03-20 21:57:04 +1100122 obj = rhashtable_lookup_fast(ht, &key, test_rht_params);
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100123
124 if (expected && !obj) {
Phil Suttere859afe2017-07-21 16:51:31 +0200125 pr_warn("Test failed: Could not find key %u\n", key.id);
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100126 return -ENOENT;
127 } else if (!expected && obj) {
128 pr_warn("Test failed: Unexpected entry found for key %u\n",
Phil Suttere859afe2017-07-21 16:51:31 +0200129 key.id);
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100130 return -EEXIST;
131 } else if (expected && obj) {
Phil Suttere859afe2017-07-21 16:51:31 +0200132 if (obj->value.id != i) {
Thomas Grafc2c8a902015-04-30 22:37:42 +0000133 pr_warn("Test failed: Lookup value mismatch %u!=%u\n",
Phil Suttere859afe2017-07-21 16:51:31 +0200134 obj->value.id, i);
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100135 return -EINVAL;
136 }
137 }
Thomas Graf685a0152015-07-17 10:52:48 +0200138
139 cond_resched_rcu();
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100140 }
141
142 return 0;
143}
144
Thomas Graf246b23a2015-04-30 22:37:44 +0000145static void test_bucket_stats(struct rhashtable *ht)
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100146{
Thomas Graf246b23a2015-04-30 22:37:44 +0000147 unsigned int err, total = 0, chain_len = 0;
148 struct rhashtable_iter hti;
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100149 struct rhash_head *pos;
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100150
Bob Copeland8f6fd832016-03-02 10:09:19 -0500151 err = rhashtable_walk_init(ht, &hti, GFP_KERNEL);
Thomas Graf246b23a2015-04-30 22:37:44 +0000152 if (err) {
153 pr_warn("Test failed: allocation error");
154 return;
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100155 }
156
Thomas Graf246b23a2015-04-30 22:37:44 +0000157 err = rhashtable_walk_start(&hti);
158 if (err && err != -EAGAIN) {
159 pr_warn("Test failed: iterator failed: %d\n", err);
160 return;
161 }
162
163 while ((pos = rhashtable_walk_next(&hti))) {
164 if (PTR_ERR(pos) == -EAGAIN) {
165 pr_info("Info: encountered resize\n");
166 chain_len++;
167 continue;
168 } else if (IS_ERR(pos)) {
169 pr_warn("Test failed: rhashtable_walk_next() error: %ld\n",
170 PTR_ERR(pos));
171 break;
172 }
173
174 total++;
175 }
176
177 rhashtable_walk_stop(&hti);
178 rhashtable_walk_exit(&hti);
179
180 pr_info(" Traversal complete: counted=%u, nelems=%u, entries=%d, table-jumps=%u\n",
181 total, atomic_read(&ht->nelems), entries, chain_len);
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100182
Thomas Graf1aa661f2015-04-30 22:37:41 +0000183 if (total != atomic_read(&ht->nelems) || total != entries)
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100184 pr_warn("Test failed: Total count mismatch ^^^");
185}
186
Florian Westphal7e936bd2017-09-20 01:12:11 +0200187static s64 __init test_rhashtable(struct rhashtable *ht, struct test_obj *array)
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100188{
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100189 struct test_obj *obj;
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100190 int err;
Phil Sutter9e9089e2015-11-20 18:17:18 +0100191 unsigned int i, insert_retries = 0;
Thomas Graf1aa661f2015-04-30 22:37:41 +0000192 s64 start, end;
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100193
194 /*
195 * Insertion Test:
Thomas Graf1aa661f2015-04-30 22:37:41 +0000196 * Insert entries into table with all keys even numbers
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100197 */
Thomas Graf1aa661f2015-04-30 22:37:41 +0000198 pr_info(" Adding %d keys\n", entries);
199 start = ktime_get_ns();
200 for (i = 0; i < entries; i++) {
Thomas Graffcc57022015-04-30 22:37:43 +0000201 struct test_obj *obj = &array[i];
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100202
Phil Suttere859afe2017-07-21 16:51:31 +0200203 obj->value.id = i * 2;
Florian Westphal7e936bd2017-09-20 01:12:11 +0200204 err = insert_retry(ht, obj, test_rht_params);
Phil Sutter9e9089e2015-11-20 18:17:18 +0100205 if (err > 0)
206 insert_retries += err;
207 else if (err)
Thomas Graffcc57022015-04-30 22:37:43 +0000208 return err;
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100209 }
210
Phil Sutter9e9089e2015-11-20 18:17:18 +0100211 if (insert_retries)
212 pr_info(" %u insertions retried due to memory pressure\n",
213 insert_retries);
Thomas Graf67b7cbf2015-04-30 22:37:45 +0000214
Thomas Graf246b23a2015-04-30 22:37:44 +0000215 test_bucket_stats(ht);
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100216 rcu_read_lock();
Florian Westphal7e936bd2017-09-20 01:12:11 +0200217 test_rht_lookup(ht, array);
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100218 rcu_read_unlock();
219
Thomas Graf246b23a2015-04-30 22:37:44 +0000220 test_bucket_stats(ht);
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100221
Thomas Graf1aa661f2015-04-30 22:37:41 +0000222 pr_info(" Deleting %d keys\n", entries);
223 for (i = 0; i < entries; i++) {
Phil Sutter78369252017-07-25 13:36:21 +0200224 struct test_obj_val key = {
225 .id = i * 2,
226 };
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100227
Phil Suttere859afe2017-07-21 16:51:31 +0200228 if (array[i].value.id != TEST_INSERT_FAIL) {
Thomas Graf67b7cbf2015-04-30 22:37:45 +0000229 obj = rhashtable_lookup_fast(ht, &key, test_rht_params);
230 BUG_ON(!obj);
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100231
Thomas Graf67b7cbf2015-04-30 22:37:45 +0000232 rhashtable_remove_fast(ht, &obj->node, test_rht_params);
233 }
Thomas Graf685a0152015-07-17 10:52:48 +0200234
235 cond_resched();
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100236 }
237
Thomas Graf1aa661f2015-04-30 22:37:41 +0000238 end = ktime_get_ns();
239 pr_info(" Duration of test: %lld ns\n", end - start);
240
241 return end - start;
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100242}
243
Daniel Borkmannb7f5e5c2015-02-20 21:14:21 +0100244static struct rhashtable ht;
245
Phil Sutterf4a3e902015-08-15 00:37:15 +0200246static int thread_lookup_test(struct thread_data *tdata)
247{
248 int i, err = 0;
249
250 for (i = 0; i < entries; i++) {
251 struct test_obj *obj;
Phil Suttere859afe2017-07-21 16:51:31 +0200252 struct test_obj_val key = {
253 .id = i,
254 .tid = tdata->id,
255 };
Phil Sutterf4a3e902015-08-15 00:37:15 +0200256
257 obj = rhashtable_lookup_fast(&ht, &key, test_rht_params);
Phil Suttere859afe2017-07-21 16:51:31 +0200258 if (obj && (tdata->objs[i].value.id == TEST_INSERT_FAIL)) {
259 pr_err(" found unexpected object %d-%d\n", key.tid, key.id);
Phil Sutterf4a3e902015-08-15 00:37:15 +0200260 err++;
Phil Suttere859afe2017-07-21 16:51:31 +0200261 } else if (!obj && (tdata->objs[i].value.id != TEST_INSERT_FAIL)) {
262 pr_err(" object %d-%d not found!\n", key.tid, key.id);
Phil Sutterf4a3e902015-08-15 00:37:15 +0200263 err++;
Phil Suttere859afe2017-07-21 16:51:31 +0200264 } else if (obj && memcmp(&obj->value, &key, sizeof(key))) {
265 pr_err(" wrong object returned (got %d-%d, expected %d-%d)\n",
266 obj->value.tid, obj->value.id, key.tid, key.id);
Phil Sutterf4a3e902015-08-15 00:37:15 +0200267 err++;
268 }
Phil Suttercd5b3182015-11-20 18:17:17 +0100269
270 cond_resched();
Phil Sutterf4a3e902015-08-15 00:37:15 +0200271 }
272 return err;
273}
274
275static int threadfunc(void *data)
276{
Phil Sutter9e9089e2015-11-20 18:17:18 +0100277 int i, step, err = 0, insert_retries = 0;
Phil Sutterf4a3e902015-08-15 00:37:15 +0200278 struct thread_data *tdata = data;
279
280 up(&prestart_sem);
281 if (down_interruptible(&startup_sem))
282 pr_err(" thread[%d]: down_interruptible failed\n", tdata->id);
283
284 for (i = 0; i < entries; i++) {
Phil Suttere859afe2017-07-21 16:51:31 +0200285 tdata->objs[i].value.id = i;
286 tdata->objs[i].value.tid = tdata->id;
Florian Westphal7e936bd2017-09-20 01:12:11 +0200287 err = insert_retry(&ht, &tdata->objs[i], test_rht_params);
Phil Sutter9e9089e2015-11-20 18:17:18 +0100288 if (err > 0) {
289 insert_retries += err;
Phil Sutterf4a3e902015-08-15 00:37:15 +0200290 } else if (err) {
291 pr_err(" thread[%d]: rhashtable_insert_fast failed\n",
292 tdata->id);
293 goto out;
294 }
295 }
Phil Sutter9e9089e2015-11-20 18:17:18 +0100296 if (insert_retries)
297 pr_info(" thread[%d]: %u insertions retried due to memory pressure\n",
298 tdata->id, insert_retries);
Phil Sutterf4a3e902015-08-15 00:37:15 +0200299
300 err = thread_lookup_test(tdata);
301 if (err) {
302 pr_err(" thread[%d]: rhashtable_lookup_test failed\n",
303 tdata->id);
304 goto out;
305 }
306
307 for (step = 10; step > 0; step--) {
308 for (i = 0; i < entries; i += step) {
Phil Suttere859afe2017-07-21 16:51:31 +0200309 if (tdata->objs[i].value.id == TEST_INSERT_FAIL)
Phil Sutterf4a3e902015-08-15 00:37:15 +0200310 continue;
311 err = rhashtable_remove_fast(&ht, &tdata->objs[i].node,
312 test_rht_params);
313 if (err) {
314 pr_err(" thread[%d]: rhashtable_remove_fast failed\n",
315 tdata->id);
316 goto out;
317 }
Phil Suttere859afe2017-07-21 16:51:31 +0200318 tdata->objs[i].value.id = TEST_INSERT_FAIL;
Phil Suttercd5b3182015-11-20 18:17:17 +0100319
320 cond_resched();
Phil Sutterf4a3e902015-08-15 00:37:15 +0200321 }
322 err = thread_lookup_test(tdata);
323 if (err) {
324 pr_err(" thread[%d]: rhashtable_lookup_test (2) failed\n",
325 tdata->id);
326 goto out;
327 }
328 }
329out:
330 while (!kthread_should_stop()) {
331 set_current_state(TASK_INTERRUPTIBLE);
332 schedule();
333 }
334 return err;
335}
336
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100337static int __init test_rht_init(void)
338{
Phil Sutterf4a3e902015-08-15 00:37:15 +0200339 int i, err, started_threads = 0, failed_threads = 0;
Thomas Graf1aa661f2015-04-30 22:37:41 +0000340 u64 total_time = 0;
Phil Sutterf4a3e902015-08-15 00:37:15 +0200341 struct thread_data *tdata;
342 struct test_obj *objs;
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100343
Thomas Graf1aa661f2015-04-30 22:37:41 +0000344 entries = min(entries, MAX_ENTRIES);
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100345
Thomas Graf1aa661f2015-04-30 22:37:41 +0000346 test_rht_params.automatic_shrinking = shrinking;
Phil Sutter95e435a2015-11-20 18:17:19 +0100347 test_rht_params.max_size = max_size ? : roundup_pow_of_two(entries);
Thomas Graf1aa661f2015-04-30 22:37:41 +0000348 test_rht_params.nelem_hint = size;
349
Florian Westphal7e936bd2017-09-20 01:12:11 +0200350 objs = vzalloc((test_rht_params.max_size + 1) * sizeof(struct test_obj));
351 if (!objs)
352 return -ENOMEM;
353
Thomas Graf1aa661f2015-04-30 22:37:41 +0000354 pr_info("Running rhashtable test nelem=%d, max_size=%d, shrinking=%d\n",
355 size, max_size, shrinking);
356
357 for (i = 0; i < runs; i++) {
358 s64 time;
359
360 pr_info("Test %02d:\n", i);
Florian Westphal7e936bd2017-09-20 01:12:11 +0200361 memset(objs, 0, test_rht_params.max_size * sizeof(struct test_obj));
362
Thomas Graf1aa661f2015-04-30 22:37:41 +0000363 err = rhashtable_init(&ht, &test_rht_params);
364 if (err < 0) {
365 pr_warn("Test failed: Unable to initialize hashtable: %d\n",
366 err);
367 continue;
368 }
369
Florian Westphal7e936bd2017-09-20 01:12:11 +0200370 time = test_rhashtable(&ht, objs);
Thomas Graf1aa661f2015-04-30 22:37:41 +0000371 rhashtable_destroy(&ht);
372 if (time < 0) {
Florian Westphal7e936bd2017-09-20 01:12:11 +0200373 vfree(objs);
Thomas Graf1aa661f2015-04-30 22:37:41 +0000374 pr_warn("Test failed: return code %lld\n", time);
375 return -EINVAL;
376 }
377
378 total_time += time;
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100379 }
380
Florian Westphal7e936bd2017-09-20 01:12:11 +0200381 vfree(objs);
Thomas Graf6decd632015-05-05 02:27:02 +0200382 do_div(total_time, runs);
383 pr_info("Average test time: %llu\n", total_time);
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100384
Phil Sutterf4a3e902015-08-15 00:37:15 +0200385 if (!tcount)
386 return 0;
387
388 pr_info("Testing concurrent rhashtable access from %d threads\n",
389 tcount);
390 sema_init(&prestart_sem, 1 - tcount);
391 tdata = vzalloc(tcount * sizeof(struct thread_data));
392 if (!tdata)
393 return -ENOMEM;
394 objs = vzalloc(tcount * entries * sizeof(struct test_obj));
395 if (!objs) {
396 vfree(tdata);
397 return -ENOMEM;
398 }
399
Phil Sutter95e435a2015-11-20 18:17:19 +0100400 test_rht_params.max_size = max_size ? :
401 roundup_pow_of_two(tcount * entries);
Phil Sutterf4a3e902015-08-15 00:37:15 +0200402 err = rhashtable_init(&ht, &test_rht_params);
403 if (err < 0) {
404 pr_warn("Test failed: Unable to initialize hashtable: %d\n",
405 err);
406 vfree(tdata);
407 vfree(objs);
408 return -EINVAL;
409 }
410 for (i = 0; i < tcount; i++) {
411 tdata[i].id = i;
412 tdata[i].objs = objs + i * entries;
413 tdata[i].task = kthread_run(threadfunc, &tdata[i],
414 "rhashtable_thrad[%d]", i);
415 if (IS_ERR(tdata[i].task))
416 pr_err(" kthread_run failed for thread %d\n", i);
417 else
418 started_threads++;
419 }
420 if (down_interruptible(&prestart_sem))
421 pr_err(" down interruptible failed\n");
422 for (i = 0; i < tcount; i++)
423 up(&startup_sem);
424 for (i = 0; i < tcount; i++) {
425 if (IS_ERR(tdata[i].task))
426 continue;
427 if ((err = kthread_stop(tdata[i].task))) {
428 pr_warn("Test failed: thread %d returned: %d\n",
429 i, err);
430 failed_threads++;
431 }
432 }
433 pr_info("Started %d threads, %d failed\n",
434 started_threads, failed_threads);
435 rhashtable_destroy(&ht);
436 vfree(tdata);
437 vfree(objs);
Thomas Graf1aa661f2015-04-30 22:37:41 +0000438 return 0;
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100439}
440
Daniel Borkmann6dd0c162015-02-20 00:53:39 +0100441static void __exit test_rht_exit(void)
442{
443}
444
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100445module_init(test_rht_init);
Daniel Borkmann6dd0c162015-02-20 00:53:39 +0100446module_exit(test_rht_exit);
Geert Uytterhoeven9d6dbe12015-01-29 15:40:25 +0100447
448MODULE_LICENSE("GPL v2");