================
@@ -112,9 +116,11 @@ class Counter {
   PerfEvent Event;
   int FileDescriptor = -1;
   bool IsDummyEvent;
+  std::vector<PerfEvent> ValidationEvents;
----------------
legrosbuffle wrote:

OK, let's rename `Counter` to `CounterGroup`, but let's at least create a 
(private) abstraction for an event and attached FD, to avoid the aligned arrays 
code duplication in `Counter::initRealEvent`:

```
  struct ConfiguredEvent {
    llvm::Error init(const pid_t ProcessID, const int GroupFd) {
      constexpr  int Cpu = -1;     // measure any processor.
      constexpr int GroupFd = -1; // no grouping of counters.
      constexpr uint32_t Flags = 0;
      perf_event_attr AttrCopy = *Event.attribute();
      FileDescriptor = perf_event_open(&AttrCopy, ProcessID, Cpu, GroupFd, 
Flags);
      if (FileDescriptor == -1) {
        return ...;
      }
    };
    PerfEvent Event;
    int FileDescriptor = -1;
  };
  // The main event, configured as an ungrouped event.
  ConfiguredEvent MainEvent;
  bool IsDummyEvent;
  // A set of optional validation events grouped into the file descriptor for
  // `MainEvent` using `PERF_IOC_FLAG_GROUP`.
  std::vector<ConfiguredEvent> ValidationEvents;
```

https://github.com/llvm/llvm-project/pull/76653
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to