Skip to contentSkip to conversation

make ipx use a slab cache for its socks

PATCH In review Arnaldo Carvalho de Melo 2 participants 2 messages Jan 19, 2005

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make ipx use a slab cache for its socks

Hi David,

This is the start of a series of patches converting the legacy
protocols to use slab caches, this is needed in preparation to introduce struct connection_sock, most of them are trivial and small due to the fact that we have been abstracting away access to the protocols private area with things like {ipx,at,ax25,netrom,rose,etc}_sk(sk), there are more involved cases, namely:

atm:

yesterday I sent a message to Chas explaining the situation (CCed netdev)

ax25 & its upper layer protos (rose, netrom):

I have the bulk of the work done, making it use the same approach used in the inet protos: tcp_sock is a inet_sock is a sock, for ax25 it is netrom/rose is a ax25_sock is a sock, Ralf Baechle is reviewing the patch and seems to be happy with it so far.

bluetooth:

Still have to do further analysis, but it mostly replicates the core infrastructure for registering a proto family, using both slab caches and sk_protinfo, I'm thinking about generalising somewhat inet_register_protosw API style or something along these lines.

All the others (pfkey, decnet, netlink, appletalk, llc, etc) are already converted in my private tree and I'll be sending it as you merge the previous one, starting with this one for IPX.

In the end of this series sk->sk_protinfo will be deleted, the generic sk_cachep will be deleted and all proto families will have private slab caches. So struct sock shrinks a bit again 8)

I didn't benchmarked these changed on a before/after way, but I expect some performance gains like the ones we got when we did the same thing for TCP, AF_UNIX, etc.

After all of this is merged I'll introduce struct connection_sock and move on to the next target, that is to move all proto families to use sk->sk_prot, as the inet protos do today, so as to remove sk->sk_slab and use sk->sk_prot->slab, at this point we can change sk_alloc to have this prototype:

struct sock *sk_alloc(struct proto *prot, int priority, int zero_it);

where today we have this one:

struct sock *sk_alloc(int family, int priority, int zero_it, kmem_cache_t *slab);

because we will be able to get the relevant slab cache from sk->sk_prot->slab, zero_it gets its original semantic, becoming again just a boolean, because we can get the proto sock size from sk->sk_prot->slab_obj_size.

This, in turn... OK, enough "roadmap dumping" for today! 8)

Comments on this course of action will be greatly appreciated.

Ah, this changeset is available at:

bk://kernel.bkbits.net/acme/connection_sock-2.6

Best Regards,

- Arnaldo

===================================================================

[email protected], 2005-01-18 00:45:37-02:00, [email protected]
[IPX] use a private slab cache for socks

Renaming ipx_opt to ipx_sock, tested with mars-nwe/ncpmount.

 include/net/ipx.h   |   13 ++++++++-
 net/ipx/af_ipx.c    |   69 ++++++++++++++++++++++++++--------------------------
 net/ipx/ipx_proc.c  |    4 +--
 net/ipx/ipx_route.c |    2 -
 4 files changed, 49 insertions(+), 39 deletions(-)
include/net/ipx.h +11 -2
diff -Nru a/include/net/ipx.h b/include/net/ipx.h
@@ -90,7 +90,11 @@
 	} last_hop;
 };
 
-struct ipx_opt {
+#include <net/sock.h>
+
+struct ipx_sock {
+	/* struct sock has to be the first member of ipx_sock */
+	struct sock		sk;
 	struct ipx_address	dest_addr;
 	struct ipx_interface	*intrfc;
 	unsigned short		port;
@@ -105,9 +109,14 @@
 	unsigned short		ipx_ncp_conn;
 };
 
-#define ipx_sk(__sk) ((struct ipx_opt *)(__sk)->sk_protinfo)
+static inline struct ipx_sock *ipx_sk(struct sock *sk)
+{
+	return (struct ipx_sock *)sk;
+}
+
 #define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0]))
 #endif
+
 #define IPX_MIN_EPHEMERAL_SOCKET	0x4000
 #define IPX_MAX_EPHEMERAL_SOCKET	0x7fff
 
net/ipx/af_ipx.c +35 -34

153 lines not on this page · raw message

net/ipx/ipx_proc.c +2 -2
diff -Nru a/net/ipx/ipx_proc.c b/net/ipx/ipx_proc.c
@@ -202,7 +202,7 @@
 {
 	struct sock* sk, *next;
 	struct ipx_interface *i;
-	struct ipx_opt *ipxs;
+	struct ipx_sock *ipxs;
 
 	++*pos;
 	if (v == SEQ_START_TOKEN) {
@@ -243,7 +243,7 @@
 static int ipx_seq_socket_show(struct seq_file *seq, void *v)
 {
 	struct sock *s;
-	struct ipx_opt *ipxs;
+	struct ipx_sock *ipxs;
 
 	if (v == SEQ_START_TOKEN) {
 #ifdef CONFIG_IPX_INTERN
net/ipx/ipx_route.c +1 -1
diff -Nru a/net/ipx/ipx_route.c b/net/ipx/ipx_route.c
@@ -172,7 +172,7 @@
 			struct iovec *iov, size_t len, int noblock)
 {
 	struct sk_buff *skb;
-	struct ipx_opt *ipxs = ipx_sk(sk);
+	struct ipx_sock *ipxs = ipx_sk(sk);
 	struct ipx_interface *intrfc;
 	struct ipxhdr *ipx;
 	size_t size;
maintainer
#1 lore raw
Quoted 3 lines · On Wed, 19 Jan 2005 01:45:08 -0200 Arnaldo Carvalho de Melo…

Ah, this changeset is available at:

bk://kernel.bkbits.net/acme/connection_sock-2.6

Sounds great, keep up the good work :-)

I'm having some trouble pulling from your tree at the moment though:

Pull bk://kernel.bkbits.net/acme/connection_sock-2.6
-> file://disk1/BK/net-2.6
ERROR-Can't get read lock on the repository.
pull: remote locked, trying again...