Skip to content

Commit

Permalink
[AF_UNIX]: Make unix_tot_inflight counter non-atomic
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
xemul authored and davem330 committed Nov 11, 2007
1 parent 8032b46 commit 9305cfa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/net/af_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern void unix_gc(void);

#define UNIX_HASH_SIZE 256

extern atomic_t unix_tot_inflight;
extern unsigned int unix_tot_inflight;

struct unix_address {
atomic_t refcnt;
Expand Down
2 changes: 1 addition & 1 deletion net/unix/af_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ static int unix_release_sock (struct sock *sk, int embrion)
* What the above comment does talk about? --ANK(980817)
*/

if (atomic_read(&unix_tot_inflight))
if (unix_tot_inflight)
unix_gc(); /* Garbage collect fds */

return 0;
Expand Down
6 changes: 3 additions & 3 deletions net/unix/garbage.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static LIST_HEAD(gc_inflight_list);
static LIST_HEAD(gc_candidates);
static DEFINE_SPINLOCK(unix_gc_lock);

atomic_t unix_tot_inflight = ATOMIC_INIT(0);
unsigned int unix_tot_inflight;


static struct sock *unix_get_socket(struct file *filp)
Expand Down Expand Up @@ -133,7 +133,7 @@ void unix_inflight(struct file *fp)
} else {
BUG_ON(list_empty(&u->link));
}
atomic_inc(&unix_tot_inflight);
unix_tot_inflight++;
spin_unlock(&unix_gc_lock);
}
}
Expand All @@ -147,7 +147,7 @@ void unix_notinflight(struct file *fp)
BUG_ON(list_empty(&u->link));
if (atomic_dec_and_test(&u->inflight))
list_del_init(&u->link);
atomic_dec(&unix_tot_inflight);
unix_tot_inflight--;
spin_unlock(&unix_gc_lock);
}
}
Expand Down

0 comments on commit 9305cfa

Please sign in to comment.