Skip to content

Commit a995388

Browse files
committed
prevent process deep sleep
1 parent 67c2c12 commit a995388

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/mainReadout.cxx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
#include "ReadoutUtils.h"
3030

3131

32+
#include <sys/types.h>
33+
#include <sys/stat.h>
34+
#include <fcntl.h>
35+
36+
3237
// option to add callgrind instrumentation
3338
// to use: valgrind --tool=callgrind --instr-atstart=no --dump-instr=yes ./a.out
3439
// to display stats: kcachegrind
@@ -105,6 +110,19 @@ int main(int argc, char* argv[])
105110
theLog.log("Error : %s",err.c_str());
106111
return -1;
107112
}
113+
114+
115+
// try to prevent deep sleeps
116+
theLog.log("Disabling CPU deep sleep for process");
117+
int maxLatency=1;
118+
int latencyFd = open("/dev/cpu_dma_latency", O_WRONLY);
119+
if (latencyFd < 0) {
120+
theLog.log("Error opening /dev/cpu_dma_latency");
121+
} else {
122+
if (write(latencyFd, &maxLatency, sizeof(maxLatency)) != sizeof(maxLatency)) {
123+
theLog.log("Error writing to /dev/cpu_dma_latency");
124+
}
125+
}
108126

109127

110128
// extract optional configuration parameters
@@ -296,7 +314,7 @@ int main(int argc, char* argv[])
296314
// configuration of data sampling
297315
#ifdef WITH_DATASAMPLING
298316
int dataSampling=0;
299-
dataSampling=cfg.getValue<int>("sampling.enabled");
317+
cfg.getOptionalValue<int>("sampling.enabled",dataSampling);
300318
std::unique_ptr<AliceO2::DataSampling::InjectorInterface> dataSamplingInjector;
301319
if (dataSampling) {
302320
theLog.log("Data sampling enabled");
@@ -419,6 +437,10 @@ int main(int argc, char* argv[])
419437
}
420438
readoutDevices.clear(); // to do it all in one go
421439

440+
if (latencyFd>=0) {
441+
close(latencyFd);
442+
}
443+
422444
theLog.log("Operations completed");
423445

424446
return 0;

0 commit comments

Comments
 (0)