@@ -192,8 +192,11 @@ void wait_for_unix_gc(void)
192
192
{
193
193
/* If number of inflight sockets is insane,
194
194
* force a garbage collect right now.
195
+ * Paired with the WRITE_ONCE() in unix_inflight(),
196
+ * unix_notinflight() and gc_in_progress().
195
197
*/
196
- if (unix_tot_inflight > UNIX_INFLIGHT_TRIGGER_GC && !gc_in_progress )
198
+ if (READ_ONCE (unix_tot_inflight ) > UNIX_INFLIGHT_TRIGGER_GC &&
199
+ !READ_ONCE (gc_in_progress ))
197
200
unix_gc ();
198
201
wait_event (unix_gc_wait , gc_in_progress == false);
199
202
}
@@ -213,7 +216,9 @@ void unix_gc(void)
213
216
if (gc_in_progress )
214
217
goto out ;
215
218
216
- gc_in_progress = true;
219
+ /* Paired with READ_ONCE() in wait_for_unix_gc(). */
220
+ WRITE_ONCE (gc_in_progress , true);
221
+
217
222
/* First, select candidates for garbage collection. Only
218
223
* in-flight sockets are considered, and from those only ones
219
224
* which don't have any external reference.
@@ -299,7 +304,10 @@ void unix_gc(void)
299
304
300
305
/* All candidates should have been detached by now. */
301
306
BUG_ON (!list_empty (& gc_candidates ));
302
- gc_in_progress = false;
307
+
308
+ /* Paired with READ_ONCE() in wait_for_unix_gc(). */
309
+ WRITE_ONCE (gc_in_progress , false);
310
+
303
311
wake_up (& unix_gc_wait );
304
312
305
313
out :
0 commit comments