Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * netprio_cgroup.h         Control Group Priority set
0004  *
0005  * Authors: Neil Horman <nhorman@tuxdriver.com>
0006  */
0007 
0008 #ifndef _NETPRIO_CGROUP_H
0009 #define _NETPRIO_CGROUP_H
0010 
0011 #include <linux/cgroup.h>
0012 #include <linux/hardirq.h>
0013 #include <linux/rcupdate.h>
0014 
0015 #if IS_ENABLED(CONFIG_CGROUP_NET_PRIO)
0016 struct netprio_map {
0017     struct rcu_head rcu;
0018     u32 priomap_len;
0019     u32 priomap[];
0020 };
0021 
0022 static inline u32 task_netprioidx(struct task_struct *p)
0023 {
0024     struct cgroup_subsys_state *css;
0025     u32 idx;
0026 
0027     rcu_read_lock();
0028     css = task_css(p, net_prio_cgrp_id);
0029     idx = css->id;
0030     rcu_read_unlock();
0031     return idx;
0032 }
0033 
0034 static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd)
0035 {
0036     if (in_interrupt())
0037         return;
0038 
0039     sock_cgroup_set_prioidx(skcd, task_netprioidx(current));
0040 }
0041 
0042 #else /* !CONFIG_CGROUP_NET_PRIO */
0043 
0044 static inline u32 task_netprioidx(struct task_struct *p)
0045 {
0046     return 0;
0047 }
0048 
0049 static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd)
0050 {
0051 }
0052 
0053 #endif /* CONFIG_CGROUP_NET_PRIO */
0054 #endif  /* _NET_CLS_CGROUP_H */