netprio_cgroup.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * netprio_cgroup.h Control Group Priority set
  4. *
  5. * Authors: Neil Horman <[email protected]>
  6. */
  7. #ifndef _NETPRIO_CGROUP_H
  8. #define _NETPRIO_CGROUP_H
  9. #include <linux/cgroup.h>
  10. #include <linux/hardirq.h>
  11. #include <linux/rcupdate.h>
  12. #if IS_ENABLED(CONFIG_CGROUP_NET_PRIO)
  13. struct netprio_map {
  14. struct rcu_head rcu;
  15. u32 priomap_len;
  16. u32 priomap[];
  17. };
  18. static inline u32 task_netprioidx(struct task_struct *p)
  19. {
  20. struct cgroup_subsys_state *css;
  21. u32 idx;
  22. rcu_read_lock();
  23. css = task_css(p, net_prio_cgrp_id);
  24. idx = css->id;
  25. rcu_read_unlock();
  26. return idx;
  27. }
  28. static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd)
  29. {
  30. if (in_interrupt())
  31. return;
  32. sock_cgroup_set_prioidx(skcd, task_netprioidx(current));
  33. }
  34. #else /* !CONFIG_CGROUP_NET_PRIO */
  35. static inline u32 task_netprioidx(struct task_struct *p)
  36. {
  37. return 0;
  38. }
  39. static inline void sock_update_netprioidx(struct sock_cgroup_data *skcd)
  40. {
  41. }
  42. #endif /* CONFIG_CGROUP_NET_PRIO */
  43. #endif /* _NET_CLS_CGROUP_H */