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

net/sock: Add kernel config SOCK_RX_QUEUE_MAPPING

Use a new config SOCK_RX_QUEUE_MAPPING to compile-in the socket
RX queue field and logic, instead of the XPS config.
This breaks dependency in XPS, and allows selecting it from non-XPS
use cases, as we do in the next patch.

In addition, use the new flag to wrap the logic in sk_rx_queue_get()
and protect access to the sk_rx_queue_mapping field, while keeping
the function exposed unconditionally, just like sk_rx_queue_set()
and sk_rx_queue_clear().

Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Tariq Toukan and committed by
David S. Miller
4e1beecc 3c5a2fd0

+11 -7
+6 -6
include/net/sock.h
··· 226 226 struct hlist_nulls_node skc_nulls_node; 227 227 }; 228 228 unsigned short skc_tx_queue_mapping; 229 - #ifdef CONFIG_XPS 229 + #ifdef CONFIG_SOCK_RX_QUEUE_MAPPING 230 230 unsigned short skc_rx_queue_mapping; 231 231 #endif 232 232 union { ··· 356 356 #define sk_nulls_node __sk_common.skc_nulls_node 357 357 #define sk_refcnt __sk_common.skc_refcnt 358 358 #define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping 359 - #ifdef CONFIG_XPS 359 + #ifdef CONFIG_SOCK_RX_QUEUE_MAPPING 360 360 #define sk_rx_queue_mapping __sk_common.skc_rx_queue_mapping 361 361 #endif 362 362 ··· 1838 1838 1839 1839 static inline void sk_rx_queue_set(struct sock *sk, const struct sk_buff *skb) 1840 1840 { 1841 - #ifdef CONFIG_XPS 1841 + #ifdef CONFIG_SOCK_RX_QUEUE_MAPPING 1842 1842 if (skb_rx_queue_recorded(skb)) { 1843 1843 u16 rx_queue = skb_get_rx_queue(skb); 1844 1844 ··· 1852 1852 1853 1853 static inline void sk_rx_queue_clear(struct sock *sk) 1854 1854 { 1855 - #ifdef CONFIG_XPS 1855 + #ifdef CONFIG_SOCK_RX_QUEUE_MAPPING 1856 1856 sk->sk_rx_queue_mapping = NO_QUEUE_MAPPING; 1857 1857 #endif 1858 1858 } 1859 1859 1860 - #ifdef CONFIG_XPS 1861 1860 static inline int sk_rx_queue_get(const struct sock *sk) 1862 1861 { 1862 + #ifdef CONFIG_SOCK_RX_QUEUE_MAPPING 1863 1863 if (sk && sk->sk_rx_queue_mapping != NO_QUEUE_MAPPING) 1864 1864 return sk->sk_rx_queue_mapping; 1865 + #endif 1865 1866 1866 1867 return -1; 1867 1868 } 1868 - #endif 1869 1869 1870 1870 static inline void sk_set_socket(struct sock *sk, struct socket *sock) 1871 1871 {
+4
net/Kconfig
··· 256 256 select CPU_RMAP 257 257 default y 258 258 259 + config SOCK_RX_QUEUE_MAPPING 260 + bool 261 + 259 262 config XPS 260 263 bool 261 264 depends on SMP 265 + select SOCK_RX_QUEUE_MAPPING 262 266 default y 263 267 264 268 config HWBM
+1 -1
net/core/filter.c
··· 8814 8814 target_size)); 8815 8815 break; 8816 8816 case offsetof(struct bpf_sock, rx_queue_mapping): 8817 - #ifdef CONFIG_XPS 8817 + #ifdef CONFIG_SOCK_RX_QUEUE_MAPPING 8818 8818 *insn++ = BPF_LDX_MEM( 8819 8819 BPF_FIELD_SIZEOF(struct sock, sk_rx_queue_mapping), 8820 8820 si->dst_reg, si->src_reg,