[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>
This commit is contained in:
committed by
David S. Miller
parent
571e768202
commit
65f7651788
@ -1913,7 +1913,7 @@ int proto_register(struct proto *prot, int alloc_slab)
|
||||
char *request_sock_slab_name = NULL;
|
||||
char *timewait_sock_slab_name;
|
||||
|
||||
if (pcounter_alloc(&prot->inuse) != 0) {
|
||||
if (sock_prot_inuse_init(prot) != 0) {
|
||||
printk(KERN_CRIT "%s: Can't alloc inuse counters!\n", prot->name);
|
||||
goto out;
|
||||
}
|
||||
@ -1984,7 +1984,7 @@ out_free_sock_slab:
|
||||
kmem_cache_destroy(prot->slab);
|
||||
prot->slab = NULL;
|
||||
out_free_inuse:
|
||||
pcounter_free(&prot->inuse);
|
||||
sock_prot_inuse_free(prot);
|
||||
out:
|
||||
return -ENOBUFS;
|
||||
}
|
||||
@ -1997,7 +1997,7 @@ void proto_unregister(struct proto *prot)
|
||||
list_del(&prot->node);
|
||||
write_unlock(&proto_list_lock);
|
||||
|
||||
pcounter_free(&prot->inuse);
|
||||
sock_prot_inuse_free(prot);
|
||||
|
||||
if (prot->slab != NULL) {
|
||||
kmem_cache_destroy(prot->slab);
|
||||
|
Reference in New Issue
Block a user