@@ -192,8 +192,11 @@ void wait_for_unix_gc(void)
192192{
193193 /* If number of inflight sockets is insane,
194194 * force a garbage collect right now.
195+ * Paired with the WRITE_ONCE() in unix_inflight(),
196+ * unix_notinflight() and gc_in_progress().
195197 */
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 ))
197200 unix_gc ();
198201 wait_event (unix_gc_wait , gc_in_progress == false);
199202}
@@ -213,7 +216,9 @@ void unix_gc(void)
213216 if (gc_in_progress )
214217 goto out ;
215218
216- gc_in_progress = true;
219+ /* Paired with READ_ONCE() in wait_for_unix_gc(). */
220+ WRITE_ONCE (gc_in_progress , true);
221+
217222 /* First, select candidates for garbage collection. Only
218223 * in-flight sockets are considered, and from those only ones
219224 * which don't have any external reference.
@@ -299,7 +304,10 @@ void unix_gc(void)
299304
300305 /* All candidates should have been detached by now. */
301306 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+
303311 wake_up (& unix_gc_wait );
304312
305313 out :
0 commit comments