aboutsummaryrefslogtreecommitdiff
path: root/net/unix/garbage.c
diff options
context:
space:
mode:
authorJeferson Oliveira <jroliveira.oliveira301@gmail.com>2022-02-21 13:08:24 +0100
committerJeferson Oliveira <jroliveira.oliveira301@gmail.com>2022-02-21 13:08:36 +0100
commit9b192fc7d0d03c5485644ed0311d5037fee0fa15 (patch)
treed1651900969ca7b9787b7f5434f248df1c29fbd4 /net/unix/garbage.c
parent1904adc0bb37e30c472eccb7bbe5e724d7cc2595 (diff)
parenta09b2d8f61ea0e9ae735c400399b97966a9418d6 (diff)
Merge tag 'v4.4.302' of https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux into r11.1r11.1
This is the 4.4.302 stable release Change-Id: Ic0294f56b50ff2e461e0bee426dd28c25f1e741e
Diffstat (limited to 'net/unix/garbage.c')
-rw-r--r--net/unix/garbage.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index 8bbe1b8e4ff7..4d283e26d816 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -197,8 +197,11 @@ void wait_for_unix_gc(void)
{
/* If number of inflight sockets is insane,
* force a garbage collect right now.
+ * Paired with the WRITE_ONCE() in unix_inflight(),
+ * unix_notinflight() and gc_in_progress().
*/
- if (unix_tot_inflight > UNIX_INFLIGHT_TRIGGER_GC && !gc_in_progress)
+ if (READ_ONCE(unix_tot_inflight) > UNIX_INFLIGHT_TRIGGER_GC &&
+ !READ_ONCE(gc_in_progress))
unix_gc();
wait_event(unix_gc_wait, gc_in_progress == false);
}
@@ -218,7 +221,9 @@ void unix_gc(void)
if (gc_in_progress)
goto out;
- gc_in_progress = true;
+ /* Paired with READ_ONCE() in wait_for_unix_gc(). */
+ WRITE_ONCE(gc_in_progress, true);
+
/* First, select candidates for garbage collection. Only
* in-flight sockets are considered, and from those only ones
* which don't have any external reference.
@@ -304,7 +309,10 @@ void unix_gc(void)
/* All candidates should have been detached by now. */
BUG_ON(!list_empty(&gc_candidates));
- gc_in_progress = false;
+
+ /* Paired with READ_ONCE() in wait_for_unix_gc(). */
+ WRITE_ONCE(gc_in_progress, false);
+
wake_up(&unix_gc_wait);
out: