Commit c5eaee3
committed
rcu-list: Fix the data-race
Instead of using the old implementation of thread-rcu [1], let's use
the newest and correct one, thread-rcu/rcu.h. And, to avoid the data
race while we traverse the linked list, introduce the for loop API,
list_for_each_entry_rcu.
After we changed the implementation and used the new for loop API, it
doesn't report the data race:
$ make
cc -o test test.c -g -Wall -std=c99 -fsanitize=thread -D'READER_NUM=10' -D'UPDATER_NUM=1' -D'TRACE_LOOP=1000' -D'CONFIG_TRACE_TIME' -lpthread
$ ./test
[tracer] loop 1000 : 2367069575.000000 ns
[1] https://github.com/linD026/parallel-programs/blob/main/rcu/thrd-based-rcu/thrd_rcu.h1 parent c5596e2 commit c5eaee3
4 files changed
+18
-224
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
66 | 74 | | |
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
72 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 41 | + | |
45 | 42 | | |
46 | 43 | | |
47 | 44 | | |
| |||
This file was deleted.
0 commit comments