Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

inet: remove dead inetpeer sequence code

inetpeer sequence numbers are no longer incremented, so no need to
check and flush the tree. The function that increments the sequence
number was already dead code and removed in in "ipv4: remove unused
function" (068a6e18). Remove the code that checks for a change, too.

Verifying that v4_seq and v6_seq are never incremented and thus that
flush_check compares bp->flush_seq to 0 is trivial.

The second part of the change removes flush_check completely even
though bp->flush_seq is exactly !0 once, at initialization. This
change is correct because the time this branch is true is when
bp->root == peer_avl_empty_rcu, in which the branch and
inetpeer_invalidate_tree are a NOOP.

Signed-off-by: Willem de Bruijn <willemb@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Willem de Bruijn and committed by
David S. Miller
a7f26b7e 1923d6e4

-22
-1
include/net/inetpeer.h
··· 61 61 struct inet_peer_base { 62 62 struct inet_peer __rcu *root; 63 63 seqlock_t lock; 64 - u32 flush_seq; 65 64 int total; 66 65 }; 67 66
-21
net/ipv4/inetpeer.c
··· 72 72 { 73 73 bp->root = peer_avl_empty_rcu; 74 74 seqlock_init(&bp->lock); 75 - bp->flush_seq = ~0U; 76 75 bp->total = 0; 77 76 } 78 77 EXPORT_SYMBOL_GPL(inet_peer_base_init); 79 - 80 - static atomic_t v4_seq = ATOMIC_INIT(0); 81 - static atomic_t v6_seq = ATOMIC_INIT(0); 82 - 83 - static atomic_t *inetpeer_seq_ptr(int family) 84 - { 85 - return (family == AF_INET ? &v4_seq : &v6_seq); 86 - } 87 - 88 - static inline void flush_check(struct inet_peer_base *base, int family) 89 - { 90 - atomic_t *fp = inetpeer_seq_ptr(family); 91 - 92 - if (unlikely(base->flush_seq != atomic_read(fp))) { 93 - inetpeer_invalidate_tree(base); 94 - base->flush_seq = atomic_read(fp); 95 - } 96 - } 97 78 98 79 #define PEER_MAXDEPTH 40 /* sufficient for about 2^27 nodes */ 99 80 ··· 424 443 struct inet_peer *p; 425 444 unsigned int sequence; 426 445 int invalidated, gccnt = 0; 427 - 428 - flush_check(base, daddr->family); 429 446 430 447 /* Attempt a lockless lookup first. 431 448 * Because of a concurrent writer, we might not find an existing entry.