rcu.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Read-Copy Update definitions shared among RCU implementations.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. * Copyright IBM Corporation, 2011
  19. *
  20. * Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
  21. */
  22. #ifndef __LINUX_RCU_H
  23. #define __LINUX_RCU_H
  24. /*
  25. * debug_rcu_head_queue()/debug_rcu_head_unqueue() are used internally
  26. * by call_rcu() and rcu callback execution, and are therefore not part of the
  27. * RCU API. Leaving in rcupdate.h because they are used by all RCU flavors.
  28. */
  29. #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
  30. # define STATE_RCU_HEAD_READY 0
  31. # define STATE_RCU_HEAD_QUEUED 1
  32. extern struct debug_obj_descr rcuhead_debug_descr;
  33. static inline void debug_rcu_head_queue(struct rcu_head *head)
  34. {
  35. WARN_ON_ONCE((unsigned long)head & 0x3);
  36. debug_object_activate(head, &rcuhead_debug_descr);
  37. debug_object_active_state(head, &rcuhead_debug_descr,
  38. STATE_RCU_HEAD_READY,
  39. STATE_RCU_HEAD_QUEUED);
  40. }
  41. static inline void debug_rcu_head_unqueue(struct rcu_head *head)
  42. {
  43. debug_object_active_state(head, &rcuhead_debug_descr,
  44. STATE_RCU_HEAD_QUEUED,
  45. STATE_RCU_HEAD_READY);
  46. debug_object_deactivate(head, &rcuhead_debug_descr);
  47. }
  48. #else /* !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
  49. static inline void debug_rcu_head_queue(struct rcu_head *head)
  50. {
  51. }
  52. static inline void debug_rcu_head_unqueue(struct rcu_head *head)
  53. {
  54. }
  55. #endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
  56. extern void kfree(const void *);
  57. static inline void __rcu_reclaim(struct rcu_head *head)
  58. {
  59. unsigned long offset = (unsigned long)head->func;
  60. if (__is_kfree_rcu_offset(offset)) {
  61. trace_rcu_invoke_kfree_callback(head, offset);
  62. kfree((void *)head - offset);
  63. } else {
  64. trace_rcu_invoke_callback(head);
  65. head->func(head);
  66. }
  67. }
  68. #endif /* __LINUX_RCU_H */