thread_info.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  4. *
  5. * Vineetg: Oct 2009
  6. * No need for ARC specific thread_info allocator (kmalloc/free). This is
  7. * anyways one page allocation, thus slab alloc can be short-circuited and
  8. * the generic version (get_free_page) would be loads better.
  9. *
  10. * Sameer Dhavale: Codito Technologies 2004
  11. */
  12. #ifndef _ASM_THREAD_INFO_H
  13. #define _ASM_THREAD_INFO_H
  14. #include <asm/page.h>
  15. #ifdef CONFIG_16KSTACKS
  16. #define THREAD_SIZE_ORDER 1
  17. #else
  18. #define THREAD_SIZE_ORDER 0
  19. #endif
  20. #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
  21. #define THREAD_SHIFT (PAGE_SHIFT << THREAD_SIZE_ORDER)
  22. #ifndef __ASSEMBLY__
  23. #include <linux/thread_info.h>
  24. /*
  25. * low level task data that entry.S needs immediate access to
  26. * - this struct should fit entirely inside of one cache line
  27. * - this struct shares the supervisor stack pages
  28. * - if the contents of this structure are changed, the assembly constants
  29. * must also be changed
  30. */
  31. struct thread_info {
  32. unsigned long flags; /* low level flags */
  33. int preempt_count; /* 0 => preemptable, <0 => BUG */
  34. struct task_struct *task; /* main task structure */
  35. __u32 cpu; /* current CPU */
  36. unsigned long thr_ptr; /* TLS ptr */
  37. };
  38. /*
  39. * macros/functions for gaining access to the thread information structure
  40. *
  41. * preempt_count needs to be 1 initially, until the scheduler is functional.
  42. */
  43. #define INIT_THREAD_INFO(tsk) \
  44. { \
  45. .task = &tsk, \
  46. .flags = 0, \
  47. .cpu = 0, \
  48. .preempt_count = INIT_PREEMPT_COUNT, \
  49. }
  50. static inline __attribute_const__ struct thread_info *current_thread_info(void)
  51. {
  52. register unsigned long sp asm("sp");
  53. return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
  54. }
  55. #endif /* !__ASSEMBLY__ */
  56. /*
  57. * thread information flags
  58. * - these are process state flags that various assembly files may need to
  59. * access
  60. * - pending work-to-be-done flags are in LSW
  61. * - other flags in MSW
  62. */
  63. #define TIF_RESTORE_SIGMASK 0 /* restore sig mask in do_signal() */
  64. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  65. #define TIF_SIGPENDING 2 /* signal pending */
  66. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  67. #define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */
  68. #define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */
  69. #define TIF_SYSCALL_TRACE 15 /* syscall trace active */
  70. /* true if poll_idle() is polling TIF_NEED_RESCHED */
  71. #define TIF_MEMDIE 16
  72. #define TIF_SYSCALL_TRACEPOINT 17 /* syscall tracepoint instrumentation */
  73. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  74. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  75. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  76. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  77. #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
  78. #define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)
  79. #define _TIF_MEMDIE (1<<TIF_MEMDIE)
  80. #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
  81. /* work to do on interrupt/exception return */
  82. #define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
  83. _TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL)
  84. #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT)
  85. /*
  86. * _TIF_ALLWORK_MASK includes SYSCALL_TRACE, but we don't need it.
  87. * SYSCALL_TRACE is anyway separately/unconditionally tested right after a
  88. * syscall, so all that remains to be tested is _TIF_WORK_MASK
  89. */
  90. #endif /* _ASM_THREAD_INFO_H */