llc: use sock slab cache
Subsystems (3)
PATCH 9/9 llc: use sock slab cache
David,
The last one in this series, for LLC.
- Arnaldo
===================================================================
[email protected], 2005-01-19 23:07:31-02:00, [email protected]
[LLC] use a private slab cache for socks
Required to get rid of sk_protinfo and to introduce struct connection_sock, also for consistency with other protocol families implementations.
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by David S. Miller <[email protected]>
include/net/llc_conn.h | 13 +++++- net/llc/af_llc.c | 40 +++++++++++++++------ net/llc/llc_c_ac.c | 92 ++++++++++++++++++++++++------------------------- net/llc/llc_c_ev.c | 2 - net/llc/llc_conn.c | 50 +++++++++----------------- net/llc/llc_if.c | 4 +- net/llc/llc_proc.c | 8 ++-- net/llc/llc_sap.c | 2 - 8 files changed, 111 insertions(+), 100 deletions(-)
include/net/llc_conn.h +10 -3
@@ -13,6 +13,7 @@*/ #include <linux/timer.h> #include <net/llc_if.h> +#include <net/sock.h> #include <linux/llc.h> #define LLC_EVENT 1
@@ -28,8 +29,9 @@u16 expire;/* timer expire time */ }; -struct llc_opt { -struct sock *sk;/* sock that has this llc_opt */ +struct llc_sock { +/* struct sock must be the first member of llc_sock */ +struct sock sk;struct sockaddr_llc addr;/* address sock is bound to */ u8 state;/* state of connection */ struct llc_sap *sap;/* pointer to parent SAP */
@@ -75,7 +77,12 @@Used for resending FRMR */ }; -#define llc_sk (__sk) ((struct llc_opt *)(__sk)->sk_protinfo) +static inline struct llc_sock *llc_sk (const struct sock *sk) +{ +return (struct llc_sock *)sk; +} + +extern kmem_cache_t *llc_sk_slab;static __inline__void llc_set_backlog_type (struct sk_buff *skb,char type) {
net/llc/af_llc.c +29 -11
@@ -42,6 +42,8 @@static int llc_ui_wait_for_data (struct sock *sk,int timeout);static int llc_ui_wait_for_busy_core (struct sock *sk,int timeout); +kmem_cache_t *llc_sk_slab; +#if 0 #define dprintk(args...) printk(KERN_DEBUG args)#else
@@ -113,7 +115,7 @@*/ static int llc_ui_send_data (struct sock * sk,struct sk_buff *skb,int noblock) { -struct llc_opt * llc =llc_sk (sk); +struct llc_sock * llc =llc_sk (sk);int rc =0 ;if (llc_data_accept_state (llc->state) || llc->p_flag) {
@@ -169,7 +171,7 @@static int llc_ui_release (struct socket *sock) {struct sock *sk = sock->sk; -struct llc_opt *llc; +struct llc_sock *llc;if (!sk) goto out;
@@ -244,7 +246,7 @@static int llc_ui_autobind (struct socket *sock,struct sockaddr_llc *addr) {struct sock *sk = sock->sk; -struct llc_opt *llc =llc_sk (sk); +struct llc_sock *llc =llc_sk (sk);struct llc_sap *sap;int rc = -EINVAL ;
@@ -293,7 +295,7 @@ {struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr;struct sock *sk = sock->sk; -struct llc_opt *llc =llc_sk (sk); +struct llc_sock *llc =llc_sk (sk);struct llc_sap *sap;int rc = -EINVAL ;
@@ -394,7 +396,7 @@ int addrlen, int flags) {struct sock *sk = sock->sk; -struct llc_opt *llc =llc_sk (sk); +struct llc_sock *llc =llc_sk (sk);struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr;struct net_device *dev;int rc = -EINVAL ;
@@ -571,7 +573,7 @@static int llc_ui_wait_for_busy_core (struct sock *sk,int timeout) {DECLARE_WAITQUEUE (wait, current); -struct llc_opt *llc =llc_sk (sk); +struct llc_sock *llc =llc_sk (sk);int rc;add_wait_queue_exclusive (sk->sk_sleep, &wait);
@@ -612,7 +614,7 @@static int llc_ui_accept (struct socket *sock,struct socket *newsock,int flags) {struct sock *sk = sock->sk, *newsk; -struct llc_opt *llc, *newllc; +struct llc_sock *llc, *newllc;struct sk_buff *skb;int rc = -EOPNOTSUPP ;
@@ -728,7 +730,7 @@ struct msghdr *msg, size_t len) {struct sock *sk = sock->sk; -struct llc_opt *llc =llc_sk (sk); +struct llc_sock *llc =llc_sk (sk);struct sockaddr_llc *addr = (struct sockaddr_llc *)msg->msg_name;int flags = msg->msg_flags;int noblock = flags &MSG_DONTWAIT ;
@@ -819,7 +821,7 @@ {struct sockaddr_llc sllc;struct sock *sk = sock->sk; -struct llc_opt *llc =llc_sk (sk); +struct llc_sock *llc =llc_sk (sk);int rc =0 ;lock_sock (sk);
@@ -883,7 +885,7 @@ char __user *optval, int optlen) {struct sock *sk = sock->sk; -struct llc_opt *llc =llc_sk (sk); +struct llc_sock *llc =llc_sk (sk);int rc = -EINVAL , opt;lock_sock (sk);
@@ -958,7 +960,7 @@ char __user *optval, int __user *optlen) { struct sock *sk = sock->sk; -struct llc_opt *llc =llc_sk (sk); +struct llc_sock *llc =llc_sk (sk);int val =0 , len =0 , rc = -EINVAL ;lock_sock (sk);
@@ -1032,6 +1034,13 @@static int __init llc2_init (void ) {int rc; + + llc_sk_slab =kmem_cache_create ("llc_sock" , +sizeof (struct llc_sock ),0 , +SLAB_HWCACHE_ALIGN ,NULL ,NULL ); + +if (llc_sk_slab ==NULL ) +return -ENOMEM ;llc_build_offset_table ();llc_station_init ();
@@ -1041,7 +1050,11 @@sock_register (&llc_ui_family_ops);llc_add_pack (LLC_DEST_SAP , llc_sap_handler);llc_add_pack (LLC_DEST_CONN , llc_conn_handler); + }else { +kmem_cache_destroy (llc_sk_slab); + llc_sk_slab =NULL ; } +return rc; }
@@ -1052,6 +1065,11 @@llc_remove_pack (LLC_DEST_CONN );sock_unregister (PF_LLC );llc_proc_exit (); + +if (llc_sk_slab !=NULL ) { +kmem_cache_destroy (llc_sk_slab); + llc_sk_slab =NULL ; + } }module_init (llc2_init);
net/llc/llc_c_ac.c +46 -46
368 lines not on this page · raw message
net/llc/llc_c_ev.c +1 -1
@@ -78,7 +78,7 @@u8 nr1, nr2;struct sk_buff *skb;struct llc_pdu_sn *pdu; -struct llc_opt *llc =llc_sk (sk); +struct llc_sock *llc =llc_sk (sk);int rc =0 ;if (llc->dev->flags &IFF_LOOPBACK )
net/llc/llc_conn.c +18 -32
157 lines not on this page · raw message
net/llc/llc_if.c +2 -2
@@ -45,7 +45,7 @@ {struct llc_conn_state_ev *ev;int rc = -ECONNABORTED ; -struct llc_opt *llc =llc_sk (sk); +struct llc_sock *llc =llc_sk (sk);if (llc->state ==LLC_CONN_STATE_ADM ) goto out;
@@ -86,7 +86,7 @@int rc = -EISCONN ;struct llc_addr laddr, daddr;struct sk_buff *skb; -struct llc_opt *llc =llc_sk (sk); +struct llc_sock *llc =llc_sk (sk);struct sock *existing; laddr.lsap = llc->sap->laddr.lsap;
net/llc/llc_proc.c +4 -4
@@ -65,7 +65,7 @@static void *llc_seq_next (struct seq_file *seq,void *v,loff_t *pos) {struct sock * sk, *next; -struct llc_opt *llc; +struct llc_sock *llc;struct llc_sap *sap; ++*pos;
@@ -102,7 +102,7 @@ {if (v && v !=SEQ_START_TOKEN ) {struct sock *sk = v; -struct llc_opt *llc =llc_sk (sk); +struct llc_sock *llc =llc_sk (sk);struct llc_sap *sap = llc->sap;read_unlock_bh (&sap->sk_list.lock);
@@ -113,7 +113,7 @@static int llc_seq_socket_show (struct seq_file *seq,void *v) {struct sock * sk; -struct llc_opt *llc; +struct llc_sock *llc;if (v ==SEQ_START_TOKEN ) { seq_puts(seq, "SKt Mc local_mac_sap remote_mac_sap "
@@ -160,7 +160,7 @@static int llc_seq_core_show (struct seq_file *seq,void *v) {struct sock * sk; -struct llc_opt *llc; +struct llc_sock *llc;if (v ==SEQ_START_TOKEN ) { seq_puts(seq, "Connection list:\n"
net/llc/llc_sap.c +1 -1
@@ -283,7 +283,7 @@read_lock_bh (&sap->sk_list.lock);sk_for_each (rc, node, &sap->sk_list.list) { -struct llc_opt *llc =llc_sk (rc); +struct llc_sock *llc =llc_sk (rc); if (rc->sk_type == SOCK_DGRAM && llc->laddr.lsap == laddr->lsap &&