diff options
| author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-09 18:07:57 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-09 18:07:57 -0500 |
| commit | c5b875e354a54e2b5ba24eecae69bf94e025edd5 (patch) | |
| tree | 0446a68d99ad50305ab78835456d9faa62be5948 /include/net/sock.h | |
| parent | eae1920a21b4f87e89cea802e7df39442b119617 (diff) | |
| parent | c3d8d1e30cace31fed6186a4b8c6b1401836d89c (diff) | |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
* 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6: (44 commits)
[NETLINK]: Fix unicast timeouts
[INET]: Remove per bucket rwlock in tcp/dccp ehash table.
[IPVS]: Synchronize closing of Connections
[IPVS]: Bind connections on stanby if the destination exists
[NET]: Remove Documentation/networking/pt.txt
[NET]: Remove Documentation/networking/routing.txt
[NET]: Remove Documentation/networking/ncsa-telnet
[NET]: Remove comx driver docs.
[NET]: Remove Documentation/networking/Configurable
[NET]: Clean proto_(un)register from in-code ifdefs
[IPSEC]: Fix crypto_alloc_comp error checking
[VLAN]: Fix SET_VLAN_INGRESS_PRIORITY_CMD ioctl
[NETNS]: Fix compiler error in net_namespace.c
[TTY]: Use tty_mode_ioctl() in network drivers.
[TTY]: Fix network driver interactions with TCGET/SET calls.
[PKT_SCHED] CLS_U32: Fix endianness problem with u32 classifier hash masks.
[NET]: Removing duplicit #includes
[NET]: Let USB_USBNET always select MII.
[RRUNNER]: Do not muck with sysctl_{r,w}mem_max
[DLM] lowcomms: Do not muck with sysctl_rmem_max.
...
Diffstat (limited to 'include/net/sock.h')
| -rw-r--r-- | include/net/sock.h | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 20de3fa7ae40..5504fb9fa88a 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
| @@ -560,6 +560,14 @@ struct proto { | |||
| 560 | void (*unhash)(struct sock *sk); | 560 | void (*unhash)(struct sock *sk); |
| 561 | int (*get_port)(struct sock *sk, unsigned short snum); | 561 | int (*get_port)(struct sock *sk, unsigned short snum); |
| 562 | 562 | ||
| 563 | #ifdef CONFIG_SMP | ||
| 564 | /* Keeping track of sockets in use */ | ||
| 565 | void (*inuse_add)(struct proto *prot, int inc); | ||
| 566 | int (*inuse_getval)(const struct proto *prot); | ||
| 567 | int *inuse_ptr; | ||
| 568 | #else | ||
| 569 | int inuse; | ||
| 570 | #endif | ||
| 563 | /* Memory pressure */ | 571 | /* Memory pressure */ |
| 564 | void (*enter_memory_pressure)(void); | 572 | void (*enter_memory_pressure)(void); |
| 565 | atomic_t *memory_allocated; /* Current allocated memory. */ | 573 | atomic_t *memory_allocated; /* Current allocated memory. */ |
| @@ -592,12 +600,38 @@ struct proto { | |||
| 592 | #ifdef SOCK_REFCNT_DEBUG | 600 | #ifdef SOCK_REFCNT_DEBUG |
| 593 | atomic_t socks; | 601 | atomic_t socks; |
| 594 | #endif | 602 | #endif |
| 595 | struct { | ||
| 596 | int inuse; | ||
| 597 | u8 __pad[SMP_CACHE_BYTES - sizeof(int)]; | ||
| 598 | } stats[NR_CPUS]; | ||
| 599 | }; | 603 | }; |
| 600 | 604 | ||
| 605 | /* | ||
| 606 | * Special macros to let protos use a fast version of inuse{get|add} | ||
| 607 | * using a static percpu variable per proto instead of an allocated one, | ||
| 608 | * saving one dereference. | ||
| 609 | * This might be changed if/when dynamic percpu vars become fast. | ||
| 610 | */ | ||
| 611 | #ifdef CONFIG_SMP | ||
| 612 | # define DEFINE_PROTO_INUSE(NAME) \ | ||
| 613 | static DEFINE_PER_CPU(int, NAME##_inuse); \ | ||
| 614 | static void NAME##_inuse_add(struct proto *prot, int inc) \ | ||
| 615 | { \ | ||
| 616 | __get_cpu_var(NAME##_inuse) += inc; \ | ||
| 617 | } \ | ||
| 618 | \ | ||
| 619 | static int NAME##_inuse_getval(const struct proto *prot)\ | ||
| 620 | { \ | ||
| 621 | int res = 0, cpu; \ | ||
| 622 | \ | ||
| 623 | for_each_possible_cpu(cpu) \ | ||
| 624 | res += per_cpu(NAME##_inuse, cpu); \ | ||
| 625 | return res; \ | ||
| 626 | } | ||
| 627 | # define REF_PROTO_INUSE(NAME) \ | ||
| 628 | .inuse_add = NAME##_inuse_add, \ | ||
| 629 | .inuse_getval = NAME##_inuse_getval, | ||
| 630 | #else | ||
| 631 | # define DEFINE_PROTO_INUSE(NAME) | ||
| 632 | # define REF_PROTO_INUSE(NAME) | ||
| 633 | #endif | ||
| 634 | |||
| 601 | extern int proto_register(struct proto *prot, int alloc_slab); | 635 | extern int proto_register(struct proto *prot, int alloc_slab); |
| 602 | extern void proto_unregister(struct proto *prot); | 636 | extern void proto_unregister(struct proto *prot); |
| 603 | 637 | ||
| @@ -629,12 +663,29 @@ static inline void sk_refcnt_debug_release(const struct sock *sk) | |||
| 629 | /* Called with local bh disabled */ | 663 | /* Called with local bh disabled */ |
| 630 | static __inline__ void sock_prot_inc_use(struct proto *prot) | 664 | static __inline__ void sock_prot_inc_use(struct proto *prot) |
| 631 | { | 665 | { |
| 632 | prot->stats[smp_processor_id()].inuse++; | 666 | #ifdef CONFIG_SMP |
| 667 | prot->inuse_add(prot, 1); | ||
| 668 | #else | ||
| 669 | prot->inuse++; | ||
| 670 | #endif | ||
| 633 | } | 671 | } |
| 634 | 672 | ||
| 635 | static __inline__ void sock_prot_dec_use(struct proto *prot) | 673 | static __inline__ void sock_prot_dec_use(struct proto *prot) |
| 636 | { | 674 | { |
| 637 | prot->stats[smp_processor_id()].inuse--; | 675 | #ifdef CONFIG_SMP |
| 676 | prot->inuse_add(prot, -1); | ||
| 677 | #else | ||
| 678 | prot->inuse--; | ||
| 679 | #endif | ||
| 680 | } | ||
| 681 | |||
| 682 | static __inline__ int sock_prot_inuse(struct proto *proto) | ||
| 683 | { | ||
| 684 | #ifdef CONFIG_SMP | ||
| 685 | return proto->inuse_getval(proto); | ||
| 686 | #else | ||
| 687 | return proto->inuse; | ||
| 688 | #endif | ||
| 638 | } | 689 | } |
| 639 | 690 | ||
| 640 | /* With per-bucket locks this operation is not-atomic, so that | 691 | /* With per-bucket locks this operation is not-atomic, so that |
