Hi Thomas,
Thanks again for your time and kindness to respond. I believe I may have found the answer. When you open a perf event related to HPC, a linux buffer for that HPC will be created. Somehow, the timer interrupt gets involved and writes to that buffer. So, the process that is being monitored is not context switched. This of course needs special CPU suppprt. You were right in your answer, I was looking for details under the hood. > On Mar 10, 2023, at 8:23 PM, Khaled Z Mahmoud <[email protected]> wrote: > > Thanks Thomas. > > For energy/RAPL, I believe it’s true. > Assuming it is exposed. how does the monitoring thread/exposing func, read > the foreign registers. These are not shared memory or shared cache-lines. > > The only way I know is attaching to a process through ptrace. > > > >> On Mar 10, 2023, at 7:53 PM, Tomas Kuchta <[email protected]> >> wrote: >> >> I'd imagine that it is all in plain text in /proc file system expised by >> the kernel. >> >> - Tomas >> >>>> On Fri, Mar 10, 2023, 19:51 Khaled Mahmoud <[email protected]> wrote: >>> >>> Hi, >>> >>> I have been trying to find an answer to this question for a long time, but >>> I have not found a clear answer or reference. >>> >>> *Context: *Linux perf tool, can read performance counters, either >>> system-wide or for specific threads/processes of interests. Performance >>> counters are stored in Model Specific Registers which are core registers. >>> >>> *Question*: How are tools like perf able to read the performance counters >>> that reside in foreign registers in foreign cores ? >>> >>> *My Understanding So Far*: Unless there is explicit support from CPU(s), >>> which there is nothing I am aware of, the only way to do this is through >>> Linux ptrace. You interrupt a process, inspect its values, and let go ? >>> >>> I asked this question in the PAPI mailing list a while ago, but I did not >>> get the answer I am looking for. They advised me to ask in a Linux group. >>> >>> Apologies if this is not the right group to ask the question >>> >>> >>> -- >>> Regards, >>> Khaled Mahmoud >>>
