annotate src/os/linux/vm/osThread_linux.hpp @ 12176:88c255656030

8016155: SIGBUS when running Kitchensink with ParallelScavenge and ParallelOld Summary: When using NUMA and large pages we need to ease the requirement on which node the memory should be allocated on. To avoid the SIGBUS we now use the memory policy MPOL_PREFERRED, which prefers a certain node, instead of MPOL_BIND, which requires a certain node. Reviewed-by: jmasa, pliden Contributed-by: stefan.johansson@oracle.com
author mgerdin
date Thu, 22 Aug 2013 10:50:41 +0200
parents f2110083203d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 6093
diff changeset
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef OS_LINUX_VM_OSTHREAD_LINUX_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define OS_LINUX_VM_OSTHREAD_LINUX_HPP
6093
960a442eae91 7161732: Improve handling of thread_id in OSThread
rbackman
parents: 6006
diff changeset
27 public:
960a442eae91 7161732: Improve handling of thread_id in OSThread
rbackman
parents: 6006
diff changeset
28 typedef pid_t thread_id_t;
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
31 int _thread_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 int thread_type() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 return _thread_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 }
a61af66fc99e Initial load
duke
parents:
diff changeset
38 void set_thread_type(int type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 _thread_type = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 }
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // _pthread_id is the pthread id, which is used by library calls
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // (e.g. pthread_kill).
a61af66fc99e Initial load
duke
parents:
diff changeset
44 pthread_t _pthread_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 sigset_t _caller_sigmask; // Caller's signal mask
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Methods to save/restore caller's signal mask
a61af66fc99e Initial load
duke
parents:
diff changeset
51 sigset_t caller_sigmask() const { return _caller_sigmask; }
a61af66fc99e Initial load
duke
parents:
diff changeset
52 void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Used for debugging, return a unique integer for each thread.
a61af66fc99e Initial load
duke
parents:
diff changeset
56 int thread_identifier() const { return _thread_id; }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
58 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // We expect no reposition failures so kill vm if we get one.
a61af66fc99e Initial load
duke
parents:
diff changeset
60 //
a61af66fc99e Initial load
duke
parents:
diff changeset
61 bool valid_reposition_failure() {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
65 pthread_t pthread_id() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 return _pthread_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 void set_pthread_id(pthread_t tid) {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 _pthread_id = tid;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // suspension support.
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // flags that support signal based suspend/resume on Linux are in a
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // separate class to avoid confusion with many flags in OSThread that
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // are used by VM level suspend/resume.
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 6093
diff changeset
80 os::SuspendResume sr;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // _ucontext and _siginfo are used by SR_handler() to save thread context,
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // and they will later be used to walk the stack or reposition thread PC.
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // If the thread is not suspended in SR_handler() (e.g. self suspend),
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // the value in _ucontext is meaningless, so we must use the last Java
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // frame information as the frame. This will mean that for threads
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // that are parked on a mutex the profiler (and safepoint mechanism)
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // will see the thread as if it were still in the Java frame. This
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // not a problem for the profiler since the Java frame is a close
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // enough result. For the safepoint mechanism when the give it the
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Java frame we are not at a point where the safepoint needs the
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // frame to that accurate (like for a compiled safepoint) since we
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // should be in a place where we are native and will block ourselves
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // if we transition.
a61af66fc99e Initial load
duke
parents:
diff changeset
95 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
96 void* _siginfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 ucontext_t* _ucontext;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 int _expanding_stack; /* non zero if manually expanding stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
99 address _alt_sig_stack; /* address of base of alternate signal stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
102 void* siginfo() const { return _siginfo; }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 void set_siginfo(void* ptr) { _siginfo = ptr; }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 ucontext_t* ucontext() const { return _ucontext; }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 void set_expanding_stack(void) { _expanding_stack = 1; }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 void clear_expanding_stack(void) { _expanding_stack = 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 int expanding_stack(void) { return _expanding_stack; }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 void set_alt_sig_stack(address val) { _alt_sig_stack = val; }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 address alt_sig_stack(void) { return _alt_sig_stack; }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
114 Monitor* _startThread_lock; // sync parent and child in thread creation
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 Monitor* startThread_lock() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 return _startThread_lock;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Platform dependent initialization and cleanup
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 void pd_initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
129 void pd_destroy();
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // Reconciliation History
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // osThread_solaris.hpp 1.24 99/08/27 13:11:54
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // End
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
134
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
135 #endif // OS_LINUX_VM_OSTHREAD_LINUX_HPP