File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 57
57
#ifdef __linux__
58
58
#include < sys/mman.h>
59
59
#include < dirent.h>
60
+ #include < sys/resource.h>
60
61
#endif
61
62
#endif
62
63
@@ -2059,6 +2060,30 @@ std::ofstream* PCM::outfile = nullptr; // output file stream
2059
2060
std::streambuf* PCM::backup_ofile = nullptr ; // backup of original output = cout
2060
2061
std::streambuf* PCM::backup_ofile_cerr = nullptr ; // backup of original output = cerr
2061
2062
2063
+ #ifdef __linux__
2064
+ void increaseULimit ()
2065
+ {
2066
+ rlimit lim{};
2067
+ if (getrlimit (RLIMIT_NOFILE, &lim) == 0 )
2068
+ {
2069
+ const rlim_t recommendedLimit = 1000000 ;
2070
+ // std::cout << "file open limit: " << lim.rlim_cur << "," << lim.rlim_max << "\n";
2071
+ if (lim.rlim_cur < recommendedLimit || lim.rlim_max < recommendedLimit)
2072
+ {
2073
+ lim.rlim_cur = lim.rlim_max = recommendedLimit;
2074
+ if (setrlimit (RLIMIT_NOFILE, &lim) != 0 )
2075
+ {
2076
+ std::cerr << " PCM Info: setrlimit for file limit " << recommendedLimit << " failed with error " << strerror (errno) << " \n " ;
2077
+ }
2078
+ }
2079
+ }
2080
+ else
2081
+ {
2082
+ std::cerr << " PCM Info: getrlimit for file limit failed with error " << strerror (errno) << " \n " ;
2083
+ }
2084
+ }
2085
+ #endif
2086
+
2062
2087
PCM::PCM () :
2063
2088
cpu_family (-1 ),
2064
2089
cpu_model (-1 ),
@@ -2115,6 +2140,9 @@ PCM::PCM() :
2115
2140
run_state(1 ),
2116
2141
needToRestoreNMIWatchdog(false )
2117
2142
{
2143
+ #ifdef __linux__
2144
+ increaseULimit ();
2145
+ #endif
2118
2146
#ifdef _MSC_VER
2119
2147
// WARNING: This driver code (msr.sys) is only for testing purposes, not for production use
2120
2148
Driver drv (Driver::msrLocalPath ());
Original file line number Diff line number Diff line change @@ -238,7 +238,7 @@ MsrHandle::MsrHandle(uint32 cpu) : fd(-1), cpu_id(cpu)
238
238
delete[] path;
239
239
if (handle < 0 )
240
240
{
241
- std::cerr << " PCM Error: can't open MSR handle for core " << cpu << " \n " ;
241
+ std::cerr << " PCM Error: can't open MSR handle for core " << cpu << " ( " << strerror (errno) << " ) \n " ;
242
242
std::cerr << " Try no-MSR mode by setting env variable PCM_NO_MSR=1\n " ;
243
243
throw std::exception ();
244
244
}
You can’t perform that action at this time.
0 commit comments