Skip to content

Commit af63633

Browse files
committed
cgroup: make CONFIG_CGROUP_NET_PRIO bool and drop unnecessary init_netclassid_cgroup()
net_prio is the only cgroup which is allowed to be built as a module. The savings from allowing one controller to be built as a module are tiny especially given that cgroup module support itself adds quite a bit of complexity. Given that none of other controllers has much chance of being made a module and that we're unlikely to add new modular controllers, the added complexity is simply not justifiable. As a first step to drop cgroup module support, this patch changes the config option to bool from tristate and drops module related code from it. Also, while an earlier commit fe1217c ("net: net_cls: move cgroupfs classid handling into core") dropped module support from net_cls cgroup, it retained a call to cgroup_load_subsys(), which is noop for built-in controllers. Drop it along with init_netclassid_cgroup(). v2: Removed modular version of task_netprioidx() in include/net/netprio_cgroup.h as suggested by Li Zefan. v3: Rebased on top of fe1217c ("net: net_cls: move cgroupfs classid handling into core"). net_cls cgroup part is mostly dropped except for removal of init_netclassid_cgroup(). Signed-off-by: Tejun Heo <[email protected]> Acked-by: Neil Horman <[email protected]> Acked-by: "David S. Miller" <[email protected]> Acked-by: Li Zefan <[email protected]> Cc: Thomas Graf <[email protected]>
1 parent 38dbfb5 commit af63633

File tree

4 files changed

+3
-52
lines changed

4 files changed

+3
-52
lines changed

include/net/netprio_cgroup.h

-15
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ struct netprio_map {
2727

2828
void sock_update_netprioidx(struct sock *sk);
2929

30-
#if IS_BUILTIN(CONFIG_CGROUP_NET_PRIO)
3130
static inline u32 task_netprioidx(struct task_struct *p)
3231
{
3332
struct cgroup_subsys_state *css;
@@ -39,20 +38,6 @@ static inline u32 task_netprioidx(struct task_struct *p)
3938
rcu_read_unlock();
4039
return idx;
4140
}
42-
#elif IS_MODULE(CONFIG_CGROUP_NET_PRIO)
43-
static inline u32 task_netprioidx(struct task_struct *p)
44-
{
45-
struct cgroup_subsys_state *css;
46-
u32 idx = 0;
47-
48-
rcu_read_lock();
49-
css = task_css(p, net_prio_subsys_id);
50-
if (css)
51-
idx = css->cgroup->id;
52-
rcu_read_unlock();
53-
return idx;
54-
}
55-
#endif
5641
#else /* !CONFIG_CGROUP_NET_PRIO */
5742
static inline u32 task_netprioidx(struct task_struct *p)
5843
{

net/Kconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ config XPS
239239
default y
240240

241241
config CGROUP_NET_PRIO
242-
tristate "Network priority cgroup"
242+
bool "Network priority cgroup"
243243
depends on CGROUPS
244244
---help---
245245
Cgroup subsystem for use in assigning processes to network priorities on

net/core/netclassid_cgroup.c

-6
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,3 @@ struct cgroup_subsys net_cls_subsys = {
112112
.base_cftypes = ss_files,
113113
.module = THIS_MODULE,
114114
};
115-
116-
static int __init init_netclassid_cgroup(void)
117-
{
118-
return cgroup_load_subsys(&net_cls_subsys);
119-
}
120-
__initcall(init_netclassid_cgroup);

net/core/netprio_cgroup.c

+2-30
Original file line numberDiff line numberDiff line change
@@ -283,37 +283,9 @@ static struct notifier_block netprio_device_notifier = {
283283

284284
static int __init init_cgroup_netprio(void)
285285
{
286-
int ret;
287-
288-
ret = cgroup_load_subsys(&net_prio_subsys);
289-
if (ret)
290-
goto out;
291-
292286
register_netdevice_notifier(&netprio_device_notifier);
293-
294-
out:
295-
return ret;
296-
}
297-
298-
static void __exit exit_cgroup_netprio(void)
299-
{
300-
struct netprio_map *old;
301-
struct net_device *dev;
302-
303-
unregister_netdevice_notifier(&netprio_device_notifier);
304-
305-
cgroup_unload_subsys(&net_prio_subsys);
306-
307-
rtnl_lock();
308-
for_each_netdev(&init_net, dev) {
309-
old = rtnl_dereference(dev->priomap);
310-
RCU_INIT_POINTER(dev->priomap, NULL);
311-
if (old)
312-
kfree_rcu(old, rcu);
313-
}
314-
rtnl_unlock();
287+
return 0;
315288
}
316289

317-
module_init(init_cgroup_netprio);
318-
module_exit(exit_cgroup_netprio);
290+
subsys_initcall(init_cgroup_netprio);
319291
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)