aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/sock.h
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2008-01-03 23:46:48 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:00:36 -0500
commit65f7651788e18fadb2fbb7276af935d7871e1803 (patch)
treedcad32d4344d6d11d80061773d9d1dbc9ae92223 /include/net/sock.h
parent571e7682026fd0e25833d103a3eeb74be29bf199 (diff)
[NET]: prot_inuse cleanups and optimizations
1) Cleanups (all functions are prefixed by sock_prot_inuse) sock_prot_inc_use(prot) -> sock_prot_inuse_add(prot,-1) sock_prot_dec_use(prot) -> sock_prot_inuse_add(prot,-1) sock_prot_inuse() -> sock_prot_inuse_get() New functions : sock_prot_inuse_init() and sock_prot_inuse_free() to abstract pcounter use. 2) if CONFIG_PROC_FS=n, we can zap 'inuse' member from "struct proto", since nobody wants to read the inuse value. This saves 1372 bytes on i386/SMP and some cpu cycles. Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sock.h')
-rw-r--r--include/net/sock.h40
1 files changed, 30 insertions, 10 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 3d938f6c6725..786fae858e77 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -548,7 +548,9 @@ struct proto {
548 int (*get_port)(struct sock *sk, unsigned short snum); 548 int (*get_port)(struct sock *sk, unsigned short snum);
549 549
550 /* Keeping track of sockets in use */ 550 /* Keeping track of sockets in use */
551#ifdef CONFIG_PROC_FS
551 struct pcounter inuse; 552 struct pcounter inuse;
553#endif
552 554
553 /* Memory pressure */ 555 /* Memory pressure */
554 void (*enter_memory_pressure)(void); 556 void (*enter_memory_pressure)(void);
@@ -584,9 +586,6 @@ struct proto {
584#endif 586#endif
585}; 587};
586 588
587#define DEFINE_PROTO_INUSE(NAME) DEFINE_PCOUNTER(NAME)
588#define REF_PROTO_INUSE(NAME) PCOUNTER_MEMBER_INITIALIZER(NAME, .inuse)
589
590extern int proto_register(struct proto *prot, int alloc_slab); 589extern int proto_register(struct proto *prot, int alloc_slab);
591extern void proto_unregister(struct proto *prot); 590extern void proto_unregister(struct proto *prot);
592 591
@@ -615,21 +614,42 @@ static inline void sk_refcnt_debug_release(const struct sock *sk)
615#define sk_refcnt_debug_release(sk) do { } while (0) 614#define sk_refcnt_debug_release(sk) do { } while (0)
616#endif /* SOCK_REFCNT_DEBUG */ 615#endif /* SOCK_REFCNT_DEBUG */
617 616
617
618#ifdef CONFIG_PROC_FS
619# define DEFINE_PROTO_INUSE(NAME) DEFINE_PCOUNTER(NAME)
620# define REF_PROTO_INUSE(NAME) PCOUNTER_MEMBER_INITIALIZER(NAME, .inuse)
618/* Called with local bh disabled */ 621/* Called with local bh disabled */
619static __inline__ void sock_prot_inc_use(struct proto *prot) 622static inline void sock_prot_inuse_add(struct proto *prot, int inc)
620{ 623{
621 pcounter_add(&prot->inuse, 1); 624 pcounter_add(&prot->inuse, inc);
622} 625}
623 626static inline int sock_prot_inuse_init(struct proto *proto)
624static __inline__ void sock_prot_dec_use(struct proto *prot)
625{ 627{
626 pcounter_add(&prot->inuse, -1); 628 return pcounter_alloc(&proto->inuse);
627} 629}
628 630static inline int sock_prot_inuse_get(struct proto *proto)
629static __inline__ int sock_prot_inuse(struct proto *proto)
630{ 631{
631 return pcounter_getval(&proto->inuse); 632 return pcounter_getval(&proto->inuse);
632} 633}
634static inline void sock_prot_inuse_free(struct proto *proto)
635{
636 pcounter_free(&proto->inuse);
637}
638#else
639# define DEFINE_PROTO_INUSE(NAME)
640# define REF_PROTO_INUSE(NAME)
641static void inline sock_prot_inuse_add(struct proto *prot, int inc)
642{
643}
644static int inline sock_prot_inuse_init(struct proto *proto)
645{
646 return 0;
647}
648static void inline sock_prot_inuse_free(struct proto *proto)
649{
650}
651#endif
652
633 653
634/* With per-bucket locks this operation is not-atomic, so that 654/* With per-bucket locks this operation is not-atomic, so that
635 * this version is not worse. 655 * this version is not worse.