netprio_cgroup.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  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. #ifndef _NETPRIO_CGROUP_H
  14. #define _NETPRIO_CGROUP_H
  15. #include <linux/cgroup.h>
  16. #include <linux/hardirq.h>
  17. #include <linux/rcupdate.h>
  18. #if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
  19. struct netprio_map {
  20. struct rcu_head rcu;
  21. u32 priomap_len;
  22. u32 priomap[];
  23. };
  24. void sock_update_netprioidx(struct sock *sk);
  25. #if IS_BUILTIN(CONFIG_NETPRIO_CGROUP)
  26. static inline u32 task_netprioidx(struct task_struct *p)
  27. {
  28. struct cgroup_subsys_state *css;
  29. u32 idx;
  30. rcu_read_lock();
  31. css = task_css(p, net_prio_subsys_id);
  32. idx = css->cgroup->id;
  33. rcu_read_unlock();
  34. return idx;
  35. }
  36. #elif IS_MODULE(CONFIG_NETPRIO_CGROUP)
  37. static inline u32 task_netprioidx(struct task_struct *p)
  38. {
  39. struct cgroup_subsys_state *css;
  40. u32 idx = 0;
  41. rcu_read_lock();
  42. css = task_css(p, net_prio_subsys_id);
  43. if (css)
  44. idx = css->cgroup->id;
  45. rcu_read_unlock();
  46. return idx;
  47. }
  48. #endif
  49. #else /* !CONFIG_NETPRIO_CGROUP */
  50. static inline u32 task_netprioidx(struct task_struct *p)
  51. {
  52. return 0;
  53. }
  54. #define sock_update_netprioidx(sk)
  55. #endif /* CONFIG_NETPRIO_CGROUP */
  56. #endif /* _NET_CLS_CGROUP_H */