From b9932c41123ceadc38465fa1d02b2e860cd7e785 Mon Sep 17 00:00:00 2001 From: Michael Blizek Date: Tue, 5 Jan 2010 19:12:37 +0100 Subject: [PATCH] struct conn size optimisation --- net/cor/common.c | 8 +++--- net/cor/cor.h | 70 ++++++++++++++++--------------------------------- net/cor/forward.c | 1 - net/cor/kpacket_parse.c | 4 +-- 4 files changed, 29 insertions(+), 54 deletions(-) diff --git a/net/cor/common.c b/net/cor/common.c index b3dd3d17dd8..e8debb4cf05 100644 --- a/net/cor/common.c +++ b/net/cor/common.c @@ -405,9 +405,6 @@ struct conn* alloc_conn(gfp_t allocflags) rconn->sockstate = SOCKSTATE_CONN; sconn->sockstate = SOCKSTATE_CONN; - spin_lock_init(&(rconn->credit_lock)); - spin_lock_init(&(sconn->credit_lock)); - databuf_init(&(rconn->buf)); databuf_init(&(sconn->buf)); @@ -576,6 +573,11 @@ static int __init cor_common_init(void) printk(KERN_ERR " conn.source: %d", sizeof(c.source)); printk(KERN_ERR " conn.target: %d", sizeof(c.target)); printk(KERN_ERR " conn.target.out: %d", sizeof(c.target.out)); + printk(KERN_ERR " conn.target.buf: %d", sizeof(c.buf)); + + printk(KERN_ERR " mutex: %d", sizeof(struct mutex)); + printk(KERN_ERR " spinlock: %d", sizeof(spinlock_t)); + printk(KERN_ERR " kref: %d", sizeof(struct kref)); conn_slab = kmem_cache_create("cor_conn", sizeof(struct conn), 8, 0, 0); diff --git a/net/cor/cor.h b/net/cor/cor.h index 465357599a4..e9aa8c0f9b1 100644 --- a/net/cor/cor.h +++ b/net/cor/cor.h @@ -323,7 +323,6 @@ struct data_buf_item{ }; struct data_buf{ - struct mutex lock; struct list_head items; struct data_buf_item *lastread; __u64 first_offset; @@ -337,12 +336,6 @@ struct data_buf{ __u32 last_buflen; }; -struct sock_hdr { - /* The first 2 members of connlistener/conn (see sock.c) */ - struct ref_counter refs; - __u8 sockstate; -}; - struct connlistener; struct bindnode{ @@ -354,6 +347,11 @@ struct bindnode{ #define SOCKSTATE_LISTENER 1 #define SOCKSTATE_CONN 2 +struct sock_hdr { + /* The first member of connlistener/conn (see sock.c) */ + __u8 sockstate; +}; + struct connlistener { /* The first member has to be the same as in conn (see sock.c) */ __u8 sockstate; @@ -377,9 +375,7 @@ struct connlistener { struct conn{ /* The first member has to be the same as in connlistener (see sock.c)*/ __u8 sockstate; - struct ref_counter refs; - - + #define SOURCE_NONE 0 #define SOURCE_IN 1 #define SOURCE_SOCK 2 @@ -391,34 +387,20 @@ struct conn{ __u8 sourcetype:4, targettype:4; __u8 isreset; + __u8 qdisc_active; + struct list_head queue_list; + + /* todo: convert to kref */ + struct ref_counter refs; struct mutex rcv_lock; - spinlock_t credit_lock; - - psched_time_t last_rcv_time; - psched_time_t last_snd_time; -// PSCHED_GET_TIME(now); - - __u32 bytes_queued; - __u32 bytes_queued_avg; - /* state */ __u32 credits; - /* credit rate */ __s32 sender_crate; __s32 resp_crate; - /* credit status of the sender/recp (for balancing credits)*/ - __u32 credit_sender; - __u32 credit_recp; - - __u32 avg_snd_cost; - - __u32 avg_rate; - - union{ struct{ struct neighbor *nb; @@ -434,11 +416,10 @@ struct conn{ }in; struct{ + struct list_head cl_list; wait_queue_head_t wait; struct socket *sock; int flags; - - struct list_head cl_list; }sock; }source; @@ -460,13 +441,8 @@ struct conn{ __u32 conn_id; __u32 seqno; - - /* see packet id definition */ - __u8 connected:1; - /*struct sk_buff_head queue;*/ - struct list_head queue_list; - __u8 qdisc_active; + }out; struct{ @@ -507,16 +483,6 @@ struct skb_procstate{ }funcstate; }; -static inline char *cor_pull_skb(struct sk_buff *skb, unsigned int len) -{ - char *ptr = skb_pull(skb, len); - - if(ptr == 0) - return 0; - - return ptr - len; -} - /* common.c */ extern void ref_counter_decr(struct ref_counter *cnt); @@ -702,3 +668,13 @@ static inline void put_u16(char *dst, __u16 value, int convbo) dst[0] = p_value[0]; dst[1] = p_value[1]; } + +static inline char *cor_pull_skb(struct sk_buff *skb, unsigned int len) +{ + char *ptr = skb_pull(skb, len); + + if(ptr == 0) + return 0; + + return ptr - len; +} diff --git a/net/cor/forward.c b/net/cor/forward.c index 0541bb1ad8f..0042f1403e9 100644 --- a/net/cor/forward.c +++ b/net/cor/forward.c @@ -29,7 +29,6 @@ struct kmem_cache *data_buf_item_slab; void databuf_init(struct data_buf *data) { memset(data, 0, sizeof(struct data_buf)); - mutex_init(&(data->lock)); INIT_LIST_HEAD(&(data->items)); } diff --git a/net/cor/kpacket_parse.c b/net/cor/kpacket_parse.c index 1eba8d20089..9533f426681 100644 --- a/net/cor/kpacket_parse.c +++ b/net/cor/kpacket_parse.c @@ -102,14 +102,13 @@ static void parse_conn_success(struct neighbor *nb, struct sk_buff *skb, if (unlikely(unlikely(TARGET_OUT != sconn->targettype) || unlikely(nb != sconn->target.out.nb) || - unlikely(1 == sconn->target.out.connected))) { + unlikely(rconn->target.out.conn_id != 0))) { blacklist_neighbor(nb); return; } rconn->target.out.conn_id = pull_u32(skb, 1); - sconn->target.out.connected = 1; drain_ooo_queue(sconn); } @@ -180,7 +179,6 @@ static void parse_connect(struct neighbor *nb, struct sk_buff *skb) goto err; } rconn->target.out.conn_id = conn_id; - rconn->target.out.connected = 1; send_connect_success(rconn); err: -- 2.11.4.GIT