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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'rps-misc-changes'

Eric Dumazet says:

====================
rps: misc changes

Minor changes in rps:

skb_flow_limit() is probably unused these days,
and data-races are quite theoretical.
====================

Link: https://patch.msgid.link/20250407163602.170356-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+21 -15
+3 -2
include/net/rps.h
··· 57 57 * meaning we use 32-6=26 bits for the hash. 58 58 */ 59 59 struct rps_sock_flow_table { 60 - u32 mask; 60 + struct rcu_head rcu; 61 + u32 mask; 61 62 62 - u32 ents[] ____cacheline_aligned_in_smp; 63 + u32 ents[] ____cacheline_aligned_in_smp; 63 64 }; 64 65 #define RPS_SOCK_FLOW_TABLE_SIZE(_num) (offsetof(struct rps_sock_flow_table, ents[_num])) 65 66
+7 -4
net/core/dev.c
··· 4953 4953 struct softnet_data *sd = data; 4954 4954 4955 4955 ____napi_schedule(sd, &sd->backlog); 4956 - sd->received_rps++; 4956 + /* Pairs with READ_ONCE() in softnet_seq_show() */ 4957 + WRITE_ONCE(sd->received_rps, sd->received_rps + 1); 4957 4958 } 4958 4959 4959 4960 #endif /* CONFIG_RPS */ ··· 5039 5038 rcu_read_lock(); 5040 5039 fl = rcu_dereference(sd->flow_limit); 5041 5040 if (fl) { 5042 - new_flow = skb_get_hash(skb) & (fl->num_buckets - 1); 5041 + new_flow = hash_32(skb_get_hash(skb), fl->log_buckets); 5043 5042 old_flow = fl->history[fl->history_head]; 5044 5043 fl->history[fl->history_head] = new_flow; 5045 5044 ··· 5050 5049 fl->buckets[old_flow]--; 5051 5050 5052 5051 if (++fl->buckets[new_flow] > (FLOW_LIMIT_HISTORY >> 1)) { 5053 - fl->count++; 5052 + /* Pairs with READ_ONCE() in softnet_seq_show() */ 5053 + WRITE_ONCE(fl->count, fl->count + 1); 5054 5054 rcu_read_unlock(); 5055 5055 return true; 5056 5056 } ··· 7524 7522 */ 7525 7523 if (unlikely(budget <= 0 || 7526 7524 time_after_eq(jiffies, time_limit))) { 7527 - sd->time_squeeze++; 7525 + /* Pairs with READ_ONCE() in softnet_seq_show() */ 7526 + WRITE_ONCE(sd->time_squeeze, sd->time_squeeze + 1); 7528 7527 break; 7529 7528 } 7530 7529 }
+3 -2
net/core/dev.h
··· 15 15 /* Random bits of netdevice that don't need to be exposed */ 16 16 #define FLOW_LIMIT_HISTORY (1 << 7) /* must be ^2 and !overflow buckets */ 17 17 struct sd_flow_limit { 18 - u64 count; 19 - unsigned int num_buckets; 18 + struct rcu_head rcu; 19 + unsigned int count; 20 + u8 log_buckets; 20 21 unsigned int history_head; 21 22 u16 history[FLOW_LIMIT_HISTORY]; 22 23 u8 buckets[];
+5 -4
net/core/net-procfs.c
··· 132 132 133 133 rcu_read_lock(); 134 134 fl = rcu_dereference(sd->flow_limit); 135 + /* Pairs with WRITE_ONCE() in skb_flow_limit() */ 135 136 if (fl) 136 - flow_limit_count = fl->count; 137 + flow_limit_count = READ_ONCE(fl->count); 137 138 rcu_read_unlock(); 138 139 #endif 139 140 ··· 145 144 seq_printf(seq, 146 145 "%08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x " 147 146 "%08x %08x\n", 148 - sd->processed, atomic_read(&sd->dropped), 149 - sd->time_squeeze, 0, 147 + READ_ONCE(sd->processed), atomic_read(&sd->dropped), 148 + READ_ONCE(sd->time_squeeze), 0, 150 149 0, 0, 0, 0, /* was fastroute */ 151 150 0, /* was cpu_collision */ 152 - sd->received_rps, flow_limit_count, 151 + READ_ONCE(sd->received_rps), flow_limit_count, 153 152 input_qlen + process_qlen, (int)seq->index, 154 153 input_qlen, process_qlen); 155 154 return 0;
+3 -3
net/core/sysctl_net_core.c
··· 201 201 if (orig_sock_table) { 202 202 static_branch_dec(&rps_needed); 203 203 static_branch_dec(&rfs_needed); 204 - kvfree_rcu_mightsleep(orig_sock_table); 204 + kvfree_rcu(orig_sock_table, rcu); 205 205 } 206 206 } 207 207 } ··· 239 239 lockdep_is_held(&flow_limit_update_mutex)); 240 240 if (cur && !cpumask_test_cpu(i, mask)) { 241 241 RCU_INIT_POINTER(sd->flow_limit, NULL); 242 - kfree_rcu_mightsleep(cur); 242 + kfree_rcu(cur, rcu); 243 243 } else if (!cur && cpumask_test_cpu(i, mask)) { 244 244 cur = kzalloc_node(len, GFP_KERNEL, 245 245 cpu_to_node(i)); ··· 248 248 ret = -ENOMEM; 249 249 goto write_unlock; 250 250 } 251 - cur->num_buckets = netdev_flow_limit_table_len; 251 + cur->log_buckets = ilog2(netdev_flow_limit_table_len); 252 252 rcu_assign_pointer(sd->flow_limit, cur); 253 253 } 254 254 }