aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/netprio_cgroup.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/netprio_cgroup.h')
-rw-r--r--include/net/netprio_cgroup.h48
1 files changed, 40 insertions, 8 deletions
diff --git a/include/net/netprio_cgroup.h b/include/net/netprio_cgroup.h
index 7b2d43139c8e..d58fdec47597 100644
--- a/include/net/netprio_cgroup.h
+++ b/include/net/netprio_cgroup.h
@@ -37,19 +37,51 @@ extern int net_prio_subsys_id;
37 37
38extern void sock_update_netprioidx(struct sock *sk); 38extern void sock_update_netprioidx(struct sock *sk);
39 39
40static inline struct cgroup_netprio_state 40#if IS_BUILTIN(CONFIG_NETPRIO_CGROUP)
41 *task_netprio_state(struct task_struct *p) 41
42static inline u32 task_netprioidx(struct task_struct *p)
42{ 43{
43#if IS_ENABLED(CONFIG_NETPRIO_CGROUP) 44 struct cgroup_netprio_state *state;
44 return container_of(task_subsys_state(p, net_prio_subsys_id), 45 u32 idx;
45 struct cgroup_netprio_state, css); 46
46#else 47 rcu_read_lock();
47 return NULL; 48 state = container_of(task_subsys_state(p, net_prio_subsys_id),
48#endif 49 struct cgroup_netprio_state, css);
50 idx = state->prioidx;
51 rcu_read_unlock();
52 return idx;
53}
54
55#elif IS_MODULE(CONFIG_NETPRIO_CGROUP)
56
57static inline u32 task_netprioidx(struct task_struct *p)
58{
59 struct cgroup_netprio_state *state;
60 int subsys_id;
61 u32 idx = 0;
62
63 rcu_read_lock();
64 subsys_id = rcu_dereference_index_check(net_prio_subsys_id,
65 rcu_read_lock_held());
66 if (subsys_id >= 0) {
67 state = container_of(task_subsys_state(p, subsys_id),
68 struct cgroup_netprio_state, css);
69 idx = state->prioidx;
70 }
71 rcu_read_unlock();
72 return idx;
49} 73}
50 74
51#else 75#else
52 76
77static inline u32 task_netprioidx(struct task_struct *p)
78{
79 return 0;
80}
81
82#endif /* CONFIG_NETPRIO_CGROUP */
83
84#else
53#define sock_update_netprioidx(sk) 85#define sock_update_netprioidx(sk)
54#endif 86#endif
55 87