netprio_cgroup.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. struct cgroup_netprio_state {
  25. struct cgroup_subsys_state css;
  26. };
  27. extern void sock_update_netprioidx(struct sock *sk, struct task_struct *task);
  28. #if IS_BUILTIN(CONFIG_NETPRIO_CGROUP)
  29. static inline u32 task_netprioidx(struct task_struct *p)
  30. {
  31. struct cgroup_subsys_state *css;
  32. u32 idx;
  33. rcu_read_lock();
  34. css = task_subsys_state(p, net_prio_subsys_id);
  35. idx = css->cgroup->id;
  36. rcu_read_unlock();
  37. return idx;
  38. }
  39. #elif IS_MODULE(CONFIG_NETPRIO_CGROUP)
  40. static inline u32 task_netprioidx(struct task_struct *p)
  41. {
  42. struct cgroup_subsys_state *css;
  43. u32 idx = 0;
  44. rcu_read_lock();
  45. css = task_subsys_state(p, net_prio_subsys_id);
  46. if (css)
  47. idx = css->cgroup->id;
  48. rcu_read_unlock();
  49. return idx;
  50. }
  51. #endif
  52. #else /* !CONFIG_NETPRIO_CGROUP */
  53. static inline u32 task_netprioidx(struct task_struct *p)
  54. {
  55. return 0;
  56. }
  57. #define sock_update_netprioidx(sk, task)
  58. #endif /* CONFIG_NETPRIO_CGROUP */
  59. #endif /* _NET_CLS_CGROUP_H */