message: pcm-msr: implement -a option to read/write on all cores
diff: @@ -44,6 +44,7 @@ void print_usage(const char * progname)
  std::cout << " -w value : write the value before reading \n";
  std::cout << " -c core : perform msr read/write on specified core (default is 0)\n";
  std::cout << " -d : output all numbers in dec (default is hex)\n";
  + std::cout << " -a : perform msr read/write operations on all cores\n";
  std::cout << "\n";
  }
  @@ -60,7 +61,7 @@ int main(int argc, char * argv[])
  bool dec = false;
  int my_opt = -1;
  - while ((my_opt = getopt(argc, argv, "w:c:d")) != -1)
  + while ((my_opt = getopt(argc, argv, "w:c:d:a")) != -1)
  {
  switch (my_opt)
  {
  @@ -74,6 +75,9 @@ int main(int argc, char * argv[])
  case 'd':
  dec = true;
  break;
  + case 'a':
  + core = -1;
  + break;
  default:
  print_usage(argv[0]);
  return -1;
  @@ -106,6 +110,8 @@ int main(int argc, char * argv[])
  return -1;
  }
  #endif
  + auto doOne = [&dec, &write, &value, &msr](int core)
  + {
  try {
  MsrHandle h(core);
  if (!dec) std::cout << std::hex << std::showbase;
  @@ -132,4 +138,21 @@ int main(int argc, char * argv[])
  std::cerr << "Error accessing MSRs: " << e.what() << std::endl;
  std::cerr << "Please check if the program can access MSR drivers." << std::endl;
  }
  + };
  + if (core >= 0)
  + {
  + doOne(core);
  + }
  + else
  + {
  + set_signal_handlers();
  + auto m = PCM::getInstance();
  + for (uint32 i = 0; i < m->getNumCores(); ++i)
  + {
  + if (m->isCoreOnline(i))
  + {
  + doOne(i);
  + }
  + }
  + }
  }
  