[AF_UNIX]: Make unix_tot_inflight counter non-atomic
authorPavel Emelyanov <xemul@openvz.org>
Sun, 11 Nov 2007 06:06:01 +0000 (22:06 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 11 Nov 2007 06:06:01 +0000 (22:06 -0800)
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 <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/af_unix.h
net/unix/af_unix.c
net/unix/garbage.c

index 0864a775de24462fb962545da1c91b7b56a860ae..a1c805d7f488b7295a335c33de66f495cd5d0e37 100644 (file)
@@ -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;
index 515e7a692f9bf85e263bf5a8752c22f0384595d0..ab9048ac197fc34c8b9216ee338a6299d255ab46 100644 (file)
@@ -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;
index 406b6433e467b4b4cbe697d24ec03f4cfa33e22e..399717ed7b9d6c8b6f918e7abd6e911f798c2a2e 100644 (file)
@@ -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)
@@ -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);
        }
 }
@@ -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);
        }
 }