-
Notifications
You must be signed in to change notification settings - Fork 3
/
markobjmod.tex
341 lines (331 loc) · 6.8 KB
/
markobjmod.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
This approach uses a keyword that does not participate in type checking,
for example, a \co{_Carries_dependency} keyword.
This might be treated in a manner similar to a storage class.
It need not necessarily interact with the type system.
\begin{figure}[tbp]
{ \scriptsize
\begin{verbatim}
1 void thread0()
2 {
3 rcutest *p = new rcutest();
7 p->a = 42;
8 assert(p->a != 43);
9 rcu_assign_pointer(gp, p);
10 }
11
12 void thread1()
13 {
14 rcutest *_Carries_dependency p = rcu_dereference(gp);
15 if (p)
16 p->a = 43;
17 }
\end{verbatim}
}
\caption{Object Modifier: Simple Case}
\label{fig:Object Modifier: Simple Case}
\end{figure}
\begin{figure}[tbp]
{ \scriptsize
\begin{verbatim}
1 void thread0()
2 {
3 rcutest *p = new rcutest();
4 p->a = 42;
5 rcu_assign_pointer(gp, p);
6 }
7
8 void
9 thread1_help(rcutest *_Carries_dependency q)
10 {
11 if (q)
12 assert(q->a == 42);
13 }
14
15 void thread1()
16 {
17 rcutest *_Carries_dependency p = rcu_dereference(gp);
18 thread1_help(p);
19 }
\end{verbatim}
}
\caption{Object Modifier: In via Function Parameter}
\label{fig:Object Modifier: In via Function Parameter}
\end{figure}
\begin{figure}[tbp]
{ \scriptsize
\begin{verbatim}
1 void thread0()
2 {
3 rcutest *p = new rcutest();
4 p->a = 42;
5 rcu_assign_pointer(gp, p);
6 }
7
8 rcutest *_Carries_dependency thread1_help()
9 {
10 return rcu_dereference(gp);
11 }
12
13 void thread1()
14 {
15 rcutest *_Carries_dependency p = thread1_help();
16 if (p)
17 assert(p->a == 42);
18 }
\end{verbatim}
}
\caption{Object Modifier: Out via Function Return}
\label{fig:Object Modifier: Out via Function Return}
\end{figure}
\begin{figure}[tbp]
{ \scriptsize
\begin{verbatim}
1 void thread0()
2 {
3 rcutest *p = new rcutest();
4 p->a = 42;
5 rcu_assign_pointer(gp, p);
6
7 p = new rcutest();
8 p->a = 43;
9 rcu_assign_pointer(gsgp, p);
10 }
11
12 rcutest *_Carries_dependency
13 thread1_help(rcutest *_Carries_dependency p)
14 {
15 if (p)
16 assert(p->a == 42);
17 return rcu_dereference(gsgp);
18 }
19
20 void thread1(void)
21 {
22 rcutest *_Carries_dependency p = rcu_dereference(gp);
23 p = thread1_help(p);
24 if (p)
25 assert(p->a == 43);
26 }
\end{verbatim}
}
\caption{Object Modifier: In and Out, But Different Chains}
\label{fig:Object Modifier: In and Out, But Different Chains}
\end{figure}
\begin{figure}[tbp]
{ \scriptsize
\begin{verbatim}
1 void thread0()
2 {
3 rcutest *p = new rcutest();
4 p->a = 42;
5 rcu_assign_pointer(gp, p);
6 }
7
8 void
9 thread1_help1(rcutest *_Carries_dependency q)
10 {
11 if (q)
12 assert(q->a == 42);
13 }
14
15 void
16 thread1_help2(rcutest *_Carries_dependency q)
17 {
18 if (q)
19 assert(q->a != 43);
20 }
21
22 void thread1()
23 {
24 rcutest *_Carries_dependency p = rcu_dereference(gp);
25 thread1_help1(p);
26 thread1_help2(p);
27 }
\end{verbatim}
}
\caption{Object Modifier: Chain Fanning Out}
\label{fig:Object Modifier: Chain Fanning Out}
\end{figure}
\begin{figure}[tbp]
{ \scriptsize
\begin{verbatim}
1 void thread0()
2 {
3 rcutest *p = new rcutest();
4 p->a = 42;
5 rcu_assign_pointer(gp, p);
6 rcutest1 *p1 = new rcutest1();
7 p1->a = 41;
8 p1->rt.a = 42;
9 rcu_assign_pointer(g1p, p1);
10 }
11
12 void
13 thread1_help(rcutest *_Carries_dependency q)
14 {
15 if (q)
16 assert(q->a == 42);
17 }
18
19 void thread1()
20 {
21 rcutest *_Carries_dependency p = rcu_dereference(gp);
22 thread1_help(p);
23 }
24
25 void thread2()
26 {
27 rcutest1 *_Carries_dependency p1 = rcu_dereference(g1p);
28 thread1_help(&p1->rt);
29 }
\end{verbatim}
}
\caption{Object Modifier: Chain Fanning In}
\label{fig:Object Modifier: Chain Fanning In}
\end{figure}
\begin{figure}[tbp]
{ \scriptsize
\begin{verbatim}
1 void thread0()
2 {
3 rcutest *p = new rcutest();
4 p->a = 42;
5 p->b = 43;
6 rcu_assign_pointer(gp, p);
7 rcutest1 *p1 = new rcutest1();
8 p1->a = 41;
9 p1->rt.a = 42;
10 p1->rt.b = 43;
11 rcu_assign_pointer(g1p, p1);
12 }
13
14 void
15 thread1a_help(rcutest *_Carries_dependency q)
16 {
17 assert(q->a == 42);
18 }
19
20 void
21 thread1b_help(rcutest *_Carries_dependency q)
22 {
23 assert(q->b == 43);
24 }
25
26 void
27 thread1_help(rcutest *_Carries_dependency q)
28 {
29 if (q) {
30 thread1a_help(q);
31 thread1b_help(q);
32 }
33 }
34
35 void thread1()
36 {
37 rcutest *_Carries_dependency p = rcu_dereference(gp);
38 thread1_help(p);
39 }
40
41 void thread2()
42 {
43 rcutest1 *_Carries_dependency p1 = rcu_dereference(g1p);
44 thread1_help(&p1->rt);
45 }
\end{verbatim}
}
\caption{Object Modifier: Chain Fanning In and Out}
\label{fig:Object Modifier: Chain Fanning In and Out}
\end{figure}
\begin{figure}[tbp]
{ \scriptsize
\begin{verbatim}
1 void thread0()
2 {
3 struct rcutest *p = new rcutest();
4 p->a = 42;
5 p->b = 43;
6 rcu_assign_pointer(gp, p);
7 struct rcutest1 *p1 = new rcutest1();
8 p1->a = 41;
9 p1->rt.a = 42;
10 p1->rt.b = 43;
11 rcu_assign_pointer(g1p, p1);
12 }
13
14 #ifdef FOO
15 void
16 thread1a_help(rcutest *_Carries_dependency q)
17 {
18 assert(q->a == 42);
19 }
20 #endif
21
22 void
23 thread1b_help(rcutest *_Carries_dependency q)
24 {
25 assert(q->b == 43);
26 }
27
28 void
29 thread1_help(rcutest *_Carries_dependency q)
30 {
31 if (q) {
32 #ifdef FOO
33 thread1a_help(q);
34 #endif
35 thread1b_help(q);
36 }
37 }
38
39 void thread1()
40 {
41 rcutest *_Carries_dependency p = rcu_dereference(gp);
42 thread1_help(p);
43 }
44
45 void thread2()
46 {
47 rcutest1 *_Carries_dependency p1 = rcu_dereference(g1p);
48 thread1_help(&p1->rt);
49 }
\end{verbatim}
}
\caption{Object Modifier: Conditional Compilation of Chain Endpoints}
\label{fig:Object Modifier: Conditional Compilation of Chain Endpoints}
\end{figure}
\begin{figure}[tbp]
{ \scriptsize
\begin{verbatim}
1 void thread0()
2 {
3 rcutest *p = new rcutest();
4 p->a = 42;
5 assert(p->a != 43);
6 rcu_assign_pointer(gp, p);
7 }
8
9 void thread1()
10 {
11 rcutest *_Carries_dependency p = rcu_dereference(gp);
12 if (p) {
13 assert(p->a == 42);
14 spin_lock(&p->lock);
15 p = std::kill_dependency(p);
17 p->a++;
18 spin_unlock(&p->lock);
19 }
20 }
\end{verbatim}
}
\caption{Object Modifier: Handoff to Locking}
\label{fig:Object Modifier: Handoff to Locking}
\end{figure}
Figures~\ref{fig:Object Modifier: Simple Case}--\ref{fig:Object Modifier: Handoff to Locking}
show how object modifiers can be applied to each of the examples
introduced in Section~\ref{sec:Representative Use Cases}.
These changes are straightforward markings of local variables, function
parameters, and return-value types.
Object modifiers therefore easily support the use cases in the Linux
kernel.\footnote{
Give or take a strong distaste for any sort of marking scheme
on the part of numerous Linux-kernel community members.}