| 1 | // SPDX-License-Identifier: GPL-2.0-onlycxx . . $ `<file>/src/sched_deadline/cyclicdeadline.c`/ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (C) 2016 Red Hat Inc, Steven Rostedt <[email protected]> |
| 5 | * Copyright (C) 2019 John Kacur <[email protected]> |
| 6 | * Copyright (C) 2019 Clark Williams <[email protected]> |
| 7 | */ |
| 8 | |
| 9 | #include <pthread.h> |
| 10 | #include <stdarg.h> |
| 11 | #include <stdlib.h> |
| 12 | #include <string.h> |
| 13 | #include <unistd.h> |
| 14 | #include <stdio.h> |
| 15 | #include <fcntl.h> |
| 16 | #include <sched.h> |
| 17 | #include <ctype.h> |
| 18 | #include <errno.h> |
| 19 | #include <signal.h> |
| 20 | #include <getopt.h> |
| 21 | |
| 22 | #include <sys/syscall.h> |
| 23 | #include <sys/types.h> |
| 24 | #include <sys/mount.h> |
| 25 | #include <sys/mman.h> |
| 26 | #include <sys/time.h> |
| 27 | #include <sys/stat.h> |
| 28 | #include <sys/vfs.h> |
| 29 | |
| 30 | #include <linux/unistd.h> |
| 31 | #include <linux/magic.h> |
| 32 | |
| 33 | #include "rt-utils.h"cxx . . $ `<file>/src/include/rt-utils.h`/ |
| 34 | #include "rt-sched.h"cxx . . $ `<file>/src/include/rt-sched.h`/ |
| 35 | #include "rt-error.h"cxx . . $ `<file>/src/include/rt-error.h`/ |
| 36 | #include "histogram.h"cxx . . $ `<file>/src/include/histogram.h`/ |
| 37 | |
| 38 | #define _STRcxx . . $ `src/sched_deadline/cyclicdeadline.c:38:9`!(x) #x |
| 39 | #define STRcxx . . $ `src/sched_deadline/cyclicdeadline.c:39:9`!(x) _STRcxx . . $ `src/sched_deadline/cyclicdeadline.c:38:9`!(x) |
| 40 | #ifndef MAXPATH |
| 41 | #define MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! 1024 |
| 42 | #endif |
| 43 | |
| 44 | #define HIST_MAXcxx . . $ `src/sched_deadline/cyclicdeadline.c:44:9`! 1000000 |
| 45 | |
| 46 | #define CPUSET_ALLcxx . . $ `src/sched_deadline/cyclicdeadline.c:46:9`! "my_cpuset_all" |
| 47 | #define CPUSET_LOCALcxx . . $ `src/sched_deadline/cyclicdeadline.c:47:9`! "my_cpuset" |
| 48 | |
| 49 | typedef unsigned long long u64cxx . . $ u64#; |
| 50 | typedef unsigned int u32cxx . . $ u32#; |
| 51 | typedef int s32cxx . . $ s32#; |
| 52 | |
| 53 | /* Struct for statistics */ |
| 54 | struct thread_statcxx . . $ thread_stat# { |
| 55 | unsigned long cyclescxx . . $ thread_stat#cycles.; |
| 56 | long mincxx . . $ thread_stat#min.; |
| 57 | long maxcxx . . $ thread_stat#max.; |
| 58 | long actcxx . . $ thread_stat#act.; |
| 59 | double avgcxx . . $ thread_stat#avg.; |
| 60 | long *valuescxx . . $ thread_stat#values.; |
| 61 | struct histogramcxx . . $ histogram# *histcxx . . $ thread_stat#hist.; |
| 62 | pthread_tcxx . . $ pthread_t# threadcxx . . $ thread_stat#thread.; |
| 63 | int threadstartedcxx . . $ thread_stat#threadstarted.; |
| 64 | int tidcxx . . $ thread_stat#tid.; |
| 65 | long reducecxx . . $ thread_stat#reduce.; |
| 66 | }; |
| 67 | |
| 68 | struct sched_datacxx . . $ sched_data# { |
| 69 | u64cxx . . $ u64# runtime_uscxx . . $ sched_data#runtime_us.; |
| 70 | u64cxx . . $ u64# deadline_uscxx . . $ sched_data#deadline_us.; |
| 71 | |
| 72 | int bufmskcxx . . $ sched_data#bufmsk.; |
| 73 | |
| 74 | struct thread_statcxx . . $ thread_stat# statcxx . . $ sched_data#stat.; |
| 75 | }; |
| 76 | |
| 77 | static int shutdowncxx . . $ shutdown.; |
| 78 | static int info_enablecxx . . $ info_enable.; |
| 79 | static int debug_enablecxx . . $ debug_enable.; |
| 80 | static int tracelimitcxx . . $ tracelimit.; |
| 81 | static int trace_markercxx . . $ trace_marker.; |
| 82 | static int histogramcxx . . $ histogram.; |
| 83 | static FILEcxx . . $ FILE# *histfilecxx . . $ histfile.; |
| 84 | static pthread_mutex_tcxx . . $ pthread_mutex_t# break_thread_id_lockcxx . . $ break_thread_id_lock. = PTHREAD_MUTEX_INITIALIZERcxx . . $ `<external>/14712363683955484316/pthread.h:90:9`!; |
| 85 | static pid_tcxx . . $ pid_t# break_thread_idcxx . . $ break_thread_id.; |
| 86 | static uint64_tcxx . . $ uint64_t# break_thread_valuecxx . . $ break_thread_value.; |
| 87 | static pthread_barrier_tcxx . . $ pthread_barrier_t# barriercxx . . $ barrier.; |
| 88 | |
| 89 | static int cpu_countcxx . . $ cpu_count.; |
| 90 | static int all_cpuscxx . . $ all_cpus.; |
| 91 | static int nr_threadscxx . . $ nr_threads.; |
| 92 | static int use_nsecscxx . . $ use_nsecs.; |
| 93 | static int quietcxx . . $ quiet.; |
| 94 | static char jsonfilecxx . . $ jsonfile.[MAX_PATHcxx . . $ `src/include/rt-utils.h:9:9`!]; |
| 95 | |
| 96 | static struct histosetcxx . . $ histoset# hsetcxx . . $ hset.; |
| 97 | |
| 98 | static int find_mountcxx . . $ find_mount(2f051e3560ff300f).(const char *mount, char *debugfs) |
| 99 | { |
| 100 | char type[100]; |
| 101 | FILEcxx . . $ FILE# *fp; |
| 102 | |
| 103 | if ((fp = fopencxx . . $ fopen(82ec0787cd37e0a3).("/proc/mounts", "r")) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 104 | return 0; |
| 105 | |
| 106 | while (fscanfcxx . . $ fscanf(bc216f8e5b1ebeac).(fp, "%*s %" |
| 107 | STRcxx . . $ `src/sched_deadline/cyclicdeadline.c:39:9`!(MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`!) |
| 108 | "s %99s %*s %*d %*d\n", |
| 109 | debugfs, type) == 2) { |
| 110 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(type, mount) == 0) |
| 111 | break; |
| 112 | } |
| 113 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 114 | |
| 115 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(type, mount) != 0) |
| 116 | return 0; |
| 117 | return 1; |
| 118 | } |
| 119 | |
| 120 | static const char *find_debugfscxx . . $ find_debugfs(33a1f659e94feb42).(void) |
| 121 | { |
| 122 | static int debugfs_found; |
| 123 | static char debugfs[MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`!+1]; |
| 124 | |
| 125 | if (debugfs_found) |
| 126 | return debugfs; |
| 127 | |
| 128 | if (!find_mountcxx . . $ find_mount(2f051e3560ff300f).("debugfs", debugfs)) |
| 129 | return ""; |
| 130 | |
| 131 | debugfs_found = 1; |
| 132 | |
| 133 | return debugfs; |
| 134 | } |
| 135 | |
| 136 | /* |
| 137 | * Return true if file exists |
| 138 | */ |
| 139 | static int check_file_existscxx . . $ check_file_exists(1ef8e6ec083aabb9).(char *path) |
| 140 | { |
| 141 | int ret; |
| 142 | struct statcxx . . $ stat# st; |
| 143 | |
| 144 | ret = !statcxx . . $ stat(a9cd1e23e96f423c).(path, &st); |
| 145 | |
| 146 | return ret; |
| 147 | |
| 148 | } |
| 149 | |
| 150 | /* |
| 151 | * Return 0 on success |
| 152 | */ |
| 153 | |
| 154 | static int fill_sched_featurescxx . . $ fill_sched_features(1ef8e6ec083aabb9).(char *path) |
| 155 | { |
| 156 | int ret; |
| 157 | const char *debugfs; |
| 158 | |
| 159 | debugfs = find_debugfscxx . . $ find_debugfs(33a1f659e94feb42).(); |
| 160 | if (strlencxx . . $ strlen(751346f8406fd082).(debugfs) == 0) |
| 161 | return -1; |
| 162 | |
| 163 | ret = snprintfcxx . . $ snprintf(ea502d73e74c754c).(path, MAX_PATHcxx . . $ `src/include/rt-utils.h:9:9`!, "%s/sched/features", debugfs); |
| 164 | if (ret >= MAX_PATHcxx . . $ `src/include/rt-utils.h:9:9`!) |
| 165 | return -1; |
| 166 | ret = check_file_existscxx . . $ check_file_exists(1ef8e6ec083aabb9).(path); |
| 167 | if (ret) |
| 168 | return 0; |
| 169 | |
| 170 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(path, 0, MAX_PATHcxx . . $ `src/include/rt-utils.h:9:9`!); |
| 171 | return ret; |
| 172 | } |
| 173 | |
| 174 | static int setup_hr_tickcxx . . $ setup_hr_tick(b126dc7c1de90089).(void) |
| 175 | { |
| 176 | char path[MAX_PATHcxx . . $ `src/include/rt-utils.h:9:9`!]; |
| 177 | char buf[500]; |
| 178 | static int set = 0; |
| 179 | int hrtick_dl = 0; |
| 180 | char *p; |
| 181 | int ret; |
| 182 | int len; |
| 183 | int fd; |
| 184 | |
| 185 | if (set) |
| 186 | return 1; |
| 187 | set = 1; |
| 188 | |
| 189 | ret = fill_sched_featurescxx . . $ fill_sched_features(1ef8e6ec083aabb9).(path); |
| 190 | if (ret) |
| 191 | return 0; |
| 192 | |
| 193 | fd = opencxx . . $ open(e156e3aa1e5c4ad1).(path, O_RDWRcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:45:9`!); |
| 194 | if (fd < 0) { |
| 195 | perrorcxx . . $ perror(85c52e162fed56f9).(path); |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | len = sizeof(buf); |
| 200 | |
| 201 | ret = readcxx . . $ read(7e34d0a36f355389).(fd, buf, len); |
| 202 | if (ret < 0) { |
| 203 | perrorcxx . . $ perror(85c52e162fed56f9).(path); |
| 204 | closecxx . . $ close(7864480464b09eea).(fd); |
| 205 | return 0; |
| 206 | } |
| 207 | if (ret >= len) |
| 208 | ret = len - 1; |
| 209 | buf[ret] = 0; |
| 210 | |
| 211 | ret = 1; |
| 212 | |
| 213 | p = strstrcxx . . $ strstr(a713fe7b9a57cf96).(buf, "HRTICK_DL"); |
| 214 | if (p && p - 3 >= buf) { |
| 215 | hrtick_dl = 1; |
| 216 | p -= 3; |
| 217 | if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).(p, "NO_HRTICK_DL", 12) == 0) { |
| 218 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, "HRTICK_DL", 9); |
| 219 | if (ret != 9) |
| 220 | ret = 0; |
| 221 | else |
| 222 | ret = 1; |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | /* Backwards compatibility for kernel that only have HRTICK */ |
| 227 | if (!hrtick_dl) { |
| 228 | p = strstrcxx . . $ strstr(a713fe7b9a57cf96).(buf, "HRTICK"); |
| 229 | if (p && p - 3 >= buf) { |
| 230 | p -=3; |
| 231 | if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).(p, "NO_HRTICK", 9) == 0) { |
| 232 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, "HRTICK", 6); |
| 233 | if (ret != 6) |
| 234 | ret = 0; |
| 235 | else |
| 236 | ret = 1; |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | closecxx . . $ close(7864480464b09eea).(fd); |
| 242 | return ret; |
| 243 | } |
| 244 | |
| 245 | static int mountedcxx . . $ mounted(d9501915370efab1).(const char *path, long magic) |
| 246 | { |
| 247 | struct statfscxx . . $ statfs# st_fs; |
| 248 | |
| 249 | if (statfscxx . . $ statfs(361e01602215989e).(path, &st_fs) < 0) |
| 250 | return -1; |
| 251 | if ((long)st_fs.f_typecxx . . $ statfs#f_type. != magic) |
| 252 | return 0; |
| 253 | return 1; |
| 254 | } |
| 255 | |
| 256 | #define CGROUP_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:256:9`! "/sys/fs/cgroup" |
| 257 | #define CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`! CGROUP_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:256:9`! "/cpuset" |
| 258 | |
| 259 | /** |
| 260 | * cgroup_mounted - test if the path /sys/fs/cgroup exists |
| 261 | * and is a supported type |
| 262 | * |
| 263 | * Returns -1 if the path does not exist |
| 264 | * Returns 0 if the path exists but is not a cgroup type |
| 265 | * Returns 1 if the path exists and supports cgroups |
| 266 | */ |
| 267 | static int cgroup_mountedcxx . . $ cgroup_mounted(b126dc7c1de90089).(void) |
| 268 | { |
| 269 | int ret; |
| 270 | |
| 271 | ret = mountedcxx . . $ mounted(d9501915370efab1).(CGROUP_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:256:9`!, TMPFS_MAGICcxx . . $ `<external>/706109818625493630/magic.h:18:9`!); |
| 272 | if (ret == -1) |
| 273 | return -1; /* path doesn't exist */ |
| 274 | if (ret == 1) |
| 275 | return 1; /* tmpfs */ |
| 276 | ret = mountedcxx . . $ mounted(d9501915370efab1).(CGROUP_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:256:9`!, CGROUP_SUPER_MAGICcxx . . $ `<external>/706109818625493630/magic.h:70:9`!); |
| 277 | if (ret == 1) |
| 278 | return 1; /* cgroup v1 */ |
| 279 | ret = mountedcxx . . $ mounted(d9501915370efab1).(CGROUP_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:256:9`!, CGROUP2_SUPER_MAGICcxx . . $ `<external>/706109818625493630/magic.h:71:9`!); |
| 280 | if (ret == 1) |
| 281 | return 1; /* cgroup v2 */ |
| 282 | return 0; /* path exists but type is not recognized */ |
| 283 | } |
| 284 | |
| 285 | static int open_cpusetcxx . . $ open_cpuset(5ae29d726ae57f88).(const char *path, const char *name) |
| 286 | { |
| 287 | char buf[MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`!]; |
| 288 | struct statcxx . . $ stat# st; |
| 289 | int ret; |
| 290 | int fd; |
| 291 | |
| 292 | buf[MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! - 1] = 0; |
| 293 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! - 1, "%s/%s", path, name); |
| 294 | |
| 295 | ret = statcxx . . $ stat(a9cd1e23e96f423c).(buf, &st); |
| 296 | if (ret < 0) |
| 297 | return ret; |
| 298 | |
| 299 | fd = opencxx . . $ open(e156e3aa1e5c4ad1).(buf, O_WRONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:44:9`!); |
| 300 | return fd; |
| 301 | } |
| 302 | |
| 303 | static int mount_cpusetcxx . . $ mount_cpuset(b126dc7c1de90089).(void) |
| 304 | { |
| 305 | struct statcxx . . $ stat# st; |
| 306 | int ret; |
| 307 | int fd; |
| 308 | |
| 309 | /* Check if cgroups is already mounted. */ |
| 310 | ret = cgroup_mountedcxx . . $ cgroup_mounted(b126dc7c1de90089).(); |
| 311 | if (ret < 0) /* /sys/fs/cgroup doesn't exist */ |
| 312 | return ret; |
| 313 | |
| 314 | if (!ret) /* /sys/fs/cgroup exists, but we don't recognize the type */ |
| 315 | return -1; |
| 316 | |
| 317 | ret = statcxx . . $ stat(a9cd1e23e96f423c).(CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!, &st); |
| 318 | if (ret < 0) { |
| 319 | ret = mkdircxx . . $ mkdir(1df18506ef0a631b).(CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!, 0755); |
| 320 | if (ret < 0) |
| 321 | return ret; |
| 322 | } |
| 323 | ret = mountedcxx . . $ mounted(d9501915370efab1).(CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!, CGROUP_SUPER_MAGICcxx . . $ `<external>/706109818625493630/magic.h:70:9`!); |
| 324 | if (ret < 0) |
| 325 | return ret; |
| 326 | if (!ret) { |
| 327 | ret = mountcxx . . $ mount(710c9fc3e555a477).("cpuset", CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!, "cgroup", 0, "cpuset"); |
| 328 | if (ret < 0) |
| 329 | return ret; |
| 330 | } |
| 331 | |
| 332 | fd = open_cpusetcxx . . $ open_cpuset(5ae29d726ae57f88).(CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!, "cpuset.cpu_exclusive"); |
| 333 | if (fd < 0) |
| 334 | return fd; |
| 335 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, "1", 2); |
| 336 | closecxx . . $ close(7864480464b09eea).(fd); |
| 337 | |
| 338 | fd = open_cpusetcxx . . $ open_cpuset(5ae29d726ae57f88).(CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!, "cpuset.sched_load_balance"); |
| 339 | if (fd < 0) |
| 340 | return fd; |
| 341 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, "0", 2); |
| 342 | if (ret < 0) { |
| 343 | closecxx . . $ close(7864480464b09eea).(fd); |
| 344 | return ret; |
| 345 | } |
| 346 | closecxx . . $ close(7864480464b09eea).(fd); |
| 347 | |
| 348 | return 0; |
| 349 | } |
| 350 | |
| 351 | enumcxx . . $ $anonymous_type_7455b886ab1eb2f7_0# { |
| 352 | CPUSET_FL_CPU_EXCLUSIVEcxx . . $ CPUSET_FL_CPU_EXCLUSIVE. = (1 << 0), |
| 353 | CPUSET_FL_MEM_EXCLUSIVEcxx . . $ CPUSET_FL_MEM_EXCLUSIVE. = (1 << 1), |
| 354 | CPUSET_FL_ALL_TASKScxx . . $ CPUSET_FL_ALL_TASKS. = (1 << 2), |
| 355 | CPUSET_FL_TASKScxx . . $ CPUSET_FL_TASKS. = (1 << 3), |
| 356 | CPUSET_FL_CLEAR_LOADBALANCEcxx . . $ CPUSET_FL_CLEAR_LOADBALANCE. = (1 << 4), |
| 357 | CPUSET_FL_SET_LOADBALANCEcxx . . $ CPUSET_FL_SET_LOADBALANCE. = (1 << 5), |
| 358 | CPUSET_FL_CLONE_CHILDRENcxx . . $ CPUSET_FL_CLONE_CHILDREN. = (1 << 6), |
| 359 | }; |
| 360 | |
| 361 | static void make_cpusetcxx . . $ make_cpuset(7749fb5eed986304).(const char *name, const char *cpus, |
| 362 | const char *mems, unsigned int flags, ...) |
| 363 | { |
| 364 | struct statcxx . . $ stat# st; |
| 365 | char path[MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`!]; |
| 366 | char buf[100]; |
| 367 | va_listcxx . . $ va_list# ap; |
| 368 | int ret; |
| 369 | int fd; |
| 370 | |
| 371 | printfcxx . . $ printf(581fddd72a8db8fc).("Creating cpuset '%s'\n", name); |
| 372 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(path, MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! - 1, "%s/%s", CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!, name); |
| 373 | path[MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! - 1] = 0; |
| 374 | |
| 375 | ret = mount_cpusetcxx . . $ mount_cpuset(b126dc7c1de90089).(); |
| 376 | if (ret < 0) |
| 377 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("mount_cpuset"); |
| 378 | |
| 379 | ret = statcxx . . $ stat(a9cd1e23e96f423c).(path, &st); |
| 380 | if (ret < 0) { |
| 381 | ret = mkdircxx . . $ mkdir(1df18506ef0a631b).(path, 0755); |
| 382 | if (ret < 0) |
| 383 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("mkdir"); |
| 384 | } |
| 385 | |
| 386 | fd = open_cpusetcxx . . $ open_cpuset(5ae29d726ae57f88).(path, "cpuset.cpus"); |
| 387 | if (fd < 0) |
| 388 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("cset"); |
| 389 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, cpus, strlencxx . . $ strlen(751346f8406fd082).(cpus)); |
| 390 | closecxx . . $ close(7864480464b09eea).(fd); |
| 391 | if (ret < 0) |
| 392 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("write cpus"); |
| 393 | |
| 394 | if (mems) { |
| 395 | fd = open_cpusetcxx . . $ open_cpuset(5ae29d726ae57f88).(path, "cpuset.mems"); |
| 396 | if (fd < 0) |
| 397 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("open mems"); |
| 398 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, mems, strlencxx . . $ strlen(751346f8406fd082).(mems)); |
| 399 | closecxx . . $ close(7864480464b09eea).(fd); |
| 400 | if (ret < 0) |
| 401 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("write mems"); |
| 402 | } |
| 403 | |
| 404 | if (flags & CPUSET_FL_CPU_EXCLUSIVEcxx . . $ CPUSET_FL_CPU_EXCLUSIVE.) { |
| 405 | fd = open_cpusetcxx . . $ open_cpuset(5ae29d726ae57f88).(path, "cpuset.cpu_exclusive"); |
| 406 | if (fd < 0) |
| 407 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("open cpu_exclusive"); |
| 408 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, "1", 2); |
| 409 | closecxx . . $ close(7864480464b09eea).(fd); |
| 410 | if (ret < 0) |
| 411 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("write cpu_exclusive"); |
| 412 | } |
| 413 | |
| 414 | if (flags & (CPUSET_FL_CLEAR_LOADBALANCEcxx . . $ CPUSET_FL_CLEAR_LOADBALANCE. | CPUSET_FL_SET_LOADBALANCEcxx . . $ CPUSET_FL_SET_LOADBALANCE.)) { |
| 415 | fd = open_cpusetcxx . . $ open_cpuset(5ae29d726ae57f88).(path, "cpuset.sched_load_balance"); |
| 416 | if (fd < 0) |
| 417 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("open sched_load_balance"); |
| 418 | if (flags & CPUSET_FL_SET_LOADBALANCEcxx . . $ CPUSET_FL_SET_LOADBALANCE.) |
| 419 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, "1", 2); |
| 420 | else |
| 421 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, "0", 2); |
| 422 | closecxx . . $ close(7864480464b09eea).(fd); |
| 423 | if (ret < 0) |
| 424 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("write sched_load_balance"); |
| 425 | } |
| 426 | |
| 427 | if (flags & CPUSET_FL_CLONE_CHILDRENcxx . . $ CPUSET_FL_CLONE_CHILDREN.) { |
| 428 | fd = open_cpusetcxx . . $ open_cpuset(5ae29d726ae57f88).(path, "cgroup.clone_children"); |
| 429 | if (fd < 0) |
| 430 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("open clone_children"); |
| 431 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, "1", 2); |
| 432 | closecxx . . $ close(7864480464b09eea).(fd); |
| 433 | if (ret < 0) |
| 434 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("write clone_children"); |
| 435 | } |
| 436 | |
| 437 | |
| 438 | if (flags & CPUSET_FL_TASKScxx . . $ CPUSET_FL_TASKS.) { |
| 439 | int *pids; |
| 440 | int i; |
| 441 | |
| 442 | va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`!(ap, flags); |
| 443 | |
| 444 | fd = open_cpusetcxx . . $ open_cpuset(5ae29d726ae57f88).(path, "tasks"); |
| 445 | if (fd < 0) |
| 446 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("open tasks"); |
| 447 | |
| 448 | ret = 0; |
| 449 | pids = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`!(ap, int *); |
| 450 | for (i = 0; pids[i]; i++) { |
| 451 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buf, "%d ", pids[i]); |
| 452 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, buf, strlencxx . . $ strlen(751346f8406fd082).(buf)); |
| 453 | } |
| 454 | va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(ap); |
| 455 | closecxx . . $ close(7864480464b09eea).(fd); |
| 456 | if (ret < 0) |
| 457 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("Failed on task %d\n", pids[i]); |
| 458 | } |
| 459 | |
| 460 | if (flags & CPUSET_FL_ALL_TASKScxx . . $ CPUSET_FL_ALL_TASKS.) { |
| 461 | FILEcxx . . $ FILE# *fp; |
| 462 | int pid; |
| 463 | |
| 464 | fd = open_cpusetcxx . . $ open_cpuset(5ae29d726ae57f88).(path, "tasks"); |
| 465 | |
| 466 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(path, MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! - 1, "%s/tasks", CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!); |
| 467 | if ((fp = fopencxx . . $ fopen(82ec0787cd37e0a3).(path, "r")) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 468 | closecxx . . $ close(7864480464b09eea).(fd); |
| 469 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("opening cpuset tasks"); |
| 470 | } |
| 471 | |
| 472 | while (fscanfcxx . . $ fscanf(bc216f8e5b1ebeac).(fp, "%d", &pid) == 1) { |
| 473 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buf, "%d", pid); |
| 474 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, buf, strlencxx . . $ strlen(751346f8406fd082).(buf)); |
| 475 | /* |
| 476 | * Tasks can come and go, the only error we care |
| 477 | * about is ENOSPC, as that means something went |
| 478 | * wrong that we did not expect. |
| 479 | */ |
| 480 | if (ret < 0 && errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == ENOSPCcxx . . $ `<external>/8987895939074593727/errno-base.h:32:9`!) { |
| 481 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 482 | closecxx . . $ close(7864480464b09eea).(fd); |
| 483 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("Can not move tasks"); |
| 484 | } |
| 485 | } |
| 486 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 487 | closecxx . . $ close(7864480464b09eea).(fd); |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | static void destroy_cpusetcxx . . $ destroy_cpuset(34d26762b42c433a).(const char *name, int print) |
| 492 | { |
| 493 | struct statcxx . . $ stat# st; |
| 494 | char path[MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`!]; |
| 495 | char buf[100]; |
| 496 | FILEcxx . . $ FILE# *fp; |
| 497 | int pid; |
| 498 | int ret; |
| 499 | int fd; |
| 500 | int retry = 0; |
| 501 | |
| 502 | printfcxx . . $ printf(581fddd72a8db8fc).("Removing %s\n", name); |
| 503 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(path, MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! - 1, "%s/%s", CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!, name); |
| 504 | path[MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! - 1] = 0; |
| 505 | |
| 506 | ret = statcxx . . $ stat(a9cd1e23e96f423c).(path, &st); |
| 507 | if (ret < 0) |
| 508 | return; |
| 509 | |
| 510 | again: |
| 511 | strncatcxx . . $ strncat(255158a415b673b0).(path, "/tasks", MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! - 1); |
| 512 | if ((fp = fopencxx . . $ fopen(82ec0787cd37e0a3).(path, "r")) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 513 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Failed opening %s\n", path); |
| 514 | perrorcxx . . $ perror(85c52e162fed56f9).("fopen"); |
| 515 | return; |
| 516 | } |
| 517 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(path, MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! - 1, "%s/tasks", CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!); |
| 518 | path[MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! - 1] = 0; |
| 519 | |
| 520 | fd = opencxx . . $ open(e156e3aa1e5c4ad1).(path, O_WRONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:44:9`!); |
| 521 | if (fd < 0) { |
| 522 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 523 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Failed opening %s\n", path); |
| 524 | perrorcxx . . $ perror(85c52e162fed56f9).("open"); |
| 525 | return; |
| 526 | } |
| 527 | |
| 528 | while (fscanfcxx . . $ fscanf(bc216f8e5b1ebeac).(fp, "%d", &pid) == 1) { |
| 529 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buf, "%d", pid); |
| 530 | if (print) |
| 531 | printfcxx . . $ printf(581fddd72a8db8fc).("Moving %d out of %s\n", pid, name); |
| 532 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, buf, strlencxx . . $ strlen(751346f8406fd082).(buf)); |
| 533 | if (ret < 0 && errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == ENOSPCcxx . . $ `<external>/8987895939074593727/errno-base.h:32:9`!) { |
| 534 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 535 | closecxx . . $ close(7864480464b09eea).(fd); |
| 536 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("Cannot move tasks out of cpuset %s\n", name); |
| 537 | } |
| 538 | |
| 539 | |
| 540 | } |
| 541 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 542 | closecxx . . $ close(7864480464b09eea).(fd); |
| 543 | |
| 544 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(path, MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! - 1, "%s/%s", CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!, name); |
| 545 | path[MAXPATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:41:9`! - 1] = 0; |
| 546 | |
| 547 | sleepcxx . . $ sleep(2141b656ce2cc063).(1); |
| 548 | ret = rmdircxx . . $ rmdir(5c4306d8553b3696).(path); |
| 549 | if (ret < 0) { |
| 550 | if (retry++ < 5) { |
| 551 | err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).("Trying again\n"); |
| 552 | goto again; |
| 553 | } |
| 554 | err_msg_ncxx . . $ err_msg_n(26800c7917ec8ef2).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, "Failed to remove %s\n", path); |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | static void teardowncxx . . $ teardown(49f6e7a06ebc5aa8).(void) |
| 559 | { |
| 560 | int fd; |
| 561 | int ret; |
| 562 | |
| 563 | if (all_cpuscxx . . $ all_cpus.) |
| 564 | return; |
| 565 | |
| 566 | fd = open_cpusetcxx . . $ open_cpuset(5ae29d726ae57f88).(CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!, "cpuset.cpu_exclusive"); |
| 567 | if (fd >= 0) { |
| 568 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, "0", 2); |
| 569 | if (ret < 0) |
| 570 | perrorcxx . . $ perror(85c52e162fed56f9).("cpuset.cpu_exclusive"); |
| 571 | closecxx . . $ close(7864480464b09eea).(fd); |
| 572 | } |
| 573 | |
| 574 | fd = open_cpusetcxx . . $ open_cpuset(5ae29d726ae57f88).(CPUSET_PATHcxx . . $ `src/sched_deadline/cyclicdeadline.c:257:9`!, "cpuset.sched_load_balance"); |
| 575 | if (fd >= 0) { |
| 576 | ret = writecxx . . $ write(41184a59d38b4f65).(fd, "1", 2); |
| 577 | if (ret < 0) |
| 578 | perrorcxx . . $ perror(85c52e162fed56f9).("cpuset.sched_load_balance"); |
| 579 | closecxx . . $ close(7864480464b09eea).(fd); |
| 580 | } |
| 581 | |
| 582 | destroy_cpusetcxx . . $ destroy_cpuset(34d26762b42c433a).(CPUSET_ALLcxx . . $ `src/sched_deadline/cyclicdeadline.c:46:9`!, 0); |
| 583 | destroy_cpusetcxx . . $ destroy_cpuset(34d26762b42c433a).(CPUSET_LOCALcxx . . $ `src/sched_deadline/cyclicdeadline.c:47:9`!, 1); |
| 584 | |
| 585 | /* close any tracer file descriptors */ |
| 586 | disable_trace_markcxx . . $ disable_trace_mark(49f6e7a06ebc5aa8).(); |
| 587 | |
| 588 | } |
| 589 | |
| 590 | static void usagecxx . . $ usage(d4f767463ce0a6b3).(int error) |
| 591 | { |
| 592 | printfcxx . . $ printf(581fddd72a8db8fc).("cyclicdeadline V %1.2f\n", VERSIONcxx . . $ `<built-in>:412:9`!); |
| 593 | printfcxx . . $ printf(581fddd72a8db8fc).("Usage:\n" |
| 594 | "cyclicdeadline <options>\n\n" |
| 595 | "-a [CPUSET] --affinity Comma/hyphen separated list of CPUs to run deadline\n" |
| 596 | " tasks on. An empty CPUSET runs on all CPUs a deadline\n" |
| 597 | " task.\n" |
| 598 | "-D TIME --duration Specify a length in seconds for the test run.\n" |
| 599 | " Append 'm', 'h', or 'd' to specify minutes, hours or\n" |
| 600 | " days\n" |
| 601 | "-h --help Show this help menu.\n" |
| 602 | " --histogram=US dump a latency histogram to stdout after the run\n" |
| 603 | " US is the max latency time to be tracked in microseconds\n" |
| 604 | " This option runs all threads at the same priority.\n" |
| 605 | " --histfile=<path> dump the latency histogram to <path> instead of stdout\n" |
| 606 | "-i INTV --interval The shortest deadline for the tasks in us\n" |
| 607 | " (default 1000us).\n" |
| 608 | " --json=FILENAME write final results into FILENAME, JSON formatted\n" |
| 609 | "-s STEP --step The amount to increase the deadline for each task in us\n" |
| 610 | " (default 500us).\n" |
| 611 | "-t NUM --threads The number of threads to run as deadline (default 1).\n" |
| 612 | "-q --quiet print a summary only on exit\n" |
| 613 | "-b USEC --breaktrace=USEC send break trace command when latency > USEC\n" |
| 614 | " --tracemark write a trace mark when -b latency is exceeded\n" |
| 615 | " --debug Print debugging info for cyclicdeadline\n" |
| 616 | " --verbose Print useful information about the test\n" |
| 617 | ); |
| 618 | exitcxx . . $ exit(3ca292c338df9bb3).(error); |
| 619 | } |
| 620 | |
| 621 | static u64cxx . . $ u64# get_time_uscxx . . $ get_time_us(73266883b0c7072b).(void) |
| 622 | { |
| 623 | struct timespeccxx . . $ timespec# ts; |
| 624 | u64cxx . . $ u64# time; |
| 625 | |
| 626 | clock_gettimecxx . . $ clock_gettime(65aaefb2502b4987).(CLOCK_MONOTONIC_RAWcxx . . $ `<external>/89459239771508533/time.h:54:10`!, &ts); |
| 627 | time = ts.tv_seccxx . . $ timespec#tv_sec. * 1000000; |
| 628 | time += ts.tv_nseccxx . . $ timespec#tv_nsec. / 1000; |
| 629 | |
| 630 | return time; |
| 631 | } |
| 632 | |
| 633 | static void print_histcxx . . $ print_hist(25fc3c5c8a029a3c).(FILEcxx . . $ FILE# *fp, struct sched_datacxx . . $ sched_data# *sd, int nthreads) |
| 634 | { |
| 635 | int i; |
| 636 | unsigned long maxmax, alloverflows; |
| 637 | |
| 638 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "# Histogram\n"); |
| 639 | for (i = 0; i < histogramcxx . . $ histogram.; i++) { |
| 640 | unsigned long flags = 0; |
| 641 | char buf[64]; |
| 642 | |
| 643 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof(buf), "%06d ", i); |
| 644 | hset_print_bucketcxx . . $ hset_print_bucket(31a571358aba96cf).(&hsetcxx . . $ hset., fp, buf, i, flags); |
| 645 | } |
| 646 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "# Min Latencies:"); |
| 647 | for (i = 0; i < nthreads; i++) |
| 648 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, " %05lu", sd[i].statcxx . . $ sched_data#stat..mincxx . . $ thread_stat#min.); |
| 649 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "\n"); |
| 650 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "# Avg Latencies:"); |
| 651 | for (i = 0; i < nthreads; i++) |
| 652 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, " %05lu", sd[i].statcxx . . $ sched_data#stat..cyclescxx . . $ thread_stat#cycles. ? |
| 653 | (long)(sd[i].statcxx . . $ sched_data#stat..avgcxx . . $ thread_stat#avg./sd[i].statcxx . . $ sched_data#stat..cyclescxx . . $ thread_stat#cycles.) : 0); |
| 654 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "\n"); |
| 655 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "# Max Latencies:"); |
| 656 | maxmax = 0; |
| 657 | for (i = 0; i < nthreads; i++) { |
| 658 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, " %05lu", sd[i].statcxx . . $ sched_data#stat..maxcxx . . $ thread_stat#max.); |
| 659 | if (sd[i].statcxx . . $ sched_data#stat..maxcxx . . $ thread_stat#max. > maxmax) |
| 660 | maxmax = sd[i].statcxx . . $ sched_data#stat..maxcxx . . $ thread_stat#max.; |
| 661 | } |
| 662 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "\n"); |
| 663 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "# Histogram Overflows:"); |
| 664 | alloverflows = 0; |
| 665 | for (i = 0; i < nthreads; i++) { |
| 666 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, " %05lu", sd[i].statcxx . . $ sched_data#stat..histcxx . . $ thread_stat#hist.->oflow_countcxx . . $ histogram#oflow_count.); |
| 667 | alloverflows += sd[i].statcxx . . $ sched_data#stat..histcxx . . $ thread_stat#hist.->oflow_countcxx . . $ histogram#oflow_count.; |
| 668 | } |
| 669 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "\n"); |
| 670 | |
| 671 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "# Histogram Overflow at cycle number:\n"); |
| 672 | for (i = 0; i < nthreads; i++) { |
| 673 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "# Thread %d: ", i); |
| 674 | hist_print_oflowscxx . . $ hist_print_oflows(6acc875be05641a4).(sd[i].statcxx . . $ sched_data#stat..histcxx . . $ thread_stat#hist., fp); |
| 675 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "\n"); |
| 676 | } |
| 677 | |
| 678 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "\n"); |
| 679 | } |
| 680 | |
| 681 | static void print_statcxx . . $ print_stat(c66af740861302a).(FILEcxx . . $ FILE# *fp, struct sched_datacxx . . $ sched_data# *sd, int index, int quiet) |
| 682 | { |
| 683 | struct thread_statcxx . . $ thread_stat# *stat = &sd->statcxx . . $ sched_data#stat.; |
| 684 | char *fmt; |
| 685 | |
| 686 | if (quiet) |
| 687 | return; |
| 688 | |
| 689 | if (use_nsecscxx . . $ use_nsecs.) |
| 690 | fmt = "T:%2d (%5d) I:%ld C:%7lu Min:%7ld Act:%8ld Avg:%8ld Max:%8ld\n"; |
| 691 | else |
| 692 | fmt = "T:%2d (%5d) I:%ld C:%7lu Min:%7ld Act:%5ld Avg:%5ld Max:%8ld\n"; |
| 693 | |
| 694 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, fmt, index, stat->tidcxx . . $ thread_stat#tid., |
| 695 | sd->deadline_uscxx . . $ sched_data#deadline_us., stat->cyclescxx . . $ thread_stat#cycles., stat->mincxx . . $ thread_stat#min., stat->actcxx . . $ thread_stat#act., |
| 696 | stat->cyclescxx . . $ thread_stat#cycles. ? |
| 697 | (long)(stat->avgcxx . . $ thread_stat#avg./stat->cyclescxx . . $ thread_stat#cycles.) : 0, stat->maxcxx . . $ thread_stat#max.); |
| 698 | } |
| 699 | |
| 700 | static u64cxx . . $ u64# do_runtimecxx . . $ do_runtime(adf1066a871f9c04).(struct sched_datacxx . . $ sched_data# *sd, u64cxx . . $ u64# period) |
| 701 | { |
| 702 | struct thread_statcxx . . $ thread_stat# *stat = &sd->statcxx . . $ sched_data#stat.; |
| 703 | u64cxx . . $ u64# next_period = period + sd->deadline_uscxx . . $ sched_data#deadline_us.; |
| 704 | u64cxx . . $ u64# now = get_time_uscxx . . $ get_time_us(73266883b0c7072b).(); |
| 705 | u64cxx . . $ u64# diff; |
| 706 | |
| 707 | if (now < period) { |
| 708 | u64cxx . . $ u64# delta = period - now; |
| 709 | /* |
| 710 | * The period could be off due to other deadline tasks |
| 711 | * preempting us when we started. If that's the case then |
| 712 | * adjust the current period. |
| 713 | */ |
| 714 | tracemarkcxx . . $ tracemark(d5d9ff45db7b5d36).("Adjusting period: now: %lld period: %lld delta:%lld%s\n", |
| 715 | now, period, delta, delta > sd->deadline_uscxx . . $ sched_data#deadline_us. / 2 ? |
| 716 | " HUGE ADJUSTMENT" : ""); |
| 717 | period = now; |
| 718 | next_period = period + sd->deadline_uscxx . . $ sched_data#deadline_us.; |
| 719 | } |
| 720 | |
| 721 | tracemarkcxx . . $ tracemark(d5d9ff45db7b5d36).("start at %lld off=%lld (period=%lld next=%lld)\n", |
| 722 | now, now - period, period, next_period); |
| 723 | |
| 724 | |
| 725 | diff = now - period; |
| 726 | if (diff > stat->maxcxx . . $ thread_stat#max.) |
| 727 | stat->maxcxx . . $ thread_stat#max. = diff; |
| 728 | if (!stat->mincxx . . $ thread_stat#min. || diff < stat->mincxx . . $ thread_stat#min.) |
| 729 | stat->mincxx . . $ thread_stat#min. = diff; |
| 730 | stat->actcxx . . $ thread_stat#act. = diff; |
| 731 | stat->avgcxx . . $ thread_stat#avg. += (double) diff; |
| 732 | |
| 733 | if (histogramcxx . . $ histogram.) |
| 734 | hist_samplecxx . . $ hist_sample(e5685fb6a6b593bd).(stat->histcxx . . $ thread_stat#hist., diff); |
| 735 | |
| 736 | stat->cyclescxx . . $ thread_stat#cycles.++; |
| 737 | |
| 738 | return next_period; |
| 739 | } |
| 740 | |
| 741 | void *run_deadlinecxx . . $ run_deadline(9f162e79bfc6c74).(void *data) |
| 742 | { |
| 743 | struct sched_datacxx . . $ sched_data# *sd = data; |
| 744 | struct thread_statcxx . . $ thread_stat# *stat = &sd->statcxx . . $ sched_data#stat.; |
| 745 | struct sched_attrcxx . . $ sched_attr# attr; |
| 746 | long tid = gettidcxx . . $ gettid(b126dc7c1de90089).(); |
| 747 | u64cxx . . $ u64# period; |
| 748 | int ret; |
| 749 | |
| 750 | debugcxx . . $ debug(26800c7917ec8ef2).(debug_enablecxx . . $ debug_enable., "deadline thread %ld\n", tid); |
| 751 | // set up for each measurment thread |
| 752 | stat->tidcxx . . $ thread_stat#tid. = tid; |
| 753 | |
| 754 | ret = sched_getattrcxx . . $ sched_getattr(bd8640c19c50e270).(0, &attr, sizeof(attr), 0); |
| 755 | if (ret < 0) { |
| 756 | err_msg_ncxx . . $ err_msg_n(26800c7917ec8ef2).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, "[%ld]", tid); |
| 757 | shutdowncxx . . $ shutdown. = 1; |
| 758 | pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&barriercxx . . $ barrier.); |
| 759 | pthread_exitcxx . . $ pthread_exit(b8a01b603c304b90).("Failed sched_getattr"); |
| 760 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 761 | } |
| 762 | |
| 763 | attr.sched_policycxx . . $ sched_attr#sched_policy. = SCHED_DEADLINEcxx . . $ `<external>/4872883757279652994/sched.h:36:10`!; |
| 764 | attr.sched_runtimecxx . . $ sched_attr#sched_runtime. = sd->runtime_uscxx . . $ sched_data#runtime_us. * 1000; |
| 765 | attr.sched_deadlinecxx . . $ sched_attr#sched_deadline. = sd->deadline_uscxx . . $ sched_data#deadline_us. * 1000; |
| 766 | |
| 767 | debugcxx . . $ debug(26800c7917ec8ef2).(debug_enablecxx . . $ debug_enable., "thread[%d] runtime=%lldus deadline=%lldus\n", |
| 768 | gettidcxx . . $ gettid(b126dc7c1de90089).(), sd->runtime_uscxx . . $ sched_data#runtime_us., sd->deadline_uscxx . . $ sched_data#deadline_us.); |
| 769 | |
| 770 | ret = sched_setattrcxx . . $ sched_setattr(855aa5bf0081d6b3).(0, &attr, 0); |
| 771 | if (ret < 0) { |
| 772 | err_msg_ncxx . . $ err_msg_n(26800c7917ec8ef2).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, "[%ld]", tid); |
| 773 | shutdowncxx . . $ shutdown. = 1; |
| 774 | pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&barriercxx . . $ barrier.); |
| 775 | pthread_exitcxx . . $ pthread_exit(b8a01b603c304b90).("Failed sched_setattr"); |
| 776 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 777 | } |
| 778 | |
| 779 | pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&barriercxx . . $ barrier.); |
| 780 | |
| 781 | sched_yieldcxx . . $ sched_yield(b126dc7c1de90089).(); |
| 782 | period = get_time_uscxx . . $ get_time_us(73266883b0c7072b).(); |
| 783 | |
| 784 | while (!shutdowncxx . . $ shutdown.) { |
| 785 | period = do_runtimecxx . . $ do_runtime(adf1066a871f9c04).(sd, period); |
| 786 | if (tracelimitcxx . . $ tracelimit. && (stat->maxcxx . . $ thread_stat#max. > tracelimitcxx . . $ tracelimit.)) { |
| 787 | shutdowncxx . . $ shutdown.++; |
| 788 | pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&break_thread_id_lockcxx . . $ break_thread_id_lock.); |
| 789 | if (break_thread_idcxx . . $ break_thread_id. == 0) { |
| 790 | break_thread_idcxx . . $ break_thread_id. = stat->tidcxx . . $ thread_stat#tid.; |
| 791 | break_thread_valuecxx . . $ break_thread_value. = stat->maxcxx . . $ thread_stat#max.; |
| 792 | tracemarkcxx . . $ tracemark(d5d9ff45db7b5d36).("hit latency threshold (%lld > %d)", |
| 793 | (unsigned long long) stat->maxcxx . . $ thread_stat#max., tracelimitcxx . . $ tracelimit.); |
| 794 | tracing_stopcxx . . $ tracing_stop(49f6e7a06ebc5aa8).(); |
| 795 | } |
| 796 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&break_thread_id_lockcxx . . $ break_thread_id_lock.); |
| 797 | break; |
| 798 | } |
| 799 | sched_yieldcxx . . $ sched_yield(b126dc7c1de90089).(); |
| 800 | } |
| 801 | ret = sched_getattrcxx . . $ sched_getattr(bd8640c19c50e270).(0, &attr, sizeof(attr), 0); |
| 802 | if (ret < 0) { |
| 803 | err_msg_ncxx . . $ err_msg_n(26800c7917ec8ef2).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, "sched_getattr"); |
| 804 | pthread_exitcxx . . $ pthread_exit(b8a01b603c304b90).("Failed second sched_getattr"); |
| 805 | } |
| 806 | |
| 807 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 808 | } |
| 809 | |
| 810 | struct cpu_listcxx . . $ cpu_list# { |
| 811 | struct cpu_listcxx . . $ cpu_list# *nextcxx . . $ cpu_list#next.; |
| 812 | int start_cpucxx . . $ cpu_list#start_cpu.; |
| 813 | int end_cpucxx . . $ cpu_list#end_cpu.; |
| 814 | }; |
| 815 | |
| 816 | static void add_cpuscxx . . $ add_cpus(d0b3d0333ff28e03).(struct cpu_listcxx . . $ cpu_list# **cpu_list, int start_cpu, int end_cpu) |
| 817 | { |
| 818 | struct cpu_listcxx . . $ cpu_list# *list; |
| 819 | |
| 820 | while (*cpu_list && (*cpu_list)->end_cpucxx . . $ cpu_list#end_cpu. + 1 < start_cpu) |
| 821 | cpu_list = &(*cpu_list)->nextcxx . . $ cpu_list#next.; |
| 822 | |
| 823 | if (!*cpu_list) { |
| 824 | *cpu_list = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct cpu_listcxx . . $ cpu_list#)); |
| 825 | (*cpu_list)->start_cpucxx . . $ cpu_list#start_cpu. = start_cpu; |
| 826 | (*cpu_list)->end_cpucxx . . $ cpu_list#end_cpu. = end_cpu; |
| 827 | (*cpu_list)->nextcxx . . $ cpu_list#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 828 | return; |
| 829 | } |
| 830 | |
| 831 | /* Look to concatinate */ |
| 832 | if (end_cpu > (*cpu_list)->start_cpucxx . . $ cpu_list#start_cpu. && |
| 833 | start_cpu <= (*cpu_list)->end_cpucxx . . $ cpu_list#end_cpu. + 1) { |
| 834 | if (start_cpu < (*cpu_list)->start_cpucxx . . $ cpu_list#start_cpu.) |
| 835 | (*cpu_list)->start_cpucxx . . $ cpu_list#start_cpu. = start_cpu; |
| 836 | list = (*cpu_list)->nextcxx . . $ cpu_list#next.; |
| 837 | while (list && list->start_cpucxx . . $ cpu_list#start_cpu. <= end_cpu + 1) { |
| 838 | (*cpu_list)->end_cpucxx . . $ cpu_list#end_cpu. = list->end_cpucxx . . $ cpu_list#end_cpu.; |
| 839 | (*cpu_list)->nextcxx . . $ cpu_list#next. = list->nextcxx . . $ cpu_list#next.; |
| 840 | freecxx . . $ free(5d22bdacc48458e8).(list); |
| 841 | list = (*cpu_list)->nextcxx . . $ cpu_list#next.; |
| 842 | } |
| 843 | if ((*cpu_list)->end_cpucxx . . $ cpu_list#end_cpu. < end_cpu) |
| 844 | (*cpu_list)->end_cpucxx . . $ cpu_list#end_cpu. = end_cpu; |
| 845 | return; |
| 846 | } |
| 847 | |
| 848 | /* Check for overlaps */ |
| 849 | if (end_cpu >= (*cpu_list)->start_cpucxx . . $ cpu_list#start_cpu. - 1) { |
| 850 | (*cpu_list)->start_cpucxx . . $ cpu_list#start_cpu. = start_cpu; |
| 851 | return; |
| 852 | } |
| 853 | |
| 854 | list = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct cpu_listcxx . . $ cpu_list#)); |
| 855 | list->start_cpucxx . . $ cpu_list#start_cpu. = start_cpu; |
| 856 | list->end_cpucxx . . $ cpu_list#end_cpu. = end_cpu; |
| 857 | list->nextcxx . . $ cpu_list#next. = (*cpu_list)->nextcxx . . $ cpu_list#next.; |
| 858 | (*cpu_list)->nextcxx . . $ cpu_list#next. = list; |
| 859 | } |
| 860 | |
| 861 | static int count_cpuscxx . . $ count_cpus(bd013859c5e4b3b5).(struct cpu_listcxx . . $ cpu_list# *cpu_list) |
| 862 | { |
| 863 | struct cpu_listcxx . . $ cpu_list# *list; |
| 864 | int cpus = 0; |
| 865 | int fail = 0; |
| 866 | |
| 867 | while (cpu_list) { |
| 868 | list = cpu_list; |
| 869 | cpus += (list->end_cpucxx . . $ cpu_list#end_cpu. - list->start_cpucxx . . $ cpu_list#start_cpu.) + 1; |
| 870 | if (list->end_cpucxx . . $ cpu_list#end_cpu. >= cpu_countcxx . . $ cpu_count.) |
| 871 | fail = 1; |
| 872 | cpu_list = list->nextcxx . . $ cpu_list#next.; |
| 873 | freecxx . . $ free(5d22bdacc48458e8).(list); |
| 874 | } |
| 875 | return fail ? -1 : cpus; |
| 876 | } |
| 877 | |
| 878 | static char *append_cpuscxx . . $ append_cpus(48a3ae3b99a7122).(char *buf, int start, int end, |
| 879 | const char *comma, int *total) |
| 880 | { |
| 881 | int len; |
| 882 | |
| 883 | if (start == end) { |
| 884 | len = snprintfcxx . . $ snprintf(ea502d73e74c754c).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, "%s%d", comma, start); |
| 885 | buf = realloccxx . . $ realloc(417ab160f6baadc6).(buf, *total + len + 1); |
| 886 | buf[*total] = 0; |
| 887 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf + *total, len + 1, "%s%d", comma, start); |
| 888 | } else { |
| 889 | len = snprintfcxx . . $ snprintf(ea502d73e74c754c).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, "%s%d-%d", comma, start, end); |
| 890 | buf = realloccxx . . $ realloc(417ab160f6baadc6).(buf, *total + len + 1); |
| 891 | buf[*total] = 0; |
| 892 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf + *total, len + 1, "%s%d-%d", comma, |
| 893 | start, end); |
| 894 | } |
| 895 | *total += len; |
| 896 | return buf; |
| 897 | } |
| 898 | |
| 899 | static void make_new_listcxx . . $ make_new_list(15696bce5091baf0).(struct cpu_listcxx . . $ cpu_list# *cpu_list, char **buf) |
| 900 | { |
| 901 | char *comma = ""; |
| 902 | int total = 0; |
| 903 | |
| 904 | while (cpu_list) { |
| 905 | *buf = append_cpuscxx . . $ append_cpus(48a3ae3b99a7122).(*buf, cpu_list->start_cpucxx . . $ cpu_list#start_cpu., cpu_list->end_cpucxx . . $ cpu_list#end_cpu., |
| 906 | comma, &total); |
| 907 | comma = ","; |
| 908 | cpu_list = cpu_list->nextcxx . . $ cpu_list#next.; |
| 909 | } |
| 910 | } |
| 911 | |
| 912 | static void make_other_cpu_listcxx . . $ make_other_cpu_list(4a08200150b6cca3).(const char *setcpu, char **cpus) |
| 913 | { |
| 914 | const char *p = setcpu; |
| 915 | const char *comma = ""; |
| 916 | int curr_cpu = 0; |
| 917 | int cpu; |
| 918 | int total = 0; |
| 919 | |
| 920 | while (*p && curr_cpu < cpu_countcxx . . $ cpu_count.) { |
| 921 | cpu = atoicxx . . $ atoi(5c4306d8553b3696).(p); |
| 922 | if (cpu > curr_cpu) { |
| 923 | *cpus = append_cpuscxx . . $ append_cpus(48a3ae3b99a7122).(*cpus, curr_cpu, cpu - 1, |
| 924 | comma, &total); |
| 925 | comma = ","; |
| 926 | } |
| 927 | while (isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!(*p)) |
| 928 | p++; |
| 929 | if (*p == '-') { |
| 930 | p++; |
| 931 | cpu = atoicxx . . $ atoi(5c4306d8553b3696).(p); |
| 932 | while (isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!(*p)) |
| 933 | p++; |
| 934 | } |
| 935 | curr_cpu = cpu + 1; |
| 936 | if (*p) |
| 937 | p++; |
| 938 | } |
| 939 | |
| 940 | if (curr_cpu < cpu_countcxx . . $ cpu_count.) { |
| 941 | *cpus = append_cpuscxx . . $ append_cpus(48a3ae3b99a7122).(*cpus, curr_cpu, cpu_countcxx . . $ cpu_count. - 1, |
| 942 | comma, &total); |
| 943 | } |
| 944 | } |
| 945 | |
| 946 | static int calc_nr_cpuscxx . . $ calc_nr_cpus(c4dada3283861623).(const char *setcpu, char **buf) |
| 947 | { |
| 948 | struct cpu_listcxx . . $ cpu_list# *cpu_list = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 949 | const char *p; |
| 950 | int end_cpu; |
| 951 | int cpu; |
| 952 | |
| 953 | for (p = setcpu; *p; ) { |
| 954 | cpu = atoicxx . . $ atoi(5c4306d8553b3696).(p); |
| 955 | if (cpu < 0 || (!cpu && *p != '0')) |
| 956 | goto err; |
| 957 | |
| 958 | while (isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!(*p)) |
| 959 | p++; |
| 960 | if (*p == '-') { |
| 961 | p++; |
| 962 | end_cpu = atoicxx . . $ atoi(5c4306d8553b3696).(p); |
| 963 | if (end_cpu < cpu || (!end_cpu && *p != '0')) |
| 964 | goto err; |
| 965 | while (isdigitcxx . . $ `<external>/17904084882347303253/ctype.h:192:10`!(*p)) |
| 966 | p++; |
| 967 | } else |
| 968 | end_cpu = cpu; |
| 969 | |
| 970 | add_cpuscxx . . $ add_cpus(d0b3d0333ff28e03).(&cpu_list, cpu, end_cpu); |
| 971 | if (*p == ',') |
| 972 | p++; |
| 973 | } |
| 974 | |
| 975 | make_new_listcxx . . $ make_new_list(15696bce5091baf0).(cpu_list, buf); |
| 976 | return count_cpuscxx . . $ count_cpus(bd013859c5e4b3b5).(cpu_list); |
| 977 | err: |
| 978 | /* Frees the list */ |
| 979 | count_cpuscxx . . $ count_cpus(bd013859c5e4b3b5).(cpu_list); |
| 980 | return -1; |
| 981 | } |
| 982 | |
| 983 | static void sighandcxx . . $ sighand(d4f767463ce0a6b3).(int sig) |
| 984 | { |
| 985 | shutdowncxx . . $ shutdown. = 1; |
| 986 | } |
| 987 | |
| 988 | static const char *join_threadcxx . . $ join_thread(779c4cd7ad3bfa56).(pthread_tcxx . . $ pthread_t# *thread) |
| 989 | { |
| 990 | void *result; |
| 991 | |
| 992 | pthread_joincxx . . $ pthread_join(269902cf949f12c5).(*thread, &result); |
| 993 | return result; |
| 994 | } |
| 995 | |
| 996 | static void loopcxx . . $ loop(b05606f264c99c67).(struct sched_datacxx . . $ sched_data# *sched_data, int nr_threads) |
| 997 | { |
| 998 | int i; |
| 999 | |
| 1000 | while (!shutdowncxx . . $ shutdown.) { |
| 1001 | for (i = 0; i < nr_threads; i++) |
| 1002 | print_statcxx . . $ print_stat(c66af740861302a).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, &sched_data[i], i, quietcxx . . $ quiet.); |
| 1003 | usleepcxx . . $ usleep(4c679297bf94b9eb).(10000); |
| 1004 | if (!quietcxx . . $ quiet.) |
| 1005 | printfcxx . . $ printf(581fddd72a8db8fc).("\033[%dA", nr_threads); |
| 1006 | } |
| 1007 | usleepcxx . . $ usleep(4c679297bf94b9eb).(10000); |
| 1008 | if (!quietcxx . . $ quiet.) { |
| 1009 | printfcxx . . $ printf(581fddd72a8db8fc).("\033[%dB", nr_threads + 2); |
| 1010 | } else if (!histogramcxx . . $ histogram.) { |
| 1011 | for (i = 0; i < nr_threads; ++i) |
| 1012 | print_statcxx . . $ print_stat(c66af740861302a).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, &sched_data[i], i, 0); |
| 1013 | } |
| 1014 | |
| 1015 | if (histogramcxx . . $ histogram.) { |
| 1016 | FILEcxx . . $ FILE# *out = histfilecxx . . $ histfile. ? histfilecxx . . $ histfile. : stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!; |
| 1017 | |
| 1018 | print_histcxx . . $ print_hist(25fc3c5c8a029a3c).(out, sched_data, nr_threads); |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | static void write_statscxx . . $ write_stats(2fd218767557b4b8).(FILEcxx . . $ FILE# *f, void *data) |
| 1023 | { |
| 1024 | struct sched_datacxx . . $ sched_data# *sd = data; |
| 1025 | struct thread_statcxx . . $ thread_stat# *s; |
| 1026 | int i; |
| 1027 | |
| 1028 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " \"num_threads\": %d,\n", nr_threadscxx . . $ nr_threads.); |
| 1029 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " \"resolution_in_ns\": %u,\n", use_nsecscxx . . $ use_nsecs.); |
| 1030 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " \"thread\": {\n"); |
| 1031 | for (i = 0; i < nr_threadscxx . . $ nr_threads.; i++) { |
| 1032 | s = &sd[i].statcxx . . $ sched_data#stat.; |
| 1033 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " \"%u\": {\n", i); |
| 1034 | if (s->histcxx . . $ thread_stat#hist.) { |
| 1035 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " \"histogram\": {"); |
| 1036 | hist_print_jsoncxx . . $ hist_print_json(6acc875be05641a4).(s->histcxx . . $ thread_stat#hist., f); |
| 1037 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " },\n"); |
| 1038 | } |
| 1039 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " \"cycles\": %ld,\n", s->cyclescxx . . $ thread_stat#cycles.); |
| 1040 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " \"min\": %ld,\n", s->mincxx . . $ thread_stat#min.); |
| 1041 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " \"max\": %ld,\n", s->maxcxx . . $ thread_stat#max.); |
| 1042 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " \"avg\": %.2f\n", s->avgcxx . . $ thread_stat#avg./s->cyclescxx . . $ thread_stat#cycles.); |
| 1043 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " }%s\n", i == nr_threadscxx . . $ nr_threads. - 1 ? "" : ","); |
| 1044 | } |
| 1045 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(f, " }\n"); |
| 1046 | } |
| 1047 | |
| 1048 | enum options_valuescxx . . $ options_values# { |
| 1049 | OPT_AFFINITYcxx . . $ OPT_AFFINITY.=1, OPT_DURATIONcxx . . $ OPT_DURATION., OPT_HELPcxx . . $ OPT_HELP., OPT_INTERVALcxx . . $ OPT_INTERVAL., |
| 1050 | OPT_JSONcxx . . $ OPT_JSON., OPT_STEPcxx . . $ OPT_STEP., OPT_THREADScxx . . $ OPT_THREADS., OPT_QUIETcxx . . $ OPT_QUIET., |
| 1051 | OPT_BREAKTRACEcxx . . $ OPT_BREAKTRACE., OPT_TRACEMARKcxx . . $ OPT_TRACEMARK., OPT_INFOcxx . . $ OPT_INFO., OPT_DEBUGcxx . . $ OPT_DEBUG., |
| 1052 | OPT_HISTOGRAMcxx . . $ OPT_HISTOGRAM., OPT_HISTFILEcxx . . $ OPT_HISTFILE. |
| 1053 | }; |
| 1054 | |
| 1055 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) |
| 1056 | { |
| 1057 | struct sched_datacxx . . $ sched_data# *sched_data; |
| 1058 | struct sched_datacxx . . $ sched_data# *sd; |
| 1059 | const char *res; |
| 1060 | const char *setcpu = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1061 | char *setcpu_buf = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1062 | char *allcpu_buf = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1063 | pthread_tcxx . . $ pthread_t# *thread; |
| 1064 | unsigned int interval = 1000; |
| 1065 | unsigned int step = 500; |
| 1066 | int percent = 60; |
| 1067 | int duration = 0; |
| 1068 | u64cxx . . $ u64# runtime; |
| 1069 | u64cxx . . $ u64# start_period; |
| 1070 | u64cxx . . $ u64# end_period; |
| 1071 | int nr_cpus; |
| 1072 | int i; |
| 1073 | int c; |
| 1074 | int ret; |
| 1075 | |
| 1076 | rt_initcxx . . $ rt_init(c759356ac01a31e7).(argc, argv); |
| 1077 | |
| 1078 | cpu_countcxx . . $ cpu_count. = sysconfcxx . . $ sysconf(dc1f09c09fbff20f).(_SC_NPROCESSORS_CONFcxx . . $ `<external>/6393649343499073842/confname.h:251:9`!); |
| 1079 | if (cpu_countcxx . . $ cpu_count. < 1) |
| 1080 | err_quitcxx . . $ err_quit(5313ecf19fd40d4d).("Can not calculate number of CPUS\n"); |
| 1081 | |
| 1082 | for (;;) { |
| 1083 | static struct optioncxx . . $ option# options[] = { |
| 1084 | { "affinity", optional_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:64:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_AFFINITYcxx . . $ OPT_AFFINITY. }, |
| 1085 | { "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. }, |
| 1086 | { "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. }, |
| 1087 | { "interval", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_INTERVALcxx . . $ OPT_INTERVAL. }, |
| 1088 | { "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. }, |
| 1089 | { "step", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_STEPcxx . . $ OPT_STEP. }, |
| 1090 | { "threads", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_THREADScxx . . $ OPT_THREADS. }, |
| 1091 | { "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. }, |
| 1092 | { "breaktrace", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_BREAKTRACEcxx . . $ OPT_BREAKTRACE. }, |
| 1093 | { "tracemark", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_TRACEMARKcxx . . $ OPT_TRACEMARK. }, |
| 1094 | { "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_INFOcxx . . $ OPT_INFO.}, |
| 1095 | { "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.}, |
| 1096 | { "histogram", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_HISTOGRAMcxx . . $ OPT_HISTOGRAM. }, |
| 1097 | { "histfile", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, OPT_HISTFILEcxx . . $ OPT_HISTFILE. }, |
| 1098 | { 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 }, |
| 1099 | }; |
| 1100 | c = getopt_longcxx . . $ getopt_long(41f665c090816971).(argc, argv, "a::c:D:hi:s:t:b:q", options, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1101 | if (c == -1) |
| 1102 | break; |
| 1103 | switch (c) { |
| 1104 | case OPT_AFFINITYcxx . . $ OPT_AFFINITY.: |
| 1105 | case 'a': |
| 1106 | case 'c': |
| 1107 | if (!nr_threadscxx . . $ nr_threads.) |
| 1108 | nr_threadscxx . . $ nr_threads. = cpu_countcxx . . $ cpu_count.; |
| 1109 | if (optargcxx . . $ optarg.) |
| 1110 | setcpu = optargcxx . . $ optarg.; |
| 1111 | else if (optindcxx . . $ optind. < argc) |
| 1112 | setcpu = argv[optindcxx . . $ optind.]; |
| 1113 | else |
| 1114 | all_cpuscxx . . $ all_cpus. = 1; |
| 1115 | break; |
| 1116 | case OPT_INTERVALcxx . . $ OPT_INTERVAL.: |
| 1117 | case 'i': |
| 1118 | interval = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 1119 | break; |
| 1120 | case OPT_JSONcxx . . $ OPT_JSON.: |
| 1121 | strncpycxx . . $ strncpy(255158a415b673b0).(jsonfilecxx . . $ jsonfile., optargcxx . . $ optarg., strnlencxx . . $ strnlen(ac5a385650b4bde5).(optargcxx . . $ optarg., MAX_PATHcxx . . $ `src/include/rt-utils.h:9:9`!-1)); |
| 1122 | break; |
| 1123 | case OPT_STEPcxx . . $ OPT_STEP.: |
| 1124 | case 's': |
| 1125 | step = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 1126 | break; |
| 1127 | case OPT_THREADScxx . . $ OPT_THREADS.: |
| 1128 | case 't': |
| 1129 | nr_threadscxx . . $ nr_threads. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 1130 | break; |
| 1131 | case OPT_DURATIONcxx . . $ OPT_DURATION.: |
| 1132 | case 'D': |
| 1133 | duration = parse_time_stringcxx . . $ parse_time_string(1ef8e6ec083aabb9).(optargcxx . . $ optarg.); |
| 1134 | break; |
| 1135 | case 'b': |
| 1136 | case OPT_BREAKTRACEcxx . . $ OPT_BREAKTRACE.: |
| 1137 | tracelimitcxx . . $ tracelimit. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 1138 | break; |
| 1139 | case OPT_QUIETcxx . . $ OPT_QUIET.: |
| 1140 | case 'q': |
| 1141 | quietcxx . . $ quiet. = 1; |
| 1142 | break; |
| 1143 | case OPT_HELPcxx . . $ OPT_HELP.: |
| 1144 | case 'h': |
| 1145 | usagecxx . . $ usage(d4f767463ce0a6b3).(0); |
| 1146 | break; |
| 1147 | case OPT_TRACEMARKcxx . . $ OPT_TRACEMARK.: |
| 1148 | trace_markercxx . . $ trace_marker. = 1; |
| 1149 | break; |
| 1150 | case OPT_INFOcxx . . $ OPT_INFO.: |
| 1151 | info_enablecxx . . $ info_enable. = 1; |
| 1152 | break; |
| 1153 | case OPT_DEBUGcxx . . $ OPT_DEBUG.: |
| 1154 | debug_enablecxx . . $ debug_enable. = 1; |
| 1155 | break; |
| 1156 | case OPT_HISTOGRAMcxx . . $ OPT_HISTOGRAM.: |
| 1157 | histogramcxx . . $ histogram. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 1158 | if (histogramcxx . . $ histogram. <= 0 || histogramcxx . . $ histogram. > HIST_MAXcxx . . $ `src/sched_deadline/cyclicdeadline.c:44:9`!) |
| 1159 | usagecxx . . $ usage(d4f767463ce0a6b3).(1); |
| 1160 | break; |
| 1161 | case OPT_HISTFILEcxx . . $ OPT_HISTFILE.: |
| 1162 | histfilecxx . . $ histfile. = fopencxx . . $ fopen(82ec0787cd37e0a3).(optargcxx . . $ optarg., "w"); |
| 1163 | if (!histfilecxx . . $ histfile.) |
| 1164 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("Couldn\'t open histfile %s: %s\n", |
| 1165 | optargcxx . . $ optarg., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 1166 | break; |
| 1167 | default: |
| 1168 | usagecxx . . $ usage(d4f767463ce0a6b3).(1); |
| 1169 | } |
| 1170 | } |
| 1171 | |
| 1172 | if (!nr_threadscxx . . $ nr_threads.) |
| 1173 | nr_threadscxx . . $ nr_threads. = 1; |
| 1174 | |
| 1175 | if (setcpu) { |
| 1176 | nr_cpus = calc_nr_cpuscxx . . $ calc_nr_cpus(c4dada3283861623).(setcpu, &setcpu_buf); |
| 1177 | if (nr_cpus < 0 || nr_cpus > cpu_countcxx . . $ cpu_count.) |
| 1178 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("Invalid cpu input '%s'\n", setcpu); |
| 1179 | } else |
| 1180 | nr_cpus = cpu_countcxx . . $ cpu_count.; |
| 1181 | |
| 1182 | if (!all_cpuscxx . . $ all_cpus. && cpu_countcxx . . $ cpu_count. == nr_cpus) { |
| 1183 | printfcxx . . $ printf(581fddd72a8db8fc).("Using all CPUS\n"); |
| 1184 | all_cpuscxx . . $ all_cpus. = 1; |
| 1185 | } |
| 1186 | |
| 1187 | /* Default cpu to use is the last one */ |
| 1188 | if (!all_cpuscxx . . $ all_cpus. && !setcpu) { |
| 1189 | setcpu_buf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(12); |
| 1190 | if (!setcpu_buf) |
| 1191 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("malloc"); |
| 1192 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(setcpu_buf, "%d", cpu_countcxx . . $ cpu_count. - 1); |
| 1193 | } |
| 1194 | |
| 1195 | setcpu = setcpu_buf; |
| 1196 | |
| 1197 | if (setcpu) |
| 1198 | make_other_cpu_listcxx . . $ make_other_cpu_list(4a08200150b6cca3).(setcpu, &allcpu_buf); |
| 1199 | |
| 1200 | if (mlockallcxx . . $ mlockall(7864480464b09eea).(MCL_CURRENTcxx . . $ `<external>/17226767460805440860/mman-linux.h:131:10`!|MCL_FUTUREcxx . . $ `<external>/17226767460805440860/mman-linux.h:132:10`!) == -1) |
| 1201 | warncxx . . $ warn(d5d9ff45db7b5d36).("mlockall"); |
| 1202 | |
| 1203 | if (tracelimitcxx . . $ tracelimit. && trace_markercxx . . $ trace_marker.) |
| 1204 | enable_trace_markcxx . . $ enable_trace_mark(49f6e7a06ebc5aa8).(); |
| 1205 | |
| 1206 | thread = calloccxx . . $ calloc(63a7bf2941bfcd7a).(nr_threadscxx . . $ nr_threads., sizeof(*thread)); |
| 1207 | sched_data = calloccxx . . $ calloc(63a7bf2941bfcd7a).(nr_threadscxx . . $ nr_threads., sizeof(*sched_data)); |
| 1208 | if (!thread || !sched_data) |
| 1209 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("allocating threads"); |
| 1210 | |
| 1211 | if (histogramcxx . . $ histogram. && hset_initcxx . . $ hset_init(f7593c26bdc66446).(&hsetcxx . . $ hset., nr_threadscxx . . $ nr_threads., 1, histogramcxx . . $ histogram., histogramcxx . . $ histogram.)) |
| 1212 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("failed to allocate histogram of size %d for %d threads\n", |
| 1213 | histogramcxx . . $ histogram., nr_threadscxx . . $ nr_threads.); |
| 1214 | |
| 1215 | if (nr_threadscxx . . $ nr_threads. > nr_cpus) { |
| 1216 | /* |
| 1217 | * More threads than CPUs, then have the total be |
| 1218 | * no more than 80 percent. |
| 1219 | */ |
| 1220 | percent = nr_cpus * 80 / nr_threadscxx . . $ nr_threads.; |
| 1221 | } |
| 1222 | |
| 1223 | /* Set up the data while still in SCHED_FIFO */ |
| 1224 | for (i = 0; i < nr_threadscxx . . $ nr_threads.; i++) { |
| 1225 | sd = &sched_data[i]; |
| 1226 | /* |
| 1227 | * Interval is the deadline/period |
| 1228 | * The runtime is the percentage of that period. |
| 1229 | */ |
| 1230 | runtime = interval * percent / 100; |
| 1231 | |
| 1232 | if (runtime < 2000) { |
| 1233 | /* |
| 1234 | * If the runtime is less than 2ms, then we better |
| 1235 | * have HRTICK enabled. |
| 1236 | */ |
| 1237 | if (!setup_hr_tickcxx . . $ setup_hr_tick(b126dc7c1de90089).()) |
| 1238 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("For less than 2ms run times, you need to\n" |
| 1239 | "have HRTICK enabled in debugfs/sched_features\n"); |
| 1240 | } |
| 1241 | sd->runtime_uscxx . . $ sched_data#runtime_us. = runtime; |
| 1242 | sd->deadline_uscxx . . $ sched_data#deadline_us. = interval; |
| 1243 | |
| 1244 | if (histogramcxx . . $ histogram.) |
| 1245 | sd->statcxx . . $ sched_data#stat..histcxx . . $ thread_stat#hist. = &hsetcxx . . $ hset..histoscxx . . $ histoset#histos.[i]; |
| 1246 | |
| 1247 | infocxx . . $ info(26800c7917ec8ef2).(info_enablecxx . . $ info_enable., "interval: %lld:%lld\n", sd->runtime_uscxx . . $ sched_data#runtime_us., sd->deadline_uscxx . . $ sched_data#deadline_us.); |
| 1248 | |
| 1249 | /* Make sure that we can make our deadlines */ |
| 1250 | start_period = get_time_uscxx . . $ get_time_us(73266883b0c7072b).(); |
| 1251 | do_runtimecxx . . $ do_runtime(adf1066a871f9c04).(sd, start_period); |
| 1252 | end_period = get_time_uscxx . . $ get_time_us(73266883b0c7072b).(); |
| 1253 | if (end_period - start_period > sd->runtime_uscxx . . $ sched_data#runtime_us.) |
| 1254 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("Failed to perform task within runtime: Missed by %lld us\n", |
| 1255 | end_period - start_period - sd->runtime_uscxx . . $ sched_data#runtime_us.); |
| 1256 | |
| 1257 | infocxx . . $ info(26800c7917ec8ef2).(info_enablecxx . . $ info_enable., " Tested at %lldus of %lldus\n", |
| 1258 | end_period - start_period, sd->runtime_uscxx . . $ sched_data#runtime_us.); |
| 1259 | |
| 1260 | interval += step; |
| 1261 | } |
| 1262 | |
| 1263 | |
| 1264 | pthread_barrier_initcxx . . $ pthread_barrier_init(4180f681c7d0b92f).(&barriercxx . . $ barrier., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, nr_threadscxx . . $ nr_threads. + 1); |
| 1265 | |
| 1266 | for (i = 0; i < nr_threadscxx . . $ nr_threads.; i++) { |
| 1267 | sd = &sched_data[i]; |
| 1268 | pthread_createcxx . . $ pthread_create(2141a84bcac899e5).(&thread[i], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, run_deadlinecxx . . $ run_deadline(9f162e79bfc6c74)., sd); |
| 1269 | } |
| 1270 | |
| 1271 | atexitcxx . . $ atexit(8919c3b35e68c42d).(teardowncxx . . $ teardown(49f6e7a06ebc5aa8).); |
| 1272 | |
| 1273 | if (shutdowncxx . . $ shutdown.) |
| 1274 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("failed to setup child threads at step 1\n"); |
| 1275 | |
| 1276 | if (!all_cpuscxx . . $ all_cpus.) { |
| 1277 | int *pids; |
| 1278 | |
| 1279 | make_cpusetcxx . . $ make_cpuset(7749fb5eed986304).(CPUSET_ALLcxx . . $ `src/sched_deadline/cyclicdeadline.c:46:9`!, allcpu_buf, "0", |
| 1280 | CPUSET_FL_SET_LOADBALANCEcxx . . $ CPUSET_FL_SET_LOADBALANCE. | |
| 1281 | CPUSET_FL_CLONE_CHILDRENcxx . . $ CPUSET_FL_CLONE_CHILDREN. | |
| 1282 | CPUSET_FL_ALL_TASKScxx . . $ CPUSET_FL_ALL_TASKS.); |
| 1283 | |
| 1284 | pids = calloccxx . . $ calloc(63a7bf2941bfcd7a).(nr_threadscxx . . $ nr_threads. + 1, sizeof(int)); |
| 1285 | if (!pids) |
| 1286 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("Allocating pids"); |
| 1287 | |
| 1288 | for (i = 0; i < nr_threadscxx . . $ nr_threads.; i++) |
| 1289 | pids[i] = sched_data[i].statcxx . . $ sched_data#stat..tidcxx . . $ thread_stat#tid.; |
| 1290 | |
| 1291 | make_cpusetcxx . . $ make_cpuset(7749fb5eed986304).(CPUSET_LOCALcxx . . $ `src/sched_deadline/cyclicdeadline.c:47:9`!, setcpu, "0", |
| 1292 | CPUSET_FL_CPU_EXCLUSIVEcxx . . $ CPUSET_FL_CPU_EXCLUSIVE. | |
| 1293 | CPUSET_FL_SET_LOADBALANCEcxx . . $ CPUSET_FL_SET_LOADBALANCE. | |
| 1294 | CPUSET_FL_CLONE_CHILDRENcxx . . $ CPUSET_FL_CLONE_CHILDREN. | |
| 1295 | CPUSET_FL_TASKScxx . . $ CPUSET_FL_TASKS., pids); |
| 1296 | |
| 1297 | ret = systemcxx . . $ system(5c4306d8553b3696).("cat /sys/fs/cgroup/cpuset/my_cpuset/tasks"); |
| 1298 | if (ret < 0) |
| 1299 | perrorcxx . . $ perror(85c52e162fed56f9).("system call failed"); |
| 1300 | } |
| 1301 | |
| 1302 | debugcxx . . $ debug(26800c7917ec8ef2).(debug_enablecxx . . $ debug_enable., "main thread %d\n", gettidcxx . . $ gettid(b126dc7c1de90089).()); |
| 1303 | |
| 1304 | if (shutdowncxx . . $ shutdown.) |
| 1305 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("failed to setup child threads at step 2"); |
| 1306 | |
| 1307 | pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(&barriercxx . . $ barrier.); |
| 1308 | |
| 1309 | signalcxx . . $ signal(c2d516773f91faf8).(SIGINTcxx . . $ `<external>/11773118241360591791/signum-generic.h:48:9`!, sighandcxx . . $ sighand(d4f767463ce0a6b3).); |
| 1310 | signalcxx . . $ signal(c2d516773f91faf8).(SIGTERMcxx . . $ `<external>/11773118241360591791/signum-generic.h:53:9`!, sighandcxx . . $ sighand(d4f767463ce0a6b3).); |
| 1311 | signalcxx . . $ signal(c2d516773f91faf8).(SIGALRMcxx . . $ `<external>/11773118241360591791/signum-generic.h:61:9`!, sighandcxx . . $ sighand(d4f767463ce0a6b3).); |
| 1312 | |
| 1313 | if (duration) |
| 1314 | alarmcxx . . $ alarm(2141b656ce2cc063).(duration); |
| 1315 | |
| 1316 | loopcxx . . $ loop(b05606f264c99c67).(sched_data, nr_threadscxx . . $ nr_threads.); |
| 1317 | |
| 1318 | if (tracelimitcxx . . $ tracelimit.) { |
| 1319 | if (break_thread_idcxx . . $ break_thread_id.) { |
| 1320 | printfcxx . . $ printf(581fddd72a8db8fc).("# Break thread: %d\n", break_thread_idcxx . . $ break_thread_id.); |
| 1321 | printfcxx . . $ printf(581fddd72a8db8fc).("# Break value: %llu\n", (unsigned long long)break_thread_valuecxx . . $ break_thread_value.); |
| 1322 | } |
| 1323 | } |
| 1324 | |
| 1325 | for (i = 0; i < nr_threadscxx . . $ nr_threads.; i++) { |
| 1326 | |
| 1327 | sd = &sched_data[i]; |
| 1328 | |
| 1329 | res = join_threadcxx . . $ join_thread(779c4cd7ad3bfa56).(&thread[i]); |
| 1330 | if (res) { |
| 1331 | warncxx . . $ warn(d5d9ff45db7b5d36).("Thread %d failed: %s\n", i, res); |
| 1332 | continue; |
| 1333 | } |
| 1334 | } |
| 1335 | |
| 1336 | if (strlencxx . . $ strlen(751346f8406fd082).(jsonfilecxx . . $ jsonfile.) != 0) |
| 1337 | rt_write_jsoncxx . . $ rt_write_json(969c696bbc9a09ad).(jsonfilecxx . . $ jsonfile., 0, write_statscxx . . $ write_stats(2fd218767557b4b8)., sched_data); |
| 1338 | |
| 1339 | if (setcpu_buf) |
| 1340 | freecxx . . $ free(5d22bdacc48458e8).(setcpu_buf); |
| 1341 | freecxx . . $ free(5d22bdacc48458e8).(thread); |
| 1342 | freecxx . . $ free(5d22bdacc48458e8).(sched_data); |
| 1343 | if (histfilecxx . . $ histfile.) |
| 1344 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(histfilecxx . . $ histfile.); |
| 1345 | hset_destroycxx . . $ hset_destroy(33dbd104c143235e).(&hsetcxx . . $ hset.); |
| 1346 | |
| 1347 | return 0; |
| 1348 | } |