From: Kuniyuki Iwashima __module_get() in inet_twsk_alloc() was necessary to prevent unloading tw->tw_prot, which is used in inet_twsk_free(). DCCP has gone, and TCP is built-in, so the pair is no longer needed. ULPs also do not need it because * kTLS and XFRM_ESPINTCP restore sk_prot before close() * MPTCP is built-in * SMC uses TCP as is , but using tw_prot without module_get() would be error prone to future ULP addition. Now we can use kfree() without the slab cache pointer thanks to SLUB. Let's use kfree() in inet_twsk_free() and remove 2 atomic ops for each connection. Signed-off-by: Kuniyuki Iwashima --- include/net/inet_timewait_sock.h | 1 - net/ipv4/inet_timewait_sock.c | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index 67a313575780..500a0478370f 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h @@ -48,7 +48,6 @@ struct inet_timewait_sock { #define tw_tx_queue_mapping __tw_common.skc_tx_queue_mapping #define tw_rx_queue_mapping __tw_common.skc_rx_queue_mapping #define tw_hash __tw_common.skc_hash -#define tw_prot __tw_common.skc_prot #define tw_net __tw_common.skc_net #define tw_daddr __tw_common.skc_daddr #define tw_v6_daddr __tw_common.skc_v6_daddr diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index 875ff923a8ed..024463a3e696 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c @@ -73,10 +73,8 @@ static void inet_twsk_kill(struct inet_timewait_sock *tw) void inet_twsk_free(struct inet_timewait_sock *tw) { - struct module *owner = tw->tw_prot->owner; twsk_destructor((struct sock *)tw); - kmem_cache_free(tw->tw_prot->twsk_prot->twsk_slab, tw); - module_put(owner); + kfree(tw); } void inet_twsk_put(struct inet_timewait_sock *tw) @@ -206,7 +204,6 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, tw->tw_hash = sk->sk_hash; tw->tw_ipv6only = 0; tw->tw_transparent = inet_test_bit(TRANSPARENT, sk); - tw->tw_prot = sk->sk_prot_creator; atomic64_set(&tw->tw_cookie, atomic64_read(&sk->sk_cookie)); twsk_net_set(tw, sock_net(sk)); timer_setup(&tw->tw_timer, tw_timer_handler, 0); @@ -216,8 +213,6 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, * timewait socket. */ refcount_set(&tw->tw_refcnt, 0); - - __module_get(tw->tw_prot->owner); } return tw; -- 2.51.0.rc1.193.gad69d77794-goog