| 1 | // SPDX-License-Identifier: GPL-2.0-or-latercxx . . $ `<file>/src/pi_tests/pi_stress.c`/ |
| 2 | /* |
| 3 | * pi_stress - Priority Inheritance stress test |
| 4 | * Copyright (C) 2006, 2007 Clark Williams <[email protected]> |
| 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * This program stress tests pthreads priority inheritance mutexes |
| 9 | |
| 10 | * The logic is built upon the state machine that performs the "classic_pi" |
| 11 | * deadlock scenario. A state machine or "inversion group" is a group of three |
| 12 | * threads as described below. |
| 13 | * |
| 14 | * The basic premise here is to set up a deadlock scenario and confirm that PI |
| 15 | * mutexes resolve the situation. Three worker threads will be created from the |
| 16 | * main thread: low, medium and high priority threads that use SCHED_FIFO as |
| 17 | * their scheduling policy. The low priority thread claims a mutex and then |
| 18 | * starts "working". The medium priority thread starts and preempts the low |
| 19 | * priority thread. Then the high priority thread runs and attempts to claim |
| 20 | * the mutex owned by the low priority thread. Without priority inheritance, |
| 21 | * this will deadlock the program. With priority inheritance, the low priority |
| 22 | * thread receives a priority boost, finishes it's "work" and releases the mutex |
| 23 | * which allows the high priority thread to run and finish and then the medium |
| 24 | * priority thread finishes. |
| 25 | * |
| 26 | * That's the theory, anyway... |
| 27 | * |
| 28 | * CW - 2006 |
| 29 | */ |
| 30 | |
| 31 | #include "pi_stress.h"cxx . . $ `<file>/src/include/pi_stress.h`/ |
| 32 | |
| 33 | /* the length of the test */ |
| 34 | /* default is infinite */ |
| 35 | int durationcxx . . $ duration. = -1; |
| 36 | |
| 37 | /* times for starting and finishing the stress test */ |
| 38 | time_tcxx . . $ time_t# startcxx . . $ start., finishcxx . . $ finish.; |
| 39 | |
| 40 | /* the number of groups to create */ |
| 41 | int ngroupscxx . . $ ngroups.; |
| 42 | |
| 43 | /* the number of times a group causes a priority inversion situation */ |
| 44 | /* default to infinite */ |
| 45 | int inversionscxx . . $ inversions. = -1; |
| 46 | |
| 47 | /* turn on lots of prints */ |
| 48 | int verbosecxx . . $ verbose.; |
| 49 | |
| 50 | /* turn on pi_debugging prints */ |
| 51 | int debuggingcxx . . $ debugging.; |
| 52 | |
| 53 | /* turn off all prints, default = 0 (off) */ |
| 54 | int quietcxx . . $ quiet.; |
| 55 | |
| 56 | /* filename for JSON output */ |
| 57 | char jsonfilecxx . . $ jsonfile.[MAX_PATHcxx . . $ `src/include/rt-utils.h:9:9`!]; |
| 58 | |
| 59 | /* prompt to start test */ |
| 60 | int promptcxx . . $ prompt.; |
| 61 | |
| 62 | /* report interval */ |
| 63 | unsigned long report_intervalcxx . . $ report_interval. = (unsigned long)SEC_TO_USECcxx . . $ `src/include/rt-utils.h:44:9`!(0.75); |
| 64 | |
| 65 | int shutdowncxx . . $ shutdown.; /* global indicating we should shut down */ |
| 66 | pthread_mutex_tcxx . . $ pthread_mutex_t# shutdown_mtxcxx . . $ shutdown_mtx.; /* associated mutex */ |
| 67 | |
| 68 | /* indicate if errors have occurred */ |
| 69 | int have_errorscxx . . $ have_errors.; |
| 70 | |
| 71 | /* indicated that keyboard interrupt has happened */ |
| 72 | int interruptedcxx . . $ interrupted.; |
| 73 | |
| 74 | /* force running on one cpu */ |
| 75 | int uniprocessorcxx . . $ uniprocessor.; |
| 76 | |
| 77 | /* lock all memory */ |
| 78 | int lockallcxx . . $ lockall.; |
| 79 | |
| 80 | pthread_barrier_tcxx . . $ pthread_barrier_t# all_threads_readycxx . . $ all_threads_ready.; |
| 81 | pthread_barrier_tcxx . . $ pthread_barrier_t# all_threads_donecxx . . $ all_threads_done.; |
| 82 | |
| 83 | cpu_set_tcxx . . $ cpu_set_t# test_cpu_maskcxx . . $ test_cpu_mask., admin_cpu_maskcxx . . $ admin_cpu_mask.; |
| 84 | |
| 85 | int policycxx . . $ policy. = SCHED_FIFOcxx . . $ `<external>/4872883757279652994/sched.h:29:9`!; |
| 86 | |
| 87 | /* scheduling attributes per thread */ |
| 88 | struct sched_attrcxx . . $ sched_attr# low_sacxx . . $ low_sa.; |
| 89 | struct sched_attrcxx . . $ sched_attr# med_sacxx . . $ med_sa.; |
| 90 | struct sched_attrcxx . . $ sched_attr# high_sacxx . . $ high_sa.; |
| 91 | struct sched_attrcxx . . $ sched_attr# admin_sacxx . . $ admin_sa.; |
| 92 | |
| 93 | unsigned int sa_initializedcxx . . $ sa_initialized.; |
| 94 | |
| 95 | struct group_parameterscxx . . $ group_parameters# *groupscxx . . $ groups.; |
| 96 | |
| 97 | /* number of online processors */ |
| 98 | long num_processorscxx . . $ num_processors.; |
| 99 | |
| 100 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) |
| 101 | { |
| 102 | int status; |
| 103 | struct sched_paramcxx . . $ sched_param# thread_param; |
| 104 | int i; |
| 105 | int retval = FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 106 | int core; |
| 107 | int nthreads; |
| 108 | |
| 109 | /* Make sure we see all message, even those on stdout. */ |
| 110 | setvbufcxx . . $ setvbuf(4da3ba8c983f31bc).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, _IONBFcxx . . $ `<external>/232824719582829767/stdio.h:96:9`!, 0); |
| 111 | |
| 112 | /* get the number of processors */ |
| 113 | num_processorscxx . . $ num_processors. = sysconfcxx . . $ sysconf(dc1f09c09fbff20f).(_SC_NPROCESSORS_ONLNcxx . . $ `<external>/6393649343499073842/confname.h:253:9`!); |
| 114 | |
| 115 | /* calculate the number of inversion groups to run */ |
| 116 | ngroupscxx . . $ ngroups. = num_processorscxx . . $ num_processors. == 1 ? 1 : num_processorscxx . . $ num_processors. - 1; |
| 117 | |
| 118 | |
| 119 | /* process command line arguments */ |
| 120 | rt_initcxx . . $ rt_init(c759356ac01a31e7).(argc, argv); |
| 121 | process_command_linecxx . . $ process_command_line(c759356ac01a31e7).(argc, argv); |
| 122 | |
| 123 | /* set default sched attributes */ |
| 124 | setup_sched_configcxx . . $ setup_sched_config(d4f767463ce0a6b3).(policycxx . . $ policy.); |
| 125 | |
| 126 | /* lock memory */ |
| 127 | if (lockallcxx . . $ lockall.) |
| 128 | if (mlockallcxx . . $ mlockall(7864480464b09eea).(MCL_CURRENTcxx . . $ `<external>/17226767460805440860/mman-linux.h:131:10`! | MCL_FUTUREcxx . . $ `<external>/17226767460805440860/mman-linux.h:132:10`!) == -1) { |
| 129 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("mlockall failed\n"); |
| 130 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 131 | } |
| 132 | /* boost main's priority (so we keep running) :) */ |
| 133 | thread_param.sched_prioritycxx . . $ `<external>/17522079545615609418/sched.h:47:9`! = admin_sacxx . . $ admin_sa..sched_prioritycxx . . $ `<external>/17522079545615609418/sched.h:47:9`!; |
| 134 | status = pthread_setschedparamcxx . . $ pthread_setschedparam(21a79fc390b1b9cf).(pthread_selfcxx . . $ pthread_self(f708dce9a8856c70).(), admin_sacxx . . $ admin_sa..sched_policycxx . . $ sched_attr#sched_policy., |
| 135 | &thread_param); |
| 136 | if (status) { |
| 137 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("%s: boosting to max priority: 0x%x\n", __func__, |
| 138 | status); |
| 139 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 140 | } |
| 141 | /* block unwanted signals */ |
| 142 | block_signalscxx . . $ block_signals(b126dc7c1de90089).(); |
| 143 | |
| 144 | /* allocate our groups array */ |
| 145 | groupscxx . . $ groups. = calloccxx . . $ calloc(63a7bf2941bfcd7a).(ngroupscxx . . $ ngroups., sizeof(struct group_parameterscxx . . $ group_parameters#)); |
| 146 | if (groupscxx . . $ groups. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 147 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("%s: failed to allocate %d groups\n", __func__, |
| 148 | ngroups); |
| 149 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 150 | } |
| 151 | /* set up CPU affinity masks */ |
| 152 | if (set_cpu_affinitycxx . . $ set_cpu_affinity(d96ca8014e0634be).(&test_cpu_maskcxx . . $ test_cpu_mask., &admin_cpu_maskcxx . . $ admin_cpu_mask.)) |
| 153 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 154 | |
| 155 | nthreads = ngroupscxx . . $ ngroups. * NUM_TEST_THREADScxx . . $ `src/include/pi_stress.h:55:9`! + NUM_ADMIN_THREADScxx . . $ `src/include/pi_stress.h:56:9`!; |
| 156 | |
| 157 | /* set up our ready barrier */ |
| 158 | if (barrier_initcxx . . $ barrier_init(f9df304b61f441a4).(&all_threads_readycxx . . $ all_threads_ready., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, nthreads, |
| 159 | "all_threads_ready")) |
| 160 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 161 | |
| 162 | /* set up our done barrier */ |
| 163 | if (barrier_initcxx . . $ barrier_init(f9df304b61f441a4).(&all_threads_donecxx . . $ all_threads_done., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, nthreads, "all_threads_done")) |
| 164 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 165 | |
| 166 | /* create the groups */ |
| 167 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("Creating %d test groups\n", ngroups); |
| 168 | for (core = 0; core < num_processorscxx . . $ num_processors.; core++) |
| 169 | if (CPU_ISSETcxx . . $ `<external>/17522079545615609418/sched.h:94:10`!(core, &test_cpu_mask)) |
| 170 | break; |
| 171 | for (i = 0; i < ngroupscxx . . $ ngroups.; i++) { |
| 172 | groupscxx . . $ groups.[i].idcxx . . $ group_parameters#id. = i; |
| 173 | groupscxx . . $ groups.[i].cpucxx . . $ group_parameters#cpu. = core++; |
| 174 | if (core >= num_processorscxx . . $ num_processors.) |
| 175 | core = 0; |
| 176 | if (create_groupcxx . . $ create_group(5723616408aa12db).(&groupscxx . . $ groups.[i]) != SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!) |
| 177 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 178 | } |
| 179 | |
| 180 | /* prompt if requested */ |
| 181 | if (promptcxx . . $ prompt.) { |
| 182 | printfcxx . . $ printf(581fddd72a8db8fc).("Press return to start test: "); |
| 183 | getcharcxx . . $ getchar(b126dc7c1de90089).(); |
| 184 | } |
| 185 | /* report */ |
| 186 | bannercxx . . $ banner(49f6e7a06ebc5aa8).(); |
| 187 | startcxx . . $ start. = timecxx . . $ time(7f38134db6521d23).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 188 | |
| 189 | /* turn loose the threads */ |
| 190 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("Releasing all threads\n"); |
| 191 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&all_threads_readycxx . . $ all_threads_ready.); |
| 192 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 193 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("%s: pthread_barrier_wait(all_threads_ready): 0x%x\n", |
| 194 | __func__, status); |
| 195 | set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(); |
| 196 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 197 | } |
| 198 | |
| 199 | reportercxx . . $ reporter(9f162e79bfc6c74).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 200 | |
| 201 | if (!quietcxx . . $ quiet.) { |
| 202 | fputscxx . . $ fputs(874fa6a5e59ab9bd).(DOWN_ONEcxx . . $ `src/include/pi_stress.h:46:9`!, stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!); |
| 203 | printfcxx . . $ printf(581fddd72a8db8fc).("Stopping test\n"); |
| 204 | } |
| 205 | set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(); |
| 206 | |
| 207 | /* wait for all threads to notice the shutdown flag */ |
| 208 | if (have_errorscxx . . $ have_errors. == 0 && interruptedcxx . . $ interrupted. == 0) { |
| 209 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("waiting for all threads to complete\n"); |
| 210 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&all_threads_donecxx . . $ all_threads_done.); |
| 211 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 212 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("%s: pthread_barrier_wait(all_threads_ready): 0x%x\n", __func__, status); |
| 213 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 214 | } |
| 215 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("All threads terminated!\n"); |
| 216 | retval = SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 217 | } else |
| 218 | killcxx . . $ kill(9b79fb6aee4c0440).(0, SIGTERMcxx . . $ `<external>/11773118241360591791/signum-generic.h:53:9`!); |
| 219 | finishcxx . . $ finish. = timecxx . . $ time(7f38134db6521d23).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 220 | summarycxx . . $ summary(49f6e7a06ebc5aa8).(); |
| 221 | |
| 222 | if (strlencxx . . $ strlen(751346f8406fd082).(jsonfilecxx . . $ jsonfile.) != 0) |
| 223 | rt_write_jsoncxx . . $ rt_write_json(969c696bbc9a09ad).(jsonfilecxx . . $ jsonfile., retval, write_statscxx . . $ write_stats(2fd218767557b4b8)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 224 | |
| 225 | if (lockallcxx . . $ lockall.) |
| 226 | munlockallcxx . . $ munlockall(b126dc7c1de90089).(); |
| 227 | exitcxx . . $ exit(3ca292c338df9bb3).(retval); |
| 228 | } |
| 229 | |
| 230 | int |
| 231 | setup_thread_attrcxx . . $ setup_thread_attr(1f85186bfce73196).(pthread_attr_tcxx . . $ pthread_attr_t# *attr, struct sched_attrcxx . . $ sched_attr# *sa, |
| 232 | cpu_set_tcxx . . $ cpu_set_t# *mask) |
| 233 | { |
| 234 | int status; |
| 235 | struct sched_paramcxx . . $ sched_param# thread_param; |
| 236 | |
| 237 | status = pthread_attr_initcxx . . $ pthread_attr_init(26f1688c57ac69c9).(attr); |
| 238 | if (status) { |
| 239 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 240 | ("%s: initializing thread attribute: 0x%x\n", __func__, |
| 241 | status); |
| 242 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 243 | } |
| 244 | status = pthread_attr_setaffinity_npcxx . . $ pthread_attr_setaffinity_np(6cc641810eb60b10).(attr, sizeof(cpu_set_tcxx . . $ cpu_set_t#), mask); |
| 245 | if (status) { |
| 246 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("%s: setting affinity attribute: 0x%x\n", __func__, |
| 247 | status); |
| 248 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 249 | } |
| 250 | |
| 251 | /* |
| 252 | * The pthread API does not yet support SCHED_DEADLINE, defer the |
| 253 | * thread configuration to setup_thread() |
| 254 | */ |
| 255 | if (sa->sched_policycxx . . $ sched_attr#sched_policy. == SCHED_DEADLINEcxx . . $ `<external>/4872883757279652994/sched.h:36:10`!) |
| 256 | return SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 257 | |
| 258 | status = pthread_attr_setschedpolicycxx . . $ pthread_attr_setschedpolicy(1c205214b8a99ab8).(attr, sa->sched_policycxx . . $ sched_attr#sched_policy.); |
| 259 | if (status) { |
| 260 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 261 | ("%s: setting attribute policy to %s: 0x%x\n", __func__, |
| 262 | policy_to_string(sa->sched_policy), |
| 263 | status); |
| 264 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 265 | } |
| 266 | status = pthread_attr_setinheritschedcxx . . $ pthread_attr_setinheritsched(1c205214b8a99ab8).(attr, PTHREAD_EXPLICIT_SCHEDcxx . . $ `<external>/14712363683955484316/pthread.h:129:9`!); |
| 267 | if (status) { |
| 268 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 269 | ("%s: setting explicit scheduling inheritance: 0x%x\n", |
| 270 | __func__, status); |
| 271 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 272 | } |
| 273 | thread_param.sched_prioritycxx . . $ `<external>/17522079545615609418/sched.h:47:9`! = sa->sched_prioritycxx . . $ `<external>/17522079545615609418/sched.h:47:9`!; |
| 274 | status = pthread_attr_setschedparamcxx . . $ pthread_attr_setschedparam(4420ee5e0ea92128).(attr, &thread_param); |
| 275 | if (status) { |
| 276 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("%s: setting scheduler param: 0x%x\n", __func__, |
| 277 | status); |
| 278 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 279 | } |
| 280 | return SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 281 | } |
| 282 | |
| 283 | int set_cpu_affinitycxx . . $ set_cpu_affinity(d96ca8014e0634be).(cpu_set_tcxx . . $ cpu_set_t# *test_mask, cpu_set_tcxx . . $ cpu_set_t# *admin_mask) |
| 284 | { |
| 285 | int status, i, admin_proc; |
| 286 | cpu_set_tcxx . . $ cpu_set_t# current_mask; |
| 287 | |
| 288 | /* handle uniprocessor case */ |
| 289 | if (num_processorscxx . . $ num_processors. == 1 || uniprocessorcxx . . $ uniprocessor.) { |
| 290 | CPU_ZEROcxx . . $ `<external>/17522079545615609418/sched.h:96:10`!(admin_mask); |
| 291 | CPU_ZEROcxx . . $ `<external>/17522079545615609418/sched.h:96:10`!(test_mask); |
| 292 | CPU_SETcxx . . $ `<external>/17522079545615609418/sched.h:92:10`!(0, admin_mask); |
| 293 | CPU_SETcxx . . $ `<external>/17522079545615609418/sched.h:92:10`!(0, test_mask); |
| 294 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("admin and test threads running on one processor\n"); |
| 295 | return SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 296 | } |
| 297 | /* |
| 298 | * first set our main thread to run on the first |
| 299 | * scheduleable processor we can find |
| 300 | */ |
| 301 | status = sched_getaffinitycxx . . $ sched_getaffinity(3d37575d37dd6057).(0, sizeof(cpu_set_tcxx . . $ cpu_set_t#), ¤t_mask); |
| 302 | if (status) { |
| 303 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("failed getting CPU affinity mask: 0x%x\n", status); |
| 304 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 305 | } |
| 306 | for (i = 0; i < num_processorscxx . . $ num_processors.; i++) { |
| 307 | if (CPU_ISSETcxx . . $ `<external>/17522079545615609418/sched.h:94:10`!(i, ¤t_mask)) |
| 308 | break; |
| 309 | } |
| 310 | if (i >= num_processorscxx . . $ num_processors.) { |
| 311 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("No schedulable CPU found for main!\n"); |
| 312 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 313 | } |
| 314 | admin_proc = i; |
| 315 | CPU_ZEROcxx . . $ `<external>/17522079545615609418/sched.h:96:10`!(admin_mask); |
| 316 | CPU_SETcxx . . $ `<external>/17522079545615609418/sched.h:92:10`!(admin_proc, admin_mask); |
| 317 | status = sched_setaffinitycxx . . $ sched_setaffinity(48631566441f33fb).(0, sizeof(cpu_set_tcxx . . $ cpu_set_t#), admin_mask); |
| 318 | if (status) { |
| 319 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("%s: setting CPU affinity mask: 0x%x\n", __func__, |
| 320 | status); |
| 321 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 322 | } |
| 323 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("Admin thread running on processor: %d\n", i); |
| 324 | |
| 325 | /* Set test affinity so that tests run on the non-admin processors */ |
| 326 | CPU_ZEROcxx . . $ `<external>/17522079545615609418/sched.h:96:10`!(test_mask); |
| 327 | for (i = admin_proc + 1; i < num_processorscxx . . $ num_processors.; i++) |
| 328 | CPU_SETcxx . . $ `<external>/17522079545615609418/sched.h:92:10`!(i, test_mask); |
| 329 | |
| 330 | if (admin_proc + 1 == num_processorscxx . . $ num_processors. - 1) |
| 331 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("Test threads running on processor: %ld\n", |
| 332 | num_processors - 1); |
| 333 | else |
| 334 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("Test threads running on processors: %d-%d\n", |
| 335 | admin_proc + 1, (int)num_processors - 1); |
| 336 | |
| 337 | return SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 338 | } |
| 339 | |
| 340 | /* clear all watchdog counters */ |
| 341 | void watchdog_clearcxx . . $ watchdog_clear(49f6e7a06ebc5aa8).(void) |
| 342 | { |
| 343 | int i; |
| 344 | |
| 345 | for (i = 0; i < ngroupscxx . . $ ngroups.; i++) |
| 346 | groupscxx . . $ groups.[i].watchdogcxx . . $ group_parameters#watchdog. = 0; |
| 347 | } |
| 348 | |
| 349 | /* check for zero watchdog counters */ |
| 350 | int watchdog_checkcxx . . $ watchdog_check(b126dc7c1de90089).(void) |
| 351 | { |
| 352 | int i; |
| 353 | int failures = 0; |
| 354 | struct group_parameterscxx . . $ group_parameters# *g; |
| 355 | |
| 356 | for (i = 0; i < ngroupscxx . . $ ngroups.; i++) { |
| 357 | g = &groupscxx . . $ groups.[i]; |
| 358 | if (g->watchdogcxx . . $ group_parameters#watchdog. == 0) { |
| 359 | /* don't report deadlock if group is finished */ |
| 360 | if (g->inversionscxx . . $ group_parameters#inversions. == g->totalcxx . . $ group_parameters#total.) |
| 361 | continue; |
| 362 | if (++g->watchdog_hitscxx . . $ group_parameters#watchdog_hits. >= WATCHDOG_LIMITcxx . . $ `src/include/pi_stress.h:64:9`!) { |
| 363 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 364 | ("WATCHDOG triggered: group %d is deadlocked!\n", |
| 365 | i); |
| 366 | failures++; |
| 367 | } |
| 368 | } else |
| 369 | g->watchdog_hitscxx . . $ group_parameters#watchdog_hits. = 0; |
| 370 | } |
| 371 | return failures ? FAILUREcxx . . $ `src/include/pi_stress.h:42:9`! : SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 372 | } |
| 373 | |
| 374 | int pending_interruptcxx . . $ pending_interrupt(b126dc7c1de90089).(void) |
| 375 | { |
| 376 | sigset_tcxx . . $ sigset_t# pending; |
| 377 | |
| 378 | if (sigpendingcxx . . $ sigpending(f9c066a8ff75ee9d).(&pending) < 0) { |
| 379 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("from sigpending: %s\n", strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | return interruptedcxx . . $ interrupted. = sigismembercxx . . $ sigismember(3b90c49b7fdc3eaa).(&pending, SIGINTcxx . . $ `<external>/11773118241360591791/signum-generic.h:48:9`!); |
| 384 | } |
| 385 | |
| 386 | /* |
| 387 | * this routine serves two purposes: |
| 388 | * 1. report progress |
| 389 | * 2. check for deadlocks |
| 390 | */ |
| 391 | void *reportercxx . . $ reporter(9f162e79bfc6c74).(void *arg) |
| 392 | { |
| 393 | int status; |
| 394 | int end = 0; |
| 395 | struct timespeccxx . . $ timespec# ts; |
| 396 | |
| 397 | ts.tv_seccxx . . $ timespec#tv_sec. = 0; |
| 398 | ts.tv_nseccxx . . $ timespec#tv_nsec. = USEC_TO_NSECcxx . . $ `src/include/rt-utils.h:40:9`!(report_interval); |
| 399 | |
| 400 | tsnormcxx . . $ tsnorm(70b8fb3bc03a57b2).(&ts); |
| 401 | |
| 402 | if (durationcxx . . $ duration. >= 0) |
| 403 | end = durationcxx . . $ duration. + timecxx . . $ time(7f38134db6521d23).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 404 | |
| 405 | /* sleep initially to let everything get up and running */ |
| 406 | status = clock_nanosleepcxx . . $ clock_nanosleep(99dc002056e22615).(CLOCK_MONOTONICcxx . . $ `<external>/89459239771508533/time.h:48:10`!, 0, &ts, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 407 | if (status) { |
| 408 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("from clock_nanosleep: %s\n", strerror(status)); |
| 409 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 410 | } |
| 411 | |
| 412 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("%s: starting report loop\n", __func__); |
| 413 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("Press Control-C to stop test\nCurrent Inversions:\n"); |
| 414 | |
| 415 | for (;;) { |
| 416 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 417 | if (shutdowncxx . . $ shutdown.) { |
| 418 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 419 | break; |
| 420 | } |
| 421 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 422 | |
| 423 | /* wait for our reporting interval */ |
| 424 | status = clock_nanosleepcxx . . $ clock_nanosleep(99dc002056e22615).(CLOCK_MONOTONICcxx . . $ `<external>/89459239771508533/time.h:48:10`!, 0, &ts, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 425 | if (status) { |
| 426 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("from clock_nanosleep: %s\n", strerror(status)); |
| 427 | break; |
| 428 | } |
| 429 | |
| 430 | /* check for signaled shutdown */ |
| 431 | if (!quietcxx . . $ quiet.) { |
| 432 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 433 | if (shutdowncxx . . $ shutdown. == 0) { |
| 434 | fputscxx . . $ fputs(874fa6a5e59ab9bd).(UP_ONEcxx . . $ `src/include/pi_stress.h:45:9`!, stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!); |
| 435 | printfcxx . . $ printf(581fddd72a8db8fc).("Current Inversions: %lu\n", |
| 436 | total_inversionscxx . . $ total_inversions(f708dce9a8856c70).()); |
| 437 | } |
| 438 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 439 | } |
| 440 | |
| 441 | /* if we specified a duration, see if it has expired */ |
| 442 | if (end && timecxx . . $ time(7f38134db6521d23).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) > end) { |
| 443 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("duration reached (%d seconds)\n", duration); |
| 444 | set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(); |
| 445 | continue; |
| 446 | } |
| 447 | /* check for a pending SIGINT */ |
| 448 | if (pending_interruptcxx . . $ pending_interrupt(b126dc7c1de90089).()) { |
| 449 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("Keyboard Interrupt!\n"); |
| 450 | break; |
| 451 | } |
| 452 | /* check watchdog stuff */ |
| 453 | if ((watchdog_checkcxx . . $ watchdog_check(b126dc7c1de90089).())) { |
| 454 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("%s stopping due to watchdog event\n", __func__); |
| 455 | set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(); |
| 456 | break; |
| 457 | } |
| 458 | /* clear watchdog counters */ |
| 459 | watchdog_clearcxx . . $ watchdog_clear(49f6e7a06ebc5aa8).(); |
| 460 | |
| 461 | } |
| 462 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("%s: finished\n", __func__); |
| 463 | set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(); |
| 464 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 465 | } |
| 466 | |
| 467 | int verify_cpucxx . . $ verify_cpu(7864480464b09eea).(int cpu) |
| 468 | { |
| 469 | int status; |
| 470 | int err; |
| 471 | cpu_set_tcxx . . $ cpu_set_t# mask; |
| 472 | |
| 473 | CPU_ZEROcxx . . $ `<external>/17522079545615609418/sched.h:96:10`!(&mask); |
| 474 | |
| 475 | status = sched_getaffinitycxx . . $ sched_getaffinity(3d37575d37dd6057).(0, sizeof(cpu_set_tcxx . . $ cpu_set_t#), &mask); |
| 476 | if (status == -1) { |
| 477 | err = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!; |
| 478 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "sched_getaffinity %s\n", strerrorcxx . . $ strerror(ff224f080444ee45).(err)); |
| 479 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 480 | } |
| 481 | |
| 482 | if (CPU_ISSETcxx . . $ `<external>/17522079545615609418/sched.h:94:10`!(cpu, &mask)) |
| 483 | return SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 484 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 485 | } |
| 486 | |
| 487 | void *low_prioritycxx . . $ low_priority(9f162e79bfc6c74).(void *arg) |
| 488 | { |
| 489 | int status; |
| 490 | int unbounded; |
| 491 | unsigned long count = 0; |
| 492 | struct group_parameterscxx . . $ group_parameters# *p = (struct group_parameterscxx . . $ group_parameters# *)arg; |
| 493 | pthread_barrier_tcxx . . $ pthread_barrier_t# *loop_barr = &p->loop_barrcxx . . $ group_parameters#loop_barr.; |
| 494 | pthread_mutex_tcxx . . $ pthread_mutex_t# *loop_mtx = &p->loop_mtxcxx . . $ group_parameters#loop_mtx.; |
| 495 | int *loop = &p->loopcxx . . $ group_parameters#loop.; |
| 496 | |
| 497 | allow_sigtermcxx . . $ allow_sigterm(b126dc7c1de90089).(); |
| 498 | |
| 499 | if (verify_cpucxx . . $ verify_cpu(7864480464b09eea).(p->cpucxx . . $ group_parameters#cpu.) != SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!) { |
| 500 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("low_priority[%d]: not bound to %ld\n", p->id, p->cpu); |
| 501 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 502 | } |
| 503 | |
| 504 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: entering ready state\n", p->id); |
| 505 | /* wait for all threads to be ready */ |
| 506 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&all_threads_readycxx . . $ all_threads_ready.); |
| 507 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 508 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 509 | ("low_priority[%d]: pthread_barrier_wait(all_threads_ready): %x", |
| 510 | p->id, status); |
| 511 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 512 | } |
| 513 | |
| 514 | unbounded = (p->inversionscxx . . $ group_parameters#inversions. < 0); |
| 515 | |
| 516 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: starting inversion loop\n", p->id); |
| 517 | |
| 518 | for (;;) { |
| 519 | /* |
| 520 | * We can't set the 'loop' boolean here, because some flags |
| 521 | * may have already reached the loop_barr |
| 522 | */ |
| 523 | if (!unbounded && (p->totalcxx . . $ group_parameters#total. >= (unsigned int)p->inversionscxx . . $ group_parameters#inversions.)) |
| 524 | set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(); |
| 525 | |
| 526 | /* Either all threads go through the loop_barr, or none do */ |
| 527 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(loop_mtx); |
| 528 | if (*loop == 0) { |
| 529 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(loop_mtx); |
| 530 | break; |
| 531 | } |
| 532 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(loop_mtx); |
| 533 | |
| 534 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(loop_barr); |
| 535 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 536 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("%s[%d]: pthread_barrier_wait(loop): %x\n", |
| 537 | __func__, p->id, status); |
| 538 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 539 | } |
| 540 | |
| 541 | /* Only one Thread needs to check the shutdown status */ |
| 542 | if (status == PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 543 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 544 | if (shutdowncxx . . $ shutdown.) { |
| 545 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(loop_mtx); |
| 546 | *loop = 0; |
| 547 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(loop_mtx); |
| 548 | } |
| 549 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 550 | } |
| 551 | |
| 552 | /* initial state */ |
| 553 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: entering start wait (%ld)\n", p->id, |
| 554 | count++); |
| 555 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&p->start_barriercxx . . $ group_parameters#start_barrier.); |
| 556 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 557 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 558 | ("low_priority[%d]: pthread_barrier_wait(start): %x\n", |
| 559 | p->id, status); |
| 560 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 561 | } |
| 562 | |
| 563 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: claiming mutex\n", p->id); |
| 564 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&p->mutexcxx . . $ group_parameters#mutex.); |
| 565 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: mutex locked\n", p->id); |
| 566 | |
| 567 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: entering locked wait\n", p->id); |
| 568 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&p->locked_barriercxx . . $ group_parameters#locked_barrier.); |
| 569 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 570 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 571 | ("low_priority[%d]: pthread_barrier_wait(locked): %x\n", |
| 572 | p->id, status); |
| 573 | /* release the mutex */ |
| 574 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: unlocking mutex\n", p->id); |
| 575 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&p->mutexcxx . . $ group_parameters#mutex.); |
| 576 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 577 | } |
| 578 | |
| 579 | /* wait for priority boost */ |
| 580 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: entering elevated wait\n", p->id); |
| 581 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&p->elevate_barriercxx . . $ group_parameters#elevate_barrier.); |
| 582 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 583 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 584 | ("low_priority[%d]: pthread_barrier_wait(elevate): %x\n", |
| 585 | p->id, status); |
| 586 | /* release the mutex */ |
| 587 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: unlocking mutex\n", p->id); |
| 588 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&p->mutexcxx . . $ group_parameters#mutex.); |
| 589 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 590 | } |
| 591 | |
| 592 | /* release the mutex */ |
| 593 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: unlocking mutex\n", p->id); |
| 594 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&p->mutexcxx . . $ group_parameters#mutex.); |
| 595 | |
| 596 | /* finish state */ |
| 597 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: entering finish wait\n", p->id); |
| 598 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&p->finish_barriercxx . . $ group_parameters#finish_barrier.); |
| 599 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 600 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 601 | ("low_priority[%d]: pthread_barrier_wait(elevate): %x\n", |
| 602 | p->id, status); |
| 603 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 604 | } |
| 605 | } |
| 606 | set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(); |
| 607 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: entering done barrier\n", p->id); |
| 608 | /* wait for all threads to finish */ |
| 609 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&all_threads_donecxx . . $ all_threads_done.); |
| 610 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 611 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 612 | ("low_priority[%d]: pthread_barrier_wait(all_threads_done): %x", |
| 613 | p->id, status); |
| 614 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 615 | } |
| 616 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("low_priority[%d]: exiting\n", p->id); |
| 617 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 618 | } |
| 619 | |
| 620 | void *med_prioritycxx . . $ med_priority(9f162e79bfc6c74).(void *arg) |
| 621 | { |
| 622 | int status; |
| 623 | int unbounded; |
| 624 | unsigned long count = 0; |
| 625 | struct group_parameterscxx . . $ group_parameters# *p = (struct group_parameterscxx . . $ group_parameters# *)arg; |
| 626 | pthread_barrier_tcxx . . $ pthread_barrier_t# *loop_barr = &p->loop_barrcxx . . $ group_parameters#loop_barr.; |
| 627 | pthread_mutex_tcxx . . $ pthread_mutex_t# *loop_mtx = &p->loop_mtxcxx . . $ group_parameters#loop_mtx.; |
| 628 | int *loop = &p->loopcxx . . $ group_parameters#loop.; |
| 629 | |
| 630 | allow_sigtermcxx . . $ allow_sigterm(b126dc7c1de90089).(); |
| 631 | |
| 632 | if (verify_cpucxx . . $ verify_cpu(7864480464b09eea).(p->cpucxx . . $ group_parameters#cpu.) != SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!) { |
| 633 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("med_priority[%d]: not bound to %ld\n", p->id, p->cpu); |
| 634 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 635 | } |
| 636 | |
| 637 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("med_priority[%d]: entering ready state\n", p->id); |
| 638 | /* wait for all threads to be ready */ |
| 639 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&all_threads_readycxx . . $ all_threads_ready.); |
| 640 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 641 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 642 | ("med_priority[%d]: pthread_barrier_wait(all_threads_ready): %x", |
| 643 | p->id, status); |
| 644 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 645 | } |
| 646 | |
| 647 | unbounded = (p->inversionscxx . . $ group_parameters#inversions. < 0); |
| 648 | |
| 649 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("med_priority[%d]: starting inversion loop\n", p->id); |
| 650 | for (;;) { |
| 651 | if (!unbounded && (p->totalcxx . . $ group_parameters#total. >= (unsigned int)p->inversionscxx . . $ group_parameters#inversions.)) |
| 652 | set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(); |
| 653 | |
| 654 | /* Either all threads go through the loop_barr, or none do */ |
| 655 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(loop_mtx); |
| 656 | if (*loop == 0) { |
| 657 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(loop_mtx); |
| 658 | break; |
| 659 | } |
| 660 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(loop_mtx); |
| 661 | |
| 662 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(loop_barr); |
| 663 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 664 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("%s[%d]: pthread_barrier_wait(loop): %x\n", |
| 665 | __func__, p->id, status); |
| 666 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 667 | } |
| 668 | |
| 669 | /* Only one Thread needs to check the shutdown status */ |
| 670 | if (status == PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 671 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 672 | if (shutdowncxx . . $ shutdown.) { |
| 673 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(loop_mtx); |
| 674 | *loop = 0; |
| 675 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(loop_mtx); |
| 676 | } |
| 677 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 678 | } |
| 679 | |
| 680 | /* start state */ |
| 681 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("med_priority[%d]: entering start state (%ld)\n", p->id, |
| 682 | count++); |
| 683 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&p->start_barriercxx . . $ group_parameters#start_barrier.); |
| 684 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 685 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 686 | ("med_priority[%d]: pthread_barrier_wait(start): %x", |
| 687 | p->id, status); |
| 688 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 689 | } |
| 690 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("med_priority[%d]: entering elevate state\n", p->id); |
| 691 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&p->elevate_barriercxx . . $ group_parameters#elevate_barrier.); |
| 692 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 693 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! ("med_priority[%d]: pthread_barrier_wait(elevate): %x", p->id, status); |
| 694 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 695 | } |
| 696 | |
| 697 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("med_priority[%d]: entering finish state\n", p->id); |
| 698 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&p->finish_barriercxx . . $ group_parameters#finish_barrier.); |
| 699 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 700 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 701 | ("med_priority[%d]: pthread_barrier_wait(finished): %x", |
| 702 | p->id, status); |
| 703 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 704 | } |
| 705 | } |
| 706 | set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(); |
| 707 | |
| 708 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("med_priority[%d]: entering done barrier\n", p->id); |
| 709 | /* wait for all threads to finish */ |
| 710 | if (have_errorscxx . . $ have_errors. == 0) { |
| 711 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&all_threads_donecxx . . $ all_threads_done.); |
| 712 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 713 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 714 | ("med_priority[%d]: pthread_barrier_wait(all_threads_done): %x", |
| 715 | p->id, status); |
| 716 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 717 | } |
| 718 | } |
| 719 | /* exit */ |
| 720 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("med_priority[%d]: exiting\n", p->id); |
| 721 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 722 | } |
| 723 | |
| 724 | void *high_prioritycxx . . $ high_priority(9f162e79bfc6c74).(void *arg) |
| 725 | { |
| 726 | int status; |
| 727 | int unbounded; |
| 728 | unsigned long count = 0; |
| 729 | struct group_parameterscxx . . $ group_parameters# *p = (struct group_parameterscxx . . $ group_parameters# *)arg; |
| 730 | pthread_barrier_tcxx . . $ pthread_barrier_t# *loop_barr = &p->loop_barrcxx . . $ group_parameters#loop_barr.; |
| 731 | pthread_mutex_tcxx . . $ pthread_mutex_t# *loop_mtx = &p->loop_mtxcxx . . $ group_parameters#loop_mtx.; |
| 732 | int *loop = &p->loopcxx . . $ group_parameters#loop.; |
| 733 | cpu_set_tcxx . . $ cpu_set_t# cpu_mask; |
| 734 | int i; |
| 735 | |
| 736 | if (high_sacxx . . $ high_sa..sched_policycxx . . $ sched_attr#sched_policy. == SCHED_DEADLINEcxx . . $ `<external>/4872883757279652994/sched.h:36:10`!) { |
| 737 | CPU_ZEROcxx . . $ `<external>/17522079545615609418/sched.h:96:10`!(&cpu_mask); |
| 738 | for (i = 0; i < num_processorscxx . . $ num_processors.; i++) |
| 739 | CPU_SETcxx . . $ `<external>/17522079545615609418/sched.h:92:10`!(i, &cpu_mask); |
| 740 | status = sched_setaffinitycxx . . $ sched_setaffinity(48631566441f33fb).(0, sizeof(cpu_set_tcxx . . $ cpu_set_t#), &cpu_mask); |
| 741 | if (status < 0) { |
| 742 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 743 | ("high_priority[%d]: set cpu affinity*dl): %x\n", |
| 744 | p->id, status); |
| 745 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 746 | } |
| 747 | |
| 748 | status = sched_setattrcxx . . $ sched_setattr(855aa5bf0081d6b3).(gettidcxx . . $ gettid(b126dc7c1de90089).(), &high_sacxx . . $ high_sa., 0); |
| 749 | if (status < 0) { |
| 750 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 751 | ("high_priority[%d]: sched_setattr(dl): %x\n", |
| 752 | p->id, status); |
| 753 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | allow_sigtermcxx . . $ allow_sigterm(b126dc7c1de90089).(); |
| 758 | if (verify_cpucxx . . $ verify_cpu(7864480464b09eea).(p->cpucxx . . $ group_parameters#cpu.) != SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!) { |
| 759 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("high_priority[%d]: not bound to %ld\n", p->id, p->cpu); |
| 760 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 761 | } |
| 762 | |
| 763 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("high_priority[%d]: entering ready state\n", p->id); |
| 764 | |
| 765 | /* wait for all threads to be ready */ |
| 766 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&all_threads_readycxx . . $ all_threads_ready.); |
| 767 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 768 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 769 | ("high_priority[%d]: pthread_barrier_wait(all_threads_ready): %x", |
| 770 | p->id, status); |
| 771 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 772 | } |
| 773 | unbounded = (p->inversionscxx . . $ group_parameters#inversions. < 0); |
| 774 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("high_priority[%d]: starting inversion loop\n", p->id); |
| 775 | for (;;) { |
| 776 | if (!unbounded && (p->totalcxx . . $ group_parameters#total. >= (unsigned int)p->inversionscxx . . $ group_parameters#inversions.)) { |
| 777 | set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(); |
| 778 | } |
| 779 | |
| 780 | /* Either all threads go through the loop_barr, or none do */ |
| 781 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(loop_mtx); |
| 782 | if (*loop == 0) { |
| 783 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(loop_mtx); |
| 784 | break; |
| 785 | } |
| 786 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(loop_mtx); |
| 787 | |
| 788 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(loop_barr); |
| 789 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 790 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("%s[%d]: pthread_barrier_wait(loop): %x\n", |
| 791 | __func__, p->id, status); |
| 792 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 793 | } |
| 794 | |
| 795 | /* Only one Thread needs to check the shutdown status */ |
| 796 | if (status == PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 797 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 798 | if (shutdowncxx . . $ shutdown.) { |
| 799 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(loop_mtx); |
| 800 | *loop = 0; |
| 801 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(loop_mtx); |
| 802 | } |
| 803 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 804 | } |
| 805 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("high_priority[%d]: entering start state (%d)\n", p->id, |
| 806 | count++); |
| 807 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&p->start_barriercxx . . $ group_parameters#start_barrier.); |
| 808 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 809 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 810 | ("high_priority[%d]: pthread_barrier_wait(start): %x", |
| 811 | p->id, status); |
| 812 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 813 | } |
| 814 | |
| 815 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("high_priority[%d]: entering running state\n", p->id); |
| 816 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&p->locked_barriercxx . . $ group_parameters#locked_barrier.); |
| 817 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 818 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 819 | ("high_priority[%d]: pthread_barrier_wait(running): %x", |
| 820 | p->id, status); |
| 821 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 822 | } |
| 823 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("high_priority[%d]: locking mutex\n", p->id); |
| 824 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&p->mutexcxx . . $ group_parameters#mutex.); |
| 825 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("high_priority[%d]: got mutex\n", p->id); |
| 826 | |
| 827 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("high_priority[%d]: unlocking mutex\n", p->id); |
| 828 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&p->mutexcxx . . $ group_parameters#mutex.); |
| 829 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("high_priority[%d]: entering finish state\n", p->id); |
| 830 | |
| 831 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&p->finish_barriercxx . . $ group_parameters#finish_barrier.); |
| 832 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 833 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 834 | ("high_priority[%d]: pthread_barrier_wait(finish): %x", p->id, status); |
| 835 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 836 | } |
| 837 | /* update the group stats */ |
| 838 | p->totalcxx . . $ group_parameters#total.++; |
| 839 | |
| 840 | /* update the watchdog counter */ |
| 841 | p->watchdogcxx . . $ group_parameters#watchdog.++; |
| 842 | |
| 843 | } |
| 844 | set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(); |
| 845 | |
| 846 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("high_priority[%d]: entering done barrier\n", p->id); |
| 847 | |
| 848 | if (have_errorscxx . . $ have_errors. == 0) { |
| 849 | /* wait for all threads to finish */ |
| 850 | status = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&all_threads_donecxx . . $ all_threads_done.); |
| 851 | if (status && status != PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!) { |
| 852 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`! |
| 853 | ("high_priority[%d]: pthread_barrier_wait(all_threads_done): %x", |
| 854 | p->id, status); |
| 855 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 856 | } |
| 857 | } |
| 858 | /* exit */ |
| 859 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("high_priority[%d]: exiting\n", p->id); |
| 860 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 861 | } |
| 862 | |
| 863 | void usagecxx . . $ usage(d4f767463ce0a6b3).(int error) |
| 864 | { |
| 865 | printfcxx . . $ printf(581fddd72a8db8fc).("pi_stress V %1.2f\n", VERSIONcxx . . $ `<built-in>:412:9`!); |
| 866 | printfcxx . . $ printf(581fddd72a8db8fc).("Usage:\n" |
| 867 | "pi_stress <options>\n\n" |
| 868 | "-d --debug turn on debug prints\n" |
| 869 | "-D TIME --duration=TIME length of test run in seconds (default is infinite)\n" |
| 870 | " Append 'm', 'h', or 'd'\n" |
| 871 | " to specify minutes, hours or days.\n" |
| 872 | "-g N --groups=N set the number of inversion groups\n" |
| 873 | "-h --help print this message\n" |
| 874 | "-i INV --inversions=INV number of inversions per group (default is infinite)\n" |
| 875 | " --json=FILENAME write final results into FILENAME, JSON formatted\n" |
| 876 | "-m --mlockall lock current and future memory\n" |
| 877 | "-p --prompt prompt before starting the test\n" |
| 878 | "-q --quiet suppress running output\n" |
| 879 | "-r --rr use SCHED_RR for test threads [SCHED_FIFO]\n" |
| 880 | "-s OPTS --sched OPTS scheduling options per thread type:\n" |
| 881 | " id=[high|med|low] select thread\n" |
| 882 | " ,policy=[fifo,rr] scheduling class [SCHED_FIFO, SCHED_RR]\n" |
| 883 | " ,priority=N scheduling priority\n" |
| 884 | " ,policy=[deadline] scheduling class [DEADLINE]\n" |
| 885 | " ,runtime=N\n" |
| 886 | " ,deadline=N\n" |
| 887 | " ,period=N\n" |
| 888 | "-u --uniprocessor force all threads to run on one processor\n" |
| 889 | "-v --verbose lots of output\n" |
| 890 | "-V --version print version number on output\n" |
| 891 | ); |
| 892 | exitcxx . . $ exit(3ca292c338df9bb3).(error); |
| 893 | } |
| 894 | |
| 895 | /* block all signals (called from main) */ |
| 896 | int block_signalscxx . . $ block_signals(b126dc7c1de90089).(void) |
| 897 | { |
| 898 | int status; |
| 899 | sigset_tcxx . . $ sigset_t# sigset; |
| 900 | |
| 901 | /* mask off all signals */ |
| 902 | status = sigfillsetcxx . . $ sigfillset(f9c066a8ff75ee9d).(&sigset); |
| 903 | if (status) { |
| 904 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("setting up full signal set %s\n", strerror(status)); |
| 905 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 906 | } |
| 907 | status = pthread_sigmaskcxx . . $ pthread_sigmask(7504382baa173b1).(SIG_BLOCKcxx . . $ `<external>/16635209305659446502/sigaction.h:79:9`!, &sigset, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 908 | if (status) { |
| 909 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("setting signal mask: %s\n", strerror(status)); |
| 910 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 911 | } |
| 912 | return SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 913 | } |
| 914 | |
| 915 | /* allow SIGTERM delivery (called from worker threads) */ |
| 916 | int allow_sigtermcxx . . $ allow_sigterm(b126dc7c1de90089).(void) |
| 917 | { |
| 918 | int status; |
| 919 | sigset_tcxx . . $ sigset_t# sigset; |
| 920 | |
| 921 | status = sigemptysetcxx . . $ sigemptyset(f9c066a8ff75ee9d).(&sigset); |
| 922 | if (status) { |
| 923 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("creating empty signal set: %s\n", strerror(status)); |
| 924 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 925 | } |
| 926 | status = sigaddsetcxx . . $ sigaddset(4917c6e3ecb7dbd5).(&sigset, SIGTERMcxx . . $ `<external>/11773118241360591791/signum-generic.h:53:9`!); |
| 927 | if (status) { |
| 928 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("adding SIGTERM to signal set: %s\n", strerror(status)); |
| 929 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 930 | } |
| 931 | status = pthread_sigmaskcxx . . $ pthread_sigmask(7504382baa173b1).(SIG_UNBLOCKcxx . . $ `<external>/16635209305659446502/sigaction.h:80:9`!, &sigset, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 932 | if (status) { |
| 933 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("unblocking SIGTERM: %s\n", strerror(status)); |
| 934 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 935 | } |
| 936 | return SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 937 | } |
| 938 | |
| 939 | /* clean up before exiting */ |
| 940 | void set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(void) |
| 941 | { |
| 942 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 943 | if (shutdowncxx . . $ shutdown. == 0) { |
| 944 | /* tell anyone that's looking that we're done */ |
| 945 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("setting shutdown flag\n"); |
| 946 | shutdowncxx . . $ shutdown. = 1; |
| 947 | } |
| 948 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&shutdown_mtxcxx . . $ shutdown_mtx.); |
| 949 | } |
| 950 | |
| 951 | /* set up a test group */ |
| 952 | int initialize_groupcxx . . $ initialize_group(5723616408aa12db).(struct group_parameterscxx . . $ group_parameters# *group) |
| 953 | { |
| 954 | int status; |
| 955 | pthread_mutexattr_tcxx . . $ pthread_mutexattr_t# mutex_attr; |
| 956 | |
| 957 | group->inversionscxx . . $ group_parameters#inversions. = inversionscxx . . $ inversions.; |
| 958 | |
| 959 | /* setup default attributes for the group mutex */ |
| 960 | /* (make it a PI mutex) */ |
| 961 | status = pthread_mutexattr_initcxx . . $ pthread_mutexattr_init(7099fa328d29ec1).(&mutex_attr); |
| 962 | if (status) { |
| 963 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("initializing mutex attribute: %s\n", strerror(status)); |
| 964 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 965 | } |
| 966 | |
| 967 | /* set priority inheritance attribute for mutex */ |
| 968 | status = pthread_mutexattr_setprotocolcxx . . $ pthread_mutexattr_setprotocol(490643a50482da1c).(&mutex_attr, |
| 969 | PTHREAD_PRIO_INHERITcxx . . $ PTHREAD_PRIO_INHERIT.); |
| 970 | if (status) { |
| 971 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("setting mutex attribute policy: %s\n", strerror(status)); |
| 972 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 973 | } |
| 974 | /* initialize the group mutex */ |
| 975 | status = pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa).(&group->mutexcxx . . $ group_parameters#mutex., &mutex_attr); |
| 976 | if (status) { |
| 977 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("initializing mutex: %s\n", strerror(status)); |
| 978 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 979 | } |
| 980 | |
| 981 | /* initialize the group barriers */ |
| 982 | if (barrier_initcxx . . $ barrier_init(f9df304b61f441a4).(&group->start_barriercxx . . $ group_parameters#start_barrier., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NUM_TEST_THREADScxx . . $ `src/include/pi_stress.h:55:9`!, |
| 983 | "start_barrier")) |
| 984 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 985 | |
| 986 | if (barrier_initcxx . . $ barrier_init(f9df304b61f441a4).(&group->locked_barriercxx . . $ group_parameters#locked_barrier., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 2, "locked_barrier")) |
| 987 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 988 | |
| 989 | if (barrier_initcxx . . $ barrier_init(f9df304b61f441a4).(&group->elevate_barriercxx . . $ group_parameters#elevate_barrier., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 2, "elevate_barrier")) |
| 990 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 991 | |
| 992 | if (barrier_initcxx . . $ barrier_init(f9df304b61f441a4). |
| 993 | (&group->finish_barriercxx . . $ group_parameters#finish_barrier., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NUM_TEST_THREADScxx . . $ `src/include/pi_stress.h:55:9`!, "finish_barrier")) |
| 994 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 995 | |
| 996 | if (barrier_initcxx . . $ barrier_init(f9df304b61f441a4).(&group->loop_barrcxx . . $ group_parameters#loop_barr., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NUM_TEST_THREADScxx . . $ `src/include/pi_stress.h:55:9`!, |
| 997 | "loop_barrier")) |
| 998 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 999 | |
| 1000 | status = pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa).(&group->loop_mtxcxx . . $ group_parameters#loop_mtx., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1001 | if (status) { |
| 1002 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("pthread_mutex_init, status = %d\n", status); |
| 1003 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1004 | } |
| 1005 | |
| 1006 | status = pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&group->loop_mtxcxx . . $ group_parameters#loop_mtx.); |
| 1007 | if (status) { |
| 1008 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("pthread_mutex_lock, status = %d\n", status); |
| 1009 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1010 | } |
| 1011 | |
| 1012 | group->loopcxx . . $ group_parameters#loop. = 1; |
| 1013 | |
| 1014 | status = pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&group->loop_mtxcxx . . $ group_parameters#loop_mtx.); |
| 1015 | if (status) { |
| 1016 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("pthread_mutex_unlock, status = %d\n", status); |
| 1017 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1018 | } |
| 1019 | |
| 1020 | return SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 1021 | } |
| 1022 | |
| 1023 | /* setup and create a groups threads */ |
| 1024 | int create_groupcxx . . $ create_group(5723616408aa12db).(struct group_parameterscxx . . $ group_parameters# *group) |
| 1025 | { |
| 1026 | int status; |
| 1027 | pthread_attr_tcxx . . $ pthread_attr_t# thread_attr; |
| 1028 | cpu_set_tcxx . . $ cpu_set_t# mask; |
| 1029 | |
| 1030 | /* initialize group structure */ |
| 1031 | status = initialize_groupcxx . . $ initialize_group(5723616408aa12db).(group); |
| 1032 | if (status) { |
| 1033 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("initializing group %d\n", group->id); |
| 1034 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1035 | } |
| 1036 | |
| 1037 | CPU_ZEROcxx . . $ `<external>/17522079545615609418/sched.h:96:10`!(&mask); |
| 1038 | CPU_SETcxx . . $ `<external>/17522079545615609418/sched.h:92:10`!(group->cpu, &mask); |
| 1039 | |
| 1040 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("group %d bound to cpu %ld\n", group->id, group->cpu); |
| 1041 | |
| 1042 | /* start the low priority thread */ |
| 1043 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("creating low priority thread\n"); |
| 1044 | if (setup_thread_attrcxx . . $ setup_thread_attr(1f85186bfce73196).(&thread_attr, &low_sacxx . . $ low_sa., &mask)) |
| 1045 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1046 | status = pthread_createcxx . . $ pthread_create(2141a84bcac899e5).(&group->low_tidcxx . . $ group_parameters#low_tid., |
| 1047 | &thread_attr, low_prioritycxx . . $ low_priority(9f162e79bfc6c74)., group); |
| 1048 | if (status != 0) { |
| 1049 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("creating low_priority thread: %s\n", strerror(status)); |
| 1050 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1051 | } |
| 1052 | |
| 1053 | /* create the medium priority thread */ |
| 1054 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("creating medium priority thread\n"); |
| 1055 | if (setup_thread_attrcxx . . $ setup_thread_attr(1f85186bfce73196).(&thread_attr, &med_sacxx . . $ med_sa., &mask)) |
| 1056 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1057 | status = pthread_createcxx . . $ pthread_create(2141a84bcac899e5).(&group->med_tidcxx . . $ group_parameters#med_tid., |
| 1058 | &thread_attr, med_prioritycxx . . $ med_priority(9f162e79bfc6c74)., group); |
| 1059 | if (status != 0) { |
| 1060 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("creating med_priority thread: %s\n", strerror(status)); |
| 1061 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1062 | } |
| 1063 | |
| 1064 | /* create the high priority thread */ |
| 1065 | pi_debugcxx . . $ `src/include/pi_stress.h:50:9`!("creating high priority thread\n"); |
| 1066 | if (setup_thread_attrcxx . . $ setup_thread_attr(1f85186bfce73196).(&thread_attr, &high_sacxx . . $ high_sa., &mask)) |
| 1067 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1068 | status = pthread_createcxx . . $ pthread_create(2141a84bcac899e5).(&group->high_tidcxx . . $ group_parameters#high_tid., |
| 1069 | &thread_attr, high_prioritycxx . . $ high_priority(9f162e79bfc6c74)., group); |
| 1070 | if (status != 0) { |
| 1071 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("creating high_priority thread: %s\n", strerror(status)); |
| 1072 | set_shutdown_flagcxx . . $ set_shutdown_flag(49f6e7a06ebc5aa8).(); |
| 1073 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1074 | } |
| 1075 | return SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 1076 | } |
| 1077 | |
| 1078 | unsigned long parse_unsignedcxx . . $ parse_unsigned(751346f8406fd082).(const char *str) |
| 1079 | { |
| 1080 | unsigned long n; |
| 1081 | char *p; |
| 1082 | |
| 1083 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 1084 | n = strtoulcxx . . $ strtoul(31746e8d6ec49860).(str, &p, 10); |
| 1085 | |
| 1086 | if ((errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`! && n == ULONG_MAXcxx . . $ `<external>/67164224788392828/limits.h:135:9`!) |
| 1087 | || (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0 && n == 0)) { |
| 1088 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("parsing number failed: %s\n", str); |
| 1089 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!); |
| 1090 | } |
| 1091 | |
| 1092 | return n; |
| 1093 | } |
| 1094 | |
| 1095 | long parse_signedcxx . . $ parse_signed(3c95bd14d5d5d286).(const char *str) |
| 1096 | { |
| 1097 | long n; |
| 1098 | char *p; |
| 1099 | |
| 1100 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 1101 | n = strtolcxx . . $ strtol(44bbb87609b212fc).(str, &p, 10); |
| 1102 | |
| 1103 | if ((errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`! && (n == LONG_MAXcxx . . $ `<external>/67164224788392828/limits.h:131:9`! || n == LONG_MINcxx . . $ `<external>/67164224788392828/limits.h:129:9`!)) |
| 1104 | || (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0 && n == 0)) { |
| 1105 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("parsing number failed: %s\n", str); |
| 1106 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!); |
| 1107 | } |
| 1108 | |
| 1109 | return n; |
| 1110 | } |
| 1111 | |
| 1112 | int process_sched_linecxx . . $ process_sched_line(5c4306d8553b3696).(const char *arg) |
| 1113 | { |
| 1114 | char *buf, *k, *v; |
| 1115 | const char del[] = ",="; |
| 1116 | struct sched_attrcxx . . $ sched_attr# sa = { 0, }; |
| 1117 | char *id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1118 | int retval = SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 1119 | |
| 1120 | buf = strdupacxx . . $ `<external>/13506128340496143423/string.h:201:10`!(arg); |
| 1121 | |
| 1122 | k = strsepcxx . . $ strsep(f4782bac5b8a260e).(&buf, del); |
| 1123 | while (k) { |
| 1124 | v = strsepcxx . . $ strsep(f4782bac5b8a260e).(&buf, del); |
| 1125 | if (!v) |
| 1126 | break; |
| 1127 | |
| 1128 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(k, "id")) |
| 1129 | id = v; |
| 1130 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(k, "policy")) |
| 1131 | sa.sched_policycxx . . $ sched_attr#sched_policy. = string_to_policycxx . . $ string_to_policy(c61c63047ce273de).(v); |
| 1132 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(k, "nice")) |
| 1133 | sa.sched_nicecxx . . $ sched_attr#sched_nice. = parse_signedcxx . . $ parse_signed(3c95bd14d5d5d286).(v); |
| 1134 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(k, "priority")) |
| 1135 | sa.sched_prioritycxx . . $ `<external>/17522079545615609418/sched.h:47:9`! = parse_unsignedcxx . . $ parse_unsigned(751346f8406fd082).(v); |
| 1136 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(k, "runtime")) |
| 1137 | sa.sched_runtimecxx . . $ sched_attr#sched_runtime. = parse_unsignedcxx . . $ parse_unsigned(751346f8406fd082).(v); |
| 1138 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(k, "deadline")) |
| 1139 | sa.sched_deadlinecxx . . $ sched_attr#sched_deadline. = parse_unsignedcxx . . $ parse_unsigned(751346f8406fd082).(v); |
| 1140 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(k, "period")) |
| 1141 | sa.sched_periodcxx . . $ sched_attr#sched_period. = parse_unsignedcxx . . $ parse_unsigned(751346f8406fd082).(v); |
| 1142 | |
| 1143 | k = strsepcxx . . $ strsep(f4782bac5b8a260e).(&buf, del); |
| 1144 | } |
| 1145 | |
| 1146 | if (!id) |
| 1147 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1148 | |
| 1149 | /* |
| 1150 | * We do not validate the options, instead we pass all garbage |
| 1151 | * to the kernel and see what's happening |
| 1152 | */ |
| 1153 | |
| 1154 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(id, "low")) { |
| 1155 | memcpycxx . . $ memcpy(cc817cb175f282d).(&low_sacxx . . $ low_sa., &sa, sizeof(struct sched_attrcxx . . $ sched_attr#)); |
| 1156 | sa_initializedcxx . . $ sa_initialized. |= SA_INIT_LOWcxx . . $ `src/include/pi_stress.h:58:9`!; |
| 1157 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(id, "med")) { |
| 1158 | memcpycxx . . $ memcpy(cc817cb175f282d).(&med_sacxx . . $ med_sa., &sa, sizeof(struct sched_attrcxx . . $ sched_attr#)); |
| 1159 | sa_initializedcxx . . $ sa_initialized. |= SA_INIT_MEDcxx . . $ `src/include/pi_stress.h:59:9`!; |
| 1160 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(id, "high")) { |
| 1161 | memcpycxx . . $ memcpy(cc817cb175f282d).(&high_sacxx . . $ high_sa., &sa, sizeof(struct sched_attrcxx . . $ sched_attr#)); |
| 1162 | sa_initializedcxx . . $ sa_initialized. |= SA_INIT_HIGHcxx . . $ `src/include/pi_stress.h:60:9`!; |
| 1163 | } else { |
| 1164 | retval = FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1165 | } |
| 1166 | |
| 1167 | return retval; |
| 1168 | } |
| 1169 | |
| 1170 | enum option_valuescxx . . $ option_values# { |
| 1171 | OPT_DEBUGcxx . . $ OPT_DEBUG.=1, OPT_DURATIONcxx . . $ OPT_DURATION., OPT_GROUPScxx . . $ OPT_GROUPS., OPT_HELPcxx . . $ OPT_HELP., OPT_INVERSIONScxx . . $ OPT_INVERSIONS., |
| 1172 | OPT_JSONcxx . . $ OPT_JSON., OPT_MLOCKALLcxx . . $ OPT_MLOCKALL., OPT_PROMPTcxx . . $ OPT_PROMPT., OPT_QUIETcxx . . $ OPT_QUIET., OPT_RRcxx . . $ OPT_RR., OPT_SCHEDcxx . . $ OPT_SCHED., |
| 1173 | OPT_UNIPROCESSORcxx . . $ OPT_UNIPROCESSOR., OPT_VERBOSEcxx . . $ OPT_VERBOSE., OPT_VERSIONcxx . . $ OPT_VERSION., |
| 1174 | }; |
| 1175 | |
| 1176 | void process_command_linecxx . . $ process_command_line(c759356ac01a31e7).(int argc, char **argv) |
| 1177 | { |
| 1178 | for (;;) { |
| 1179 | struct optioncxx . . $ option# options[] = { |
| 1180 | {"debug", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_DEBUGcxx . . $ OPT_DEBUG.}, |
| 1181 | {"duration", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_DURATIONcxx . . $ OPT_DURATION.}, |
| 1182 | {"groups", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_GROUPScxx . . $ OPT_GROUPS.}, |
| 1183 | {"help", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_HELPcxx . . $ OPT_HELP.}, |
| 1184 | {"inversions", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_INVERSIONScxx . . $ OPT_INVERSIONS.}, |
| 1185 | {"json", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_JSONcxx . . $ OPT_JSON.}, |
| 1186 | {"mlockall", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_MLOCKALLcxx . . $ OPT_MLOCKALL.}, |
| 1187 | {"prompt", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_PROMPTcxx . . $ OPT_PROMPT.}, |
| 1188 | {"quiet", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_QUIETcxx . . $ OPT_QUIET.}, |
| 1189 | {"rr", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_RRcxx . . $ OPT_RR.}, |
| 1190 | {"sched", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_SCHEDcxx . . $ OPT_SCHED.}, |
| 1191 | {"uniprocessor", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_UNIPROCESSORcxx . . $ OPT_UNIPROCESSOR.}, |
| 1192 | {"verbose", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_VERBOSEcxx . . $ OPT_VERBOSE.}, |
| 1193 | {"version", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_VERSIONcxx . . $ OPT_VERSION.}, |
| 1194 | {NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0}, |
| 1195 | }; |
| 1196 | |
| 1197 | int c = getopt_longcxx . . $ getopt_long(41f665c090816971).(argc, argv, "+hD:vqi:g:rs:pdVum", options, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1198 | if (c == -1) |
| 1199 | break; |
| 1200 | switch (c) { |
| 1201 | case OPT_DEBUGcxx . . $ OPT_DEBUG.: |
| 1202 | case 'd': |
| 1203 | debuggingcxx . . $ debugging. = 1; |
| 1204 | break; |
| 1205 | case OPT_DURATIONcxx . . $ OPT_DURATION.: |
| 1206 | case 'D': |
| 1207 | durationcxx . . $ duration. = parse_time_stringcxx . . $ parse_time_string(1ef8e6ec083aabb9).(optargcxx . . $ optarg.); |
| 1208 | break; |
| 1209 | case OPT_GROUPScxx . . $ OPT_GROUPS.: |
| 1210 | case 'g': |
| 1211 | ngroupscxx . . $ ngroups. = strtolcxx . . $ strtol(44bbb87609b212fc).(optargcxx . . $ optarg., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 10); |
| 1212 | if (ngroupscxx . . $ ngroups. > num_processorscxx . . $ num_processors.) { |
| 1213 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("the number of groups cannot exceed the number of online processors (%ld)\n", num_processors); |
| 1214 | exitcxx . . $ exit(3ca292c338df9bb3).(-1); |
| 1215 | } |
| 1216 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("number of groups set to %d\n", ngroups); |
| 1217 | break; |
| 1218 | case OPT_HELPcxx . . $ OPT_HELP.: |
| 1219 | case 'h': |
| 1220 | usagecxx . . $ usage(d4f767463ce0a6b3).(0); |
| 1221 | break; |
| 1222 | case OPT_INVERSIONScxx . . $ OPT_INVERSIONS.: |
| 1223 | case 'i': |
| 1224 | inversionscxx . . $ inversions. = strtolcxx . . $ strtol(44bbb87609b212fc).(optargcxx . . $ optarg., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 10); |
| 1225 | pi_infocxx . . $ `src/include/pi_stress.h:48:9`!("doing %d inversion per group\n", inversions); |
| 1226 | break; |
| 1227 | case OPT_JSONcxx . . $ OPT_JSON.: |
| 1228 | strncpycxx . . $ strncpy(255158a415b673b0).(jsonfilecxx . . $ jsonfile., optargcxx . . $ optarg., strnlencxx . . $ strnlen(ac5a385650b4bde5).(optargcxx . . $ optarg., MAX_PATHcxx . . $ `src/include/rt-utils.h:9:9`!-1)); |
| 1229 | break; |
| 1230 | case OPT_MLOCKALLcxx . . $ OPT_MLOCKALL.: |
| 1231 | case 'm': |
| 1232 | lockallcxx . . $ lockall. = 1; |
| 1233 | break; |
| 1234 | case OPT_PROMPTcxx . . $ OPT_PROMPT.: |
| 1235 | case 'p': |
| 1236 | promptcxx . . $ prompt. = 1; |
| 1237 | break; |
| 1238 | case OPT_QUIETcxx . . $ OPT_QUIET.: |
| 1239 | case 'q': |
| 1240 | verbosecxx . . $ verbose. = 0; |
| 1241 | quietcxx . . $ quiet. = 1; |
| 1242 | break; |
| 1243 | case OPT_RRcxx . . $ OPT_RR.: |
| 1244 | case 'r': |
| 1245 | policycxx . . $ policy. = SCHED_RRcxx . . $ `<external>/4872883757279652994/sched.h:30:9`!; |
| 1246 | break; |
| 1247 | case OPT_SCHEDcxx . . $ OPT_SCHED.: |
| 1248 | case 's': |
| 1249 | if (process_sched_linecxx . . $ process_sched_line(5c4306d8553b3696).(optargcxx . . $ optarg.)) |
| 1250 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("ignoring invalid options '%s'\n", optarg); |
| 1251 | break; |
| 1252 | case OPT_UNIPROCESSORcxx . . $ OPT_UNIPROCESSOR.: |
| 1253 | case 'u': |
| 1254 | uniprocessorcxx . . $ uniprocessor. = 1; |
| 1255 | break; |
| 1256 | case OPT_VERBOSEcxx . . $ OPT_VERBOSE.: |
| 1257 | case 'v': |
| 1258 | verbosecxx . . $ verbose. = 1; |
| 1259 | quietcxx . . $ quiet. = 0; |
| 1260 | break; |
| 1261 | case OPT_VERSIONcxx . . $ OPT_VERSION.: |
| 1262 | case 'V': |
| 1263 | printfcxx . . $ printf(581fddd72a8db8fc).("pi_stress v%1.2f ", VERSIONcxx . . $ `<built-in>:412:9`!); |
| 1264 | exitcxx . . $ exit(3ca292c338df9bb3).(0); |
| 1265 | default: |
| 1266 | usagecxx . . $ usage(d4f767463ce0a6b3).(1); |
| 1267 | break; |
| 1268 | } |
| 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | /* total the number of inversions that have been performed */ |
| 1273 | unsigned long total_inversionscxx . . $ total_inversions(f708dce9a8856c70).(void) |
| 1274 | { |
| 1275 | int i; |
| 1276 | unsigned long total = 0; |
| 1277 | |
| 1278 | for (i = 0; i < ngroupscxx . . $ ngroups.; i++) |
| 1279 | total += groupscxx . . $ groups.[i].totalcxx . . $ group_parameters#total.; |
| 1280 | return total; |
| 1281 | } |
| 1282 | |
| 1283 | void print_sched_attrcxx . . $ print_sched_attr(6c3f9ef6776f5fbd).(const char *name, struct sched_attrcxx . . $ sched_attr# *sa) |
| 1284 | { |
| 1285 | printfcxx . . $ printf(581fddd72a8db8fc).(" %6s thread", name); |
| 1286 | printfcxx . . $ printf(581fddd72a8db8fc).(" %s", policy_to_stringcxx . . $ policy_to_string(f7ae7e56280f18ae).(sa->sched_policycxx . . $ sched_attr#sched_policy.)); |
| 1287 | |
| 1288 | switch (sa->sched_policycxx . . $ sched_attr#sched_policy.) { |
| 1289 | case SCHED_OTHERcxx . . $ `<external>/4872883757279652994/sched.h:28:9`!: |
| 1290 | printfcxx . . $ printf(581fddd72a8db8fc).(" nice %d\n", sa->sched_nicecxx . . $ sched_attr#sched_nice.); |
| 1291 | break; |
| 1292 | case SCHED_FIFOcxx . . $ `<external>/4872883757279652994/sched.h:29:9`!: |
| 1293 | case SCHED_RRcxx . . $ `<external>/4872883757279652994/sched.h:30:9`!: |
| 1294 | printfcxx . . $ printf(581fddd72a8db8fc).(" priority %d\n", sa->sched_prioritycxx . . $ `<external>/17522079545615609418/sched.h:47:9`!); |
| 1295 | break; |
| 1296 | case SCHED_DEADLINEcxx . . $ `<external>/4872883757279652994/sched.h:36:10`!: |
| 1297 | printfcxx . . $ printf(581fddd72a8db8fc).(" runtime %llu deadline %llu period %llu\n", |
| 1298 | sa->sched_runtimecxx . . $ sched_attr#sched_runtime., sa->sched_deadlinecxx . . $ sched_attr#sched_deadline., |
| 1299 | sa->sched_periodcxx . . $ sched_attr#sched_period.); |
| 1300 | break; |
| 1301 | } |
| 1302 | } |
| 1303 | |
| 1304 | void bannercxx . . $ banner(49f6e7a06ebc5aa8).(void) |
| 1305 | { |
| 1306 | if (quietcxx . . $ quiet.) |
| 1307 | return; |
| 1308 | |
| 1309 | printfcxx . . $ printf(581fddd72a8db8fc).("Starting PI Stress Test\n"); |
| 1310 | printfcxx . . $ printf(581fddd72a8db8fc).("Number of thread groups: %d\n", ngroupscxx . . $ ngroups.); |
| 1311 | if (durationcxx . . $ duration. >= 0) |
| 1312 | printfcxx . . $ printf(581fddd72a8db8fc).("Duration of test run: %d seconds\n", durationcxx . . $ duration.); |
| 1313 | else |
| 1314 | printfcxx . . $ printf(581fddd72a8db8fc).("Duration of test run: infinite\n"); |
| 1315 | if (inversionscxx . . $ inversions. < 0) |
| 1316 | printfcxx . . $ printf(581fddd72a8db8fc).("Number of inversions per group: unlimited\n"); |
| 1317 | else |
| 1318 | printfcxx . . $ printf(581fddd72a8db8fc).("Number of inversions per group: %d\n", inversionscxx . . $ inversions.); |
| 1319 | print_sched_attrcxx . . $ print_sched_attr(6c3f9ef6776f5fbd).("Admin", &admin_sacxx . . $ admin_sa.); |
| 1320 | printfcxx . . $ printf(581fddd72a8db8fc).("%d groups of 3 threads will be created\n", ngroupscxx . . $ ngroups.); |
| 1321 | print_sched_attrcxx . . $ print_sched_attr(6c3f9ef6776f5fbd).("High", &high_sacxx . . $ high_sa.); |
| 1322 | print_sched_attrcxx . . $ print_sched_attr(6c3f9ef6776f5fbd).("Med", &med_sacxx . . $ med_sa.); |
| 1323 | print_sched_attrcxx . . $ print_sched_attr(6c3f9ef6776f5fbd).("Low", &low_sacxx . . $ low_sa.); |
| 1324 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 1325 | } |
| 1326 | |
| 1327 | void summarycxx . . $ summary(49f6e7a06ebc5aa8).(void) |
| 1328 | { |
| 1329 | time_tcxx . . $ time_t# interval = finishcxx . . $ finish. - startcxx . . $ start.; |
| 1330 | struct tmcxx . . $ tm# *t = gmtimecxx . . $ gmtime(9477a1348abbbc5).(&interval); |
| 1331 | |
| 1332 | printfcxx . . $ printf(581fddd72a8db8fc).("Total inversion performed: %lu\n", total_inversionscxx . . $ total_inversions(f708dce9a8856c70).()); |
| 1333 | printfcxx . . $ printf(581fddd72a8db8fc).("Test Duration: %d days, %d hours, %d minutes, %d seconds\n", |
| 1334 | t->tm_ydaycxx . . $ tm#tm_yday., t->tm_hourcxx . . $ tm#tm_hour., t->tm_mincxx . . $ tm#tm_min., t->tm_seccxx . . $ tm#tm_sec.); |
| 1335 | } |
| 1336 | |
| 1337 | void write_statscxx . . $ write_stats(2fd218767557b4b8).(FILEcxx . . $ FILE# *f, void *data) |
| 1338 | { |
| 1339 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " \"inversion\": %lu\n", total_inversionscxx . . $ total_inversions(f708dce9a8856c70).()); |
| 1340 | } |
| 1341 | |
| 1342 | int |
| 1343 | barrier_initcxx . . $ barrier_init(f9df304b61f441a4).(pthread_barrier_tcxx . . $ pthread_barrier_t# *b, const pthread_barrierattr_tcxx . . $ pthread_barrierattr_t# *attr, |
| 1344 | unsigned int count, const char *name) |
| 1345 | { |
| 1346 | int status; |
| 1347 | |
| 1348 | status = pthread_barrier_initcxx . . $ pthread_barrier_init(4180f681c7d0b92f).(b, attr, count); |
| 1349 | if (status != 0) { |
| 1350 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("barrier_init: failed to initialize: %s\n", name); |
| 1351 | pi_errorcxx . . $ `src/include/pi_stress.h:52:9`!("status = %d\n", status); |
| 1352 | return FAILUREcxx . . $ `src/include/pi_stress.h:42:9`!; |
| 1353 | } |
| 1354 | |
| 1355 | return SUCCESScxx . . $ `src/include/pi_stress.h:41:9`!; |
| 1356 | } |
| 1357 | |
| 1358 | void setup_sched_attrcxx . . $ setup_sched_attr(d876dc12d2dd5b19).(struct sched_attrcxx . . $ sched_attr# *attr, int policy, int prio) |
| 1359 | { |
| 1360 | attr->sched_policycxx . . $ sched_attr#sched_policy. = policy; |
| 1361 | attr->sched_prioritycxx . . $ `<external>/17522079545615609418/sched.h:47:9`! = prio; |
| 1362 | } |
| 1363 | |
| 1364 | void setup_sched_configcxx . . $ setup_sched_config(d4f767463ce0a6b3).(int policy) |
| 1365 | { |
| 1366 | int prio_min; |
| 1367 | |
| 1368 | prio_min = sched_get_priority_mincxx . . $ sched_get_priority_min(7864480464b09eea).(policy); |
| 1369 | |
| 1370 | if (!(sa_initializedcxx . . $ sa_initialized. & SA_INIT_LOWcxx . . $ `src/include/pi_stress.h:58:9`!)) |
| 1371 | setup_sched_attrcxx . . $ setup_sched_attr(d876dc12d2dd5b19).(&low_sacxx . . $ low_sa., policy, prio_min + 0); |
| 1372 | if (!(sa_initializedcxx . . $ sa_initialized. & SA_INIT_MEDcxx . . $ `src/include/pi_stress.h:59:9`!)) |
| 1373 | setup_sched_attrcxx . . $ setup_sched_attr(d876dc12d2dd5b19).(&med_sacxx . . $ med_sa., policy, prio_min + 1); |
| 1374 | if (!(sa_initializedcxx . . $ sa_initialized. & SA_INIT_HIGHcxx . . $ `src/include/pi_stress.h:60:9`!)) |
| 1375 | setup_sched_attrcxx . . $ setup_sched_attr(d876dc12d2dd5b19).(&high_sacxx . . $ high_sa., policy, prio_min + 2); |
| 1376 | if (!(sa_initializedcxx . . $ sa_initialized. & SA_INIT_ADMINcxx . . $ `src/include/pi_stress.h:61:9`!)) |
| 1377 | setup_sched_attrcxx . . $ setup_sched_attr(d876dc12d2dd5b19).(&admin_sacxx . . $ admin_sa., policy, prio_min + 3); |
| 1378 | } |