summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@conectiva.com.br>2004-09-13 14:05:28 -0300
committerArnaldo Carvalho de Melo <acme@conectiva.com.br>2004-09-13 14:05:28 -0300
commitc531454e26c39d77c721ee59d04bbe1dc0cca119 (patch)
tree5d1f1042f0d31e8b1e0bab2da3d27c160f7d8d15 /include
parent664d4fca1f6637331b8d3c7ad51b38e626b0a9ab (diff)
[NET] generalise per protocol slab cache handling
With this patch we get two new slabcaches, for sctp socks, that previously were being allocated on the default, that was tcp[6]_sock, i.e. wasting 288 bytes per sock in the IPv4 case and 256 bytes for the IPv6 version, this is in preparation for DCCP (or any other new protocol :) ). With this in place another nice side effect that is easier to achieve is to get rid of struct sock sk->sk_slab, and instead use sk->sk_prot->slab, saving sizeof(void *) on every struct sock instance, but this unfortunatly has to wait for the conversion of all protocols that use per socket slabcaches to use sk->sk_prot, AF_UNIX is the only one AFAIK, so I'll try to convert it to use sk->sk_prot and then get rid of sk->sk_slab. As for the protocols that don't use per socket slabcaches its just a matter of defaulting to sk_cachep at sk_free time if sk->sk_prot is NULL. [root@qemu ~]# modprobe sctp [root@qemu ~]# grep _sock /proc/slabinfo sctpv6_sock 9 9 864 9 2 : tunables 54 27 0 : sctp_sock 0 0 736 5 1 : tunables 54 27 0 : rawv6_sock 3 6 640 6 1 : tunables 54 27 0 : udpv6_sock 0 0 608 6 1 : tunables 54 27 0 : tcpv6_sock 1 7 1120 7 2 : tunables 24 12 0 : unix_sock 6 10 384 10 1 : tunables 54 27 0 : raw_sock 2 8 480 8 1 : tunables 54 27 0 : udp_sock 0 0 512 7 1 : tunables 54 27 0 : tcp_sock 0 0 1024 4 1 : tunables 54 27 0 : Signed-off-by: Arnaldo Carvalho de Melo <acme@conectiva.com.br> Signed-off-by: David S. Miller <davem@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/ipv6.h4
-rw-r--r--include/net/sctp/sctp.h1
-rw-r--r--include/net/sock.h12
-rw-r--r--include/net/tcp.h3
4 files changed, 17 insertions, 3 deletions
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index ccc084d370cd..55aba976aba6 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -282,6 +282,10 @@ static inline struct raw6_opt * raw6_sk(const struct sock *__sk)
return &((struct raw6_sock *)__sk)->raw6;
}
+struct ipv6_sk_offset {
+ int offset;
+};
+
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
#define __ipv6_only_sock(sk) (inet6_sk(sk)->ipv6only)
#define ipv6_only_sock(sk) ((sk)->sk_family == PF_INET6 && __ipv6_only_sock(sk))
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 17d0f9adce09..053a0ac270f9 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -505,6 +505,7 @@ for (pos = chunk->subh.fwdtsn_hdr->skip;\
/* External references. */
extern struct proto sctp_prot;
+extern struct proto sctpv6_prot;
extern struct proc_dir_entry *proc_net_sctp;
void sctp_put_port(struct sock *sk);
diff --git a/include/net/sock.h b/include/net/sock.h
index 0b94438d5403..e9a5eb5d1840 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -555,6 +555,10 @@ struct proto {
int *sysctl_rmem;
int max_header;
+ kmem_cache_t *slab;
+ int slab_obj_size;
+ void *af_specific;
+
char name[32];
struct {
@@ -563,6 +567,14 @@ struct proto {
} stats[NR_CPUS];
};
+extern int sk_alloc_slab(struct proto *prot, char *name);
+extern void sk_free_slab(struct proto *prot);
+
+static inline void sk_alloc_slab_error(struct proto *proto)
+{
+ printk(KERN_CRIT "%s: Can't create sock SLAB cache!\n", proto->name);
+}
+
static __inline__ void sk_set_owner(struct sock *sk, struct module *owner)
{
/*
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 1a8a317f2bd5..858a0b490378 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -153,9 +153,6 @@ extern struct tcp_hashinfo {
#define tcp_lhash_wait (tcp_hashinfo.__tcp_lhash_wait)
#define tcp_portalloc_lock (tcp_hashinfo.__tcp_portalloc_lock)
-/* SLAB cache for TCP socks */
-extern kmem_cache_t *tcp_sk_cachep;
-
extern kmem_cache_t *tcp_bucket_cachep;
extern struct tcp_bind_bucket *tcp_bucket_create(struct tcp_bind_hashbucket *head,
unsigned short snum);