Skip to content

Commit 9305cfa

Browse files
xemuldavem330
authored andcommitted
[AF_UNIX]: Make unix_tot_inflight counter non-atomic
This counter is _always_ modified under the unix_gc_lock spinlock, so its atomicity can be provided w/o additional efforts. Signed-off-by: Pavel Emelyanov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8032b46 commit 9305cfa

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

include/net/af_unix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern void unix_gc(void);
1212

1313
#define UNIX_HASH_SIZE 256
1414

15-
extern atomic_t unix_tot_inflight;
15+
extern unsigned int unix_tot_inflight;
1616

1717
struct unix_address {
1818
atomic_t refcnt;

net/unix/af_unix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ static int unix_release_sock (struct sock *sk, int embrion)
457457
* What the above comment does talk about? --ANK(980817)
458458
*/
459459

460-
if (atomic_read(&unix_tot_inflight))
460+
if (unix_tot_inflight)
461461
unix_gc(); /* Garbage collect fds */
462462

463463
return 0;

net/unix/garbage.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static LIST_HEAD(gc_inflight_list);
9292
static LIST_HEAD(gc_candidates);
9393
static DEFINE_SPINLOCK(unix_gc_lock);
9494

95-
atomic_t unix_tot_inflight = ATOMIC_INIT(0);
95+
unsigned int unix_tot_inflight;
9696

9797

9898
static struct sock *unix_get_socket(struct file *filp)
@@ -133,7 +133,7 @@ void unix_inflight(struct file *fp)
133133
} else {
134134
BUG_ON(list_empty(&u->link));
135135
}
136-
atomic_inc(&unix_tot_inflight);
136+
unix_tot_inflight++;
137137
spin_unlock(&unix_gc_lock);
138138
}
139139
}
@@ -147,7 +147,7 @@ void unix_notinflight(struct file *fp)
147147
BUG_ON(list_empty(&u->link));
148148
if (atomic_dec_and_test(&u->inflight))
149149
list_del_init(&u->link);
150-
atomic_dec(&unix_tot_inflight);
150+
unix_tot_inflight--;
151151
spin_unlock(&unix_gc_lock);
152152
}
153153
}

0 commit comments

Comments
 (0)