blob: 604190596cde8c1b2cc719800b32ab98803df41d [file] [log] [blame]
Neil Horman5bc14212011-11-22 05:10:51 +00001/*
2 * netprio_cgroup.h Control Group Priority set
3 *
4 *
5 * Authors: Neil Horman <nhorman@tuxdriver.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 */
13
14#ifndef _NETPRIO_CGROUP_H
15#define _NETPRIO_CGROUP_H
Daniel Borkmann86f85152013-12-29 17:27:11 +010016
Neil Horman5bc14212011-11-22 05:10:51 +000017#include <linux/cgroup.h>
18#include <linux/hardirq.h>
19#include <linux/rcupdate.h>
20
Daniel Borkmann86f85152013-12-29 17:27:11 +010021#if IS_ENABLED(CONFIG_CGROUP_NET_PRIO)
Neil Horman5bc14212011-11-22 05:10:51 +000022struct netprio_map {
23 struct rcu_head rcu;
24 u32 priomap_len;
25 u32 priomap[];
26};
27
Neil Horman2b73bc62012-02-10 05:43:38 +000028static inline u32 task_netprioidx(struct task_struct *p)
Neil Horman5bc14212011-11-22 05:10:51 +000029{
Tejun Heo88d642f2012-11-22 07:32:47 -080030 struct cgroup_subsys_state *css;
Neil Horman2b73bc62012-02-10 05:43:38 +000031 u32 idx;
32
33 rcu_read_lock();
Tejun Heo073219e2014-02-08 10:36:58 -050034 css = task_css(p, net_prio_cgrp_id);
Tejun Heo88d642f2012-11-22 07:32:47 -080035 idx = css->cgroup->id;
Neil Horman2b73bc62012-02-10 05:43:38 +000036 rcu_read_unlock();
37 return idx;
38}
Tejun Heo2a56a1f2015-12-07 17:38:52 -050039
40static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd)
41{
42 if (in_interrupt())
43 return;
44
45 sock_cgroup_set_prioidx(skcd, task_netprioidx(current));
46}
47
Daniel Borkmann86f85152013-12-29 17:27:11 +010048#else /* !CONFIG_CGROUP_NET_PRIO */
Tejun Heo2a56a1f2015-12-07 17:38:52 -050049
Neil Horman2b73bc62012-02-10 05:43:38 +000050static inline u32 task_netprioidx(struct task_struct *p)
51{
52 return 0;
53}
54
Tejun Heo2a56a1f2015-12-07 17:38:52 -050055static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd)
56{
57}
Daniel Wagner51e4e7f2012-09-12 16:12:03 +020058
Daniel Borkmann86f85152013-12-29 17:27:11 +010059#endif /* CONFIG_CGROUP_NET_PRIO */
Neil Horman5bc14212011-11-22 05:10:51 +000060#endif /* _NET_CLS_CGROUP_H */