netprio_cgroup.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_CGROUP_NET_PRIO)
  19. struct netprio_map {
  20. struct rcu_head rcu;
  21. u32 priomap_len;
  22. u32 priomap[];
  23. };
  24. static inline u32 task_netprioidx(struct task_struct *p)
  25. {
  26. struct cgroup_subsys_state *css;
  27. u32 idx;
  28. rcu_read_lock();
  29. css = task_css(p, net_prio_cgrp_id);
  30. idx = css->cgroup->id;
  31. rcu_read_unlock();
  32. return idx;
  33. }
  34. static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd)
  35. {
  36. if (in_interrupt())
  37. return;
  38. sock_cgroup_set_prioidx(skcd, task_netprioidx(current));
  39. }
  40. #else /* !CONFIG_CGROUP_NET_PRIO */
  41. static inline u32 task_netprioidx(struct task_struct *p)
  42. {
  43. return 0;
  44. }
  45. static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd)
  46. {
  47. }
  48. #endif /* CONFIG_CGROUP_NET_PRIO */
  49. #endif /* _NET_CLS_CGROUP_H */