<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can PEBS sample every event? in Software Tuning, Performance Optimization &amp; Platform Monitoring</title>
    <link>https://community.intel.com/t5/Software-Tuning-Performance/Can-PEBS-sample-every-event/m-p/1385606#M8060</link>
    <description>&lt;P&gt;Ah so apparently is a feature, not a bug&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;From SDM 19.3.1.1 Enhancements of Performance Monitoring in the Processor Core inside 19.3.1 Performance Monitoring for Processors Based on Nehalem Microarchitecture&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Performance monitoring interrupts are triggered by a counter transitioning from maximum count to zero (assuming
IA32_PerfEvtSelX.INT is set). This same transition will cause PEBS hardware to arm, but not trigger. PEBS hard-
ware triggers upon detection of the first PEBS event after the PEBS hardware has been armed (a 0 to 1 transition
of the counter). At this point, a PEBS assist will be undertaken by the processor.
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 May 2022 12:47:31 GMT</pubDate>
    <dc:creator>barbito</dc:creator>
    <dc:date>2022-05-19T12:47:31Z</dc:date>
    <item>
      <title>Can PEBS sample every event?</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Can-PEBS-sample-every-event/m-p/1384578#M8057</link>
      <description>&lt;P&gt;&lt;STRONG&gt;TL;DR:&lt;/STRONG&gt;&lt;BR /&gt;Is it possible to sample every event with PEBS? With my experiments I wasn't able to get&amp;nbsp; more than&amp;nbsp; 1/2 samples (i.e. sample 1 captured, sample 2 missed, sample 3 captured, etc.)&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Long version:&lt;/STRONG&gt;&lt;BR /&gt;I am trying to sample with PEBS every mispredicted branch. I wrote a simple Linux kernel module to setup all the PEBS-related registers and I managed to get it working.&lt;/P&gt;
&lt;P&gt;From the initial results it seemed PEBS was missing some events. So I added 100 nops between every instruction to avoid "ghosting" and switched to an architectural event (branch taken).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To my surprise, PEBS successfully capture only 1 sample out of 2 with reset value set to -1. These are my results changing the reset value in the Debug Store "PEBS GP Counter 0 Reset" field:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Reset value -1:&amp;nbsp;&amp;nbsp; 1/2 events&lt;/LI&gt;
&lt;LI&gt;Reset value -2:&amp;nbsp;&amp;nbsp; 1/3 events&lt;/LI&gt;
&lt;LI&gt;Reset value -3:&amp;nbsp;&amp;nbsp; 1/4 events&lt;/LI&gt;
&lt;LI&gt;...&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Obviously when I use 0 as reset value I don't get any samples since 2^48 events must occur.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this an architectural limitation, or am I missing something?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 15:11:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Can-PEBS-sample-every-event/m-p/1384578#M8057</guid>
      <dc:creator>barbito</dc:creator>
      <dc:date>2022-05-16T15:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Can PEBS sample every event?</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Can-PEBS-sample-every-event/m-p/1385553#M8059</link>
      <description>&lt;P&gt;I found a temporary solution: use 2 GP counters and interleave them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;ds-&amp;gt;pebs_reset[0] = -1;
ds-&amp;gt;pebs_reset[1] = -1;

//When starting PEBS
wrmsrl(MSR_IA32_PERFCTR0, -1);
wrmsrl(MSR_IA32_PERFCTR1, -2);
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With this setup the majority of time I am able to capture all the samples, however sometimes the counters synchronize and the issue is back.&lt;BR /&gt;Any hints for a more elegant solution?&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 08:33:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Can-PEBS-sample-every-event/m-p/1385553#M8059</guid>
      <dc:creator>barbito</dc:creator>
      <dc:date>2022-05-19T08:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Can PEBS sample every event?</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Can-PEBS-sample-every-event/m-p/1385606#M8060</link>
      <description>&lt;P&gt;Ah so apparently is a feature, not a bug&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;From SDM 19.3.1.1 Enhancements of Performance Monitoring in the Processor Core inside 19.3.1 Performance Monitoring for Processors Based on Nehalem Microarchitecture&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Performance monitoring interrupts are triggered by a counter transitioning from maximum count to zero (assuming
IA32_PerfEvtSelX.INT is set). This same transition will cause PEBS hardware to arm, but not trigger. PEBS hard-
ware triggers upon detection of the first PEBS event after the PEBS hardware has been armed (a 0 to 1 transition
of the counter). At this point, a PEBS assist will be undertaken by the processor.
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 12:47:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Can-PEBS-sample-every-event/m-p/1385606#M8060</guid>
      <dc:creator>barbito</dc:creator>
      <dc:date>2022-05-19T12:47:31Z</dc:date>
    </item>
  </channel>
</rss>

