Skip to content

Commit be43d21

Browse files
committed
net-sysctl: factor-out rpm mask manipulation helpers
jira LE-1907 Rebuild_History Non-Buildable kernel-rt-5.14.0-284.30.1.rt14.315.el9_2 commit-author Paolo Abeni <pabeni@redhat.com> commit 370ca71 Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-rt-5.14.0-284.30.1.rt14.315.el9_2/370ca718.failed Will simplify the following patch. No functional change intended. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit 370ca71) Signed-off-by: Jonathan Maple <jmaple@ciq.com> # Conflicts: # net/core/dev.h
1 parent 407fd14 commit be43d21

File tree

1 file changed

+158
-0
lines changed

1 file changed

+158
-0
lines changed
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
net-sysctl: factor-out rpm mask manipulation helpers
2+
3+
jira LE-1907
4+
Rebuild_History Non-Buildable kernel-rt-5.14.0-284.30.1.rt14.315.el9_2
5+
commit-author Paolo Abeni <pabeni@redhat.com>
6+
commit 370ca718fd5e1fd45ccfdf7a9d76d010f561e607
7+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
8+
Will be included in final tarball splat. Ref for failed cherry-pick at:
9+
ciq/ciq_backports/kernel-rt-5.14.0-284.30.1.rt14.315.el9_2/370ca718.failed
10+
11+
Will simplify the following patch. No functional change
12+
intended.
13+
14+
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
15+
Reviewed-by: Simon Horman <simon.horman@corigine.com>
16+
Reviewed-by: Eric Dumazet <edumazet@google.com>
17+
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
18+
(cherry picked from commit 370ca718fd5e1fd45ccfdf7a9d76d010f561e607)
19+
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
20+
21+
# Conflicts:
22+
# net/core/dev.h
23+
diff --cc net/core/dev.h
24+
index 56b1e7c548af,e075e198092c..000000000000
25+
--- a/net/core/dev.h
26+
+++ b/net/core/dev.h
27+
@@@ -100,4 -112,28 +101,31 @@@ static inline void netif_set_gso_max_se
28+
WRITE_ONCE(dev->gso_max_segs, segs);
29+
}
30+
31+
++<<<<<<< HEAD
32+
++=======
33+
+ static inline void netif_set_gro_max_size(struct net_device *dev,
34+
+ unsigned int size)
35+
+ {
36+
+ /* This pairs with the READ_ONCE() in skb_gro_receive() */
37+
+ WRITE_ONCE(dev->gro_max_size, size);
38+
+ if (size <= GRO_LEGACY_MAX_SIZE)
39+
+ WRITE_ONCE(dev->gro_ipv4_max_size, size);
40+
+ }
41+
+
42+
+ static inline void netif_set_gso_ipv4_max_size(struct net_device *dev,
43+
+ unsigned int size)
44+
+ {
45+
+ /* dev->gso_ipv4_max_size is read locklessly from sk_setup_caps() */
46+
+ WRITE_ONCE(dev->gso_ipv4_max_size, size);
47+
+ }
48+
+
49+
+ static inline void netif_set_gro_ipv4_max_size(struct net_device *dev,
50+
+ unsigned int size)
51+
+ {
52+
+ /* This pairs with the READ_ONCE() in skb_gro_receive() */
53+
+ WRITE_ONCE(dev->gro_ipv4_max_size, size);
54+
+ }
55+
+
56+
+ int rps_cpumask_housekeeping(struct cpumask *mask);
57+
++>>>>>>> 370ca718fd5e (net-sysctl: factor-out rpm mask manipulation helpers)
58+
#endif
59+
* Unmerged path net/core/dev.h
60+
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
61+
index f50619709243..ee928d1710fc 100644
62+
--- a/net/core/net-sysfs.c
63+
+++ b/net/core/net-sysfs.c
64+
@@ -831,42 +831,18 @@ static ssize_t show_rps_map(struct netdev_rx_queue *queue, char *buf)
65+
return len < PAGE_SIZE ? len : -EINVAL;
66+
}
67+
68+
-static ssize_t store_rps_map(struct netdev_rx_queue *queue,
69+
- const char *buf, size_t len)
70+
+static int netdev_rx_queue_set_rps_mask(struct netdev_rx_queue *queue,
71+
+ cpumask_var_t mask)
72+
{
73+
- struct rps_map *old_map, *map;
74+
- cpumask_var_t mask;
75+
- int err, cpu, i;
76+
static DEFINE_MUTEX(rps_map_mutex);
77+
-
78+
- if (!capable(CAP_NET_ADMIN))
79+
- return -EPERM;
80+
-
81+
- if (!alloc_cpumask_var(&mask, GFP_KERNEL))
82+
- return -ENOMEM;
83+
-
84+
- err = bitmap_parse(buf, len, cpumask_bits(mask), nr_cpumask_bits);
85+
- if (err) {
86+
- free_cpumask_var(mask);
87+
- return err;
88+
- }
89+
-
90+
- if (!cpumask_empty(mask)) {
91+
- cpumask_and(mask, mask, housekeeping_cpumask(HK_TYPE_DOMAIN));
92+
- cpumask_and(mask, mask, housekeeping_cpumask(HK_TYPE_WQ));
93+
- if (cpumask_empty(mask)) {
94+
- free_cpumask_var(mask);
95+
- return -EINVAL;
96+
- }
97+
- }
98+
+ struct rps_map *old_map, *map;
99+
+ int cpu, i;
100+
101+
map = kzalloc(max_t(unsigned int,
102+
RPS_MAP_SIZE(cpumask_weight(mask)), L1_CACHE_BYTES),
103+
GFP_KERNEL);
104+
- if (!map) {
105+
- free_cpumask_var(mask);
106+
+ if (!map)
107+
return -ENOMEM;
108+
- }
109+
110+
i = 0;
111+
for_each_cpu_and(cpu, mask, cpu_online_mask)
112+
@@ -893,9 +869,45 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
113+
114+
if (old_map)
115+
kfree_rcu(old_map, rcu);
116+
+ return 0;
117+
+}
118+
119+
+int rps_cpumask_housekeeping(struct cpumask *mask)
120+
+{
121+
+ if (!cpumask_empty(mask)) {
122+
+ cpumask_and(mask, mask, housekeeping_cpumask(HK_TYPE_DOMAIN));
123+
+ cpumask_and(mask, mask, housekeeping_cpumask(HK_TYPE_WQ));
124+
+ if (cpumask_empty(mask))
125+
+ return -EINVAL;
126+
+ }
127+
+ return 0;
128+
+}
129+
+
130+
+static ssize_t store_rps_map(struct netdev_rx_queue *queue,
131+
+ const char *buf, size_t len)
132+
+{
133+
+ cpumask_var_t mask;
134+
+ int err;
135+
+
136+
+ if (!capable(CAP_NET_ADMIN))
137+
+ return -EPERM;
138+
+
139+
+ if (!alloc_cpumask_var(&mask, GFP_KERNEL))
140+
+ return -ENOMEM;
141+
+
142+
+ err = bitmap_parse(buf, len, cpumask_bits(mask), nr_cpumask_bits);
143+
+ if (err)
144+
+ goto out;
145+
+
146+
+ err = rps_cpumask_housekeeping(mask);
147+
+ if (err)
148+
+ goto out;
149+
+
150+
+ err = netdev_rx_queue_set_rps_mask(queue, mask);
151+
+
152+
+out:
153+
free_cpumask_var(mask);
154+
- return len;
155+
+ return err ? : len;
156+
}
157+
158+
static ssize_t show_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue,

0 commit comments

Comments
 (0)