79 |
79 |
80 // SMR Support for the Threads class. |
80 // SMR Support for the Threads class. |
81 // |
81 // |
82 class ThreadsSMRSupport : AllStatic { |
82 class ThreadsSMRSupport : AllStatic { |
83 // The coordination between ThreadsSMRSupport::release_stable_list() and |
83 // The coordination between ThreadsSMRSupport::release_stable_list() and |
84 // ThreadsSMRSupport::smr_delete() uses the smr_delete_lock in order to |
84 // ThreadsSMRSupport::smr_delete() uses the delete_lock in order to |
85 // reduce the traffic on the Threads_lock. |
85 // reduce the traffic on the Threads_lock. |
86 static Monitor* _smr_delete_lock; |
86 static Monitor* _delete_lock; |
87 // The '_cnt', '_max' and '_times" fields are enabled via |
87 // The '_cnt', '_max' and '_times" fields are enabled via |
88 // -XX:+EnableThreadSMRStatistics (see thread.cpp for a |
88 // -XX:+EnableThreadSMRStatistics (see thread.cpp for a |
89 // description about each field): |
89 // description about each field): |
90 static uint _smr_delete_lock_wait_cnt; |
90 static uint _delete_lock_wait_cnt; |
91 static uint _smr_delete_lock_wait_max; |
91 static uint _delete_lock_wait_max; |
92 // The smr_delete_notify flag is used for proper double-check |
92 // The delete_notify flag is used for proper double-check |
93 // locking in order to reduce the traffic on the smr_delete_lock. |
93 // locking in order to reduce the traffic on the system wide |
94 static volatile uint _smr_delete_notify; |
94 // Thread-SMR delete_lock. |
95 static volatile uint _smr_deleted_thread_cnt; |
95 static volatile uint _delete_notify; |
96 static volatile uint _smr_deleted_thread_time_max; |
96 static volatile uint _deleted_thread_cnt; |
97 static volatile uint _smr_deleted_thread_times; |
97 static volatile uint _deleted_thread_time_max; |
98 static ThreadsList* volatile _smr_java_thread_list; |
98 static volatile uint _deleted_thread_times; |
99 static uint64_t _smr_java_thread_list_alloc_cnt; |
99 static ThreadsList* volatile _java_thread_list; |
100 static uint64_t _smr_java_thread_list_free_cnt; |
100 static uint64_t _java_thread_list_alloc_cnt; |
101 static uint _smr_java_thread_list_max; |
101 static uint64_t _java_thread_list_free_cnt; |
102 static uint _smr_nested_thread_list_max; |
102 static uint _java_thread_list_max; |
103 static volatile uint _smr_tlh_cnt; |
103 static uint _nested_thread_list_max; |
104 static volatile uint _smr_tlh_time_max; |
104 static volatile uint _tlh_cnt; |
105 static volatile uint _smr_tlh_times; |
105 static volatile uint _tlh_time_max; |
106 static ThreadsList* _smr_to_delete_list; |
106 static volatile uint _tlh_times; |
107 static uint _smr_to_delete_list_cnt; |
107 static ThreadsList* _to_delete_list; |
108 static uint _smr_to_delete_list_max; |
108 static uint _to_delete_list_cnt; |
|
109 static uint _to_delete_list_max; |
109 |
110 |
110 static ThreadsList *acquire_stable_list_fast_path(Thread *self); |
111 static ThreadsList *acquire_stable_list_fast_path(Thread *self); |
111 static ThreadsList *acquire_stable_list_nested_path(Thread *self); |
112 static ThreadsList *acquire_stable_list_nested_path(Thread *self); |
112 static void add_smr_deleted_thread_times(uint add_value); |
113 static void add_deleted_thread_times(uint add_value); |
113 static void add_smr_tlh_times(uint add_value); |
114 static void add_tlh_times(uint add_value); |
114 static void clear_smr_delete_notify(); |
115 static void clear_delete_notify(); |
115 static void inc_smr_deleted_thread_cnt(); |
116 static Monitor* delete_lock() { return _delete_lock; } |
116 static void inc_smr_java_thread_list_alloc_cnt(); |
117 static bool delete_notify(); |
117 static void inc_smr_tlh_cnt(); |
118 static void free_list(ThreadsList* threads); |
|
119 static void inc_deleted_thread_cnt(); |
|
120 static void inc_java_thread_list_alloc_cnt(); |
|
121 static void inc_tlh_cnt(); |
118 static bool is_a_protected_JavaThread(JavaThread *thread); |
122 static bool is_a_protected_JavaThread(JavaThread *thread); |
119 static void release_stable_list_fast_path(Thread *self); |
123 static void release_stable_list_fast_path(Thread *self); |
120 static void release_stable_list_nested_path(Thread *self); |
124 static void release_stable_list_nested_path(Thread *self); |
121 static void release_stable_list_wake_up(char *log_str); |
125 static void release_stable_list_wake_up(char *log_str); |
122 static void set_smr_delete_notify(); |
126 static void set_delete_notify(); |
123 static Monitor* smr_delete_lock() { return _smr_delete_lock; } |
127 static void update_deleted_thread_time_max(uint new_value); |
124 static bool smr_delete_notify(); |
128 static void update_java_thread_list_max(uint new_value); |
125 static void smr_free_list(ThreadsList* threads); |
129 static void update_tlh_time_max(uint new_value); |
126 static void update_smr_deleted_thread_time_max(uint new_value); |
130 static ThreadsList* xchg_java_thread_list(ThreadsList* new_list); |
127 static void update_smr_java_thread_list_max(uint new_value); |
|
128 static void update_smr_tlh_time_max(uint new_value); |
|
129 static ThreadsList* xchg_smr_java_thread_list(ThreadsList* new_list); |
|
130 |
131 |
131 public: |
132 public: |
132 static ThreadsList *acquire_stable_list(Thread *self, bool is_ThreadsListSetter); |
133 static ThreadsList *acquire_stable_list(Thread *self, bool is_ThreadsListSetter); |
133 static void add_thread(JavaThread *thread); |
134 static void add_thread(JavaThread *thread); |
134 static ThreadsList* get_smr_java_thread_list(); |
135 static ThreadsList* get_java_thread_list(); |
135 static bool is_a_protected_JavaThread_with_lock(JavaThread *thread); |
136 static bool is_a_protected_JavaThread_with_lock(JavaThread *thread); |
136 static void release_stable_list(Thread *self); |
137 static void release_stable_list(Thread *self); |
137 static void remove_thread(JavaThread *thread); |
138 static void remove_thread(JavaThread *thread); |
138 static void smr_delete(JavaThread *thread); |
139 static void smr_delete(JavaThread *thread); |
139 static void update_smr_tlh_stats(uint millis); |
140 static void update_tlh_stats(uint millis); |
140 |
141 |
141 // Logging and printing support: |
142 // Logging and printing support: |
142 static void log_smr_statistics(); |
143 static void log_statistics(); |
143 static void print_smr_info_elements_on(outputStream* st, ThreadsList* t_list); |
144 static void print_info_elements_on(outputStream* st, ThreadsList* t_list); |
144 static void print_smr_info_on(outputStream* st); |
145 static void print_info_on(outputStream* st); |
145 }; |
146 }; |
146 |
147 |
147 // A fast list of JavaThreads. |
148 // A fast list of JavaThreads. |
148 // |
149 // |
149 class ThreadsList : public CHeapObj<mtThread> { |
150 class ThreadsList : public CHeapObj<mtThread> { |