2019-05-27 14:55:01 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2011-11-22 13:10:51 +08:00
|
|
|
/*
|
|
|
|
* netprio_cgroup.h Control Group Priority set
|
|
|
|
*
|
|
|
|
* Authors: Neil Horman <nhorman@tuxdriver.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETPRIO_CGROUP_H
|
|
|
|
#define _NETPRIO_CGROUP_H
|
2013-12-30 00:27:11 +08:00
|
|
|
|
2011-11-22 13:10:51 +08:00
|
|
|
#include <linux/cgroup.h>
|
|
|
|
#include <linux/hardirq.h>
|
|
|
|
#include <linux/rcupdate.h>
|
|
|
|
|
2013-12-30 00:27:11 +08:00
|
|
|
#if IS_ENABLED(CONFIG_CGROUP_NET_PRIO)
|
2011-11-22 13:10:51 +08:00
|
|
|
struct netprio_map {
|
|
|
|
struct rcu_head rcu;
|
|
|
|
u32 priomap_len;
|
|
|
|
u32 priomap[];
|
|
|
|
};
|
|
|
|
|
2012-02-10 13:43:38 +08:00
|
|
|
static inline u32 task_netprioidx(struct task_struct *p)
|
2011-11-22 13:10:51 +08:00
|
|
|
{
|
2012-11-22 23:32:47 +08:00
|
|
|
struct cgroup_subsys_state *css;
|
2012-02-10 13:43:38 +08:00
|
|
|
u32 idx;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
2014-02-08 23:36:58 +08:00
|
|
|
css = task_css(p, net_prio_cgrp_id);
|
2019-11-05 07:54:29 +08:00
|
|
|
idx = css->id;
|
2012-02-10 13:43:38 +08:00
|
|
|
rcu_read_unlock();
|
|
|
|
return idx;
|
|
|
|
}
|
2015-12-08 06:38:52 +08:00
|
|
|
|
|
|
|
static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd)
|
|
|
|
{
|
|
|
|
if (in_interrupt())
|
|
|
|
return;
|
|
|
|
|
|
|
|
sock_cgroup_set_prioidx(skcd, task_netprioidx(current));
|
|
|
|
}
|
|
|
|
|
2013-12-30 00:27:11 +08:00
|
|
|
#else /* !CONFIG_CGROUP_NET_PRIO */
|
2015-12-08 06:38:52 +08:00
|
|
|
|
2012-02-10 13:43:38 +08:00
|
|
|
static inline u32 task_netprioidx(struct task_struct *p)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-08 06:38:52 +08:00
|
|
|
static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd)
|
|
|
|
{
|
|
|
|
}
|
2012-09-12 22:12:03 +08:00
|
|
|
|
2013-12-30 00:27:11 +08:00
|
|
|
#endif /* CONFIG_CGROUP_NET_PRIO */
|
2011-11-22 13:10:51 +08:00
|
|
|
#endif /* _NET_CLS_CGROUP_H */
|