Skip to content

Commit 5a761eb

Browse files
q2venopsiff
authored andcommitted
tcp: Remove dead code and fields for bhash2.
mainline inclusion from mainline-v6.8-rc1 category: performance Now all sockets including TIME_WAIT are linked to bhash2 using sock_common.skc_bind_node. We no longer use inet_bind2_bucket.deathrow, sock.sk_bind2_node, and inet_timewait_sock.tw_bind2_node. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit 8191792) Change-Id: Ie78b23ea9661ebdb3b8f0a3717d3b34a361ff354 Signed-off-by: Wentao Guan <guanwentao@uniontech.com> [Conflicts: context diff because of KABI] Signed-off-by: Wentao Guan <guanwentao@uniontech.com> Conflicts: include/net/sock.h
1 parent 1c3eec0 commit 5a761eb

5 files changed

Lines changed: 1 addition & 35 deletions

File tree

include/net/inet_hashtables.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ struct inet_bind2_bucket {
107107
struct hlist_node bhash_node;
108108
/* List of sockets hashed to this bucket */
109109
struct hlist_head owners;
110-
/* bhash has twsk in owners, but bhash2 has twsk in
111-
* deathrow not to add a member in struct sock_common.
112-
*/
113-
struct hlist_head deathrow;
114110
};
115111

116112
static inline struct net *ib_net(const struct inet_bind_bucket *ib)

include/net/inet_timewait_sock.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,9 @@ struct inet_timewait_sock {
7474
struct timer_list tw_timer;
7575
struct inet_bind_bucket *tw_tb;
7676
struct inet_bind2_bucket *tw_tb2;
77-
struct hlist_node tw_bind2_node;
7877
};
7978
#define tw_tclass tw_tos
8079

81-
#define twsk_for_each_bound_bhash2(__tw, list) \
82-
hlist_for_each_entry(__tw, list, tw_bind2_node)
83-
8480
static inline struct inet_timewait_sock *inet_twsk(const struct sock *sk)
8581
{
8682
return (struct inet_timewait_sock *)sk;

include/net/sock.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ struct sk_filter;
353353
* @sk_txtime_report_errors: set report errors mode for SO_TXTIME
354354
* @sk_txtime_unused: unused txtime flags
355355
* @ns_tracker: tracker for netns reference
356-
* @sk_bind2_node: bind node in the bhash2 table
357356
*/
358357
struct sock {
359358
/*
@@ -545,7 +544,6 @@ struct sock {
545544
#endif
546545
struct rcu_head sk_rcu;
547546
netns_tracker ns_tracker;
548-
struct hlist_node sk_bind2_node;
549547

550548
DEEPIN_KABI_RESERVE(1)
551549
DEEPIN_KABI_RESERVE(2)
@@ -900,8 +898,6 @@ static inline void sk_add_bind_node(struct sock *sk,
900898
hlist_for_each_entry_safe(__sk, tmp, list, sk_node)
901899
#define sk_for_each_bound(__sk, list) \
902900
hlist_for_each_entry(__sk, list, sk_bind_node)
903-
#define sk_for_each_bound_bhash2(__sk, list) \
904-
hlist_for_each_entry(__sk, list, sk_bind2_node)
905901
#define sk_for_each_bound_safe(__sk, tmp, list) \
906902
hlist_for_each_entry_safe(__sk, tmp, list, sk_bind_node)
907903

net/ipv4/inet_connection_sock.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ static bool inet_bhash2_conflict(const struct sock *sk,
214214
bool relax, bool reuseport_cb_ok,
215215
bool reuseport_ok)
216216
{
217-
struct inet_timewait_sock *tw2;
218217
struct sock *sk2;
219218

220219
sk_for_each_bound(sk2, &tb2->owners) {
@@ -223,25 +222,13 @@ static bool inet_bhash2_conflict(const struct sock *sk,
223222
return true;
224223
}
225224

226-
twsk_for_each_bound_bhash2(tw2, &tb2->deathrow) {
227-
sk2 = (struct sock *)tw2;
228-
229-
if (__inet_bhash2_conflict(sk, sk2, sk_uid, relax,
230-
reuseport_cb_ok, reuseport_ok))
231-
return true;
232-
}
233-
234225
return false;
235226
}
236227

237228
#define sk_for_each_bound_bhash(__sk, __tb2, __tb) \
238229
hlist_for_each_entry(__tb2, &(__tb)->bhash2, bhash_node) \
239230
sk_for_each_bound(sk2, &(__tb2)->owners)
240231

241-
#define twsk_for_each_bound_bhash(__sk, __tb2, __tb) \
242-
hlist_for_each_entry(__tb2, &(__tb)->bhash2, bhash_node) \
243-
sk_for_each_bound_bhash2(sk2, &(__tb2)->deathrow)
244-
245232
/* This should be called only when the tb and tb2 hashbuckets' locks are held */
246233
static int inet_csk_bind_conflict(const struct sock *sk,
247234
const struct inet_bind_bucket *tb,
@@ -281,14 +268,6 @@ static int inet_csk_bind_conflict(const struct sock *sk,
281268
return true;
282269
}
283270

284-
twsk_for_each_bound_bhash(sk2, tb2, tb) {
285-
if (!inet_bind_conflict(sk, sk2, uid, relax, reuseport_cb_ok, reuseport_ok))
286-
continue;
287-
288-
if (inet_rcv_saddr_equal(sk, sk2, true))
289-
return true;
290-
}
291-
292271
return false;
293272
}
294273

net/ipv4/inet_hashtables.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ static void inet_bind2_bucket_init(struct inet_bind2_bucket *tb2,
122122
tb2->rcv_saddr = sk->sk_rcv_saddr;
123123
#endif
124124
INIT_HLIST_HEAD(&tb2->owners);
125-
INIT_HLIST_HEAD(&tb2->deathrow);
126125
hlist_add_head(&tb2->node, &head->chain);
127126
hlist_add_head(&tb2->bhash_node, &tb->bhash2);
128127
}
@@ -144,7 +143,7 @@ struct inet_bind2_bucket *inet_bind2_bucket_create(struct kmem_cache *cachep,
144143
/* Caller must hold hashbucket lock for this tb with local BH disabled */
145144
void inet_bind2_bucket_destroy(struct kmem_cache *cachep, struct inet_bind2_bucket *tb)
146145
{
147-
if (hlist_empty(&tb->owners) && hlist_empty(&tb->deathrow)) {
146+
if (hlist_empty(&tb->owners)) {
148147
__hlist_del(&tb->node);
149148
__hlist_del(&tb->bhash_node);
150149
kmem_cache_free(cachep, tb);

0 commit comments

Comments
 (0)