title: program context from perf sample event
body: <p>I am using perf_event utility to collect PEBS sample in kernel space. How can I get context information (interrupt/nmi context, program context) from perf_sample_data? I can see that perf_regs contains register informations. Which register bits indicate context of the sample?    </p>
  
  <p><strong>Update:</strong></p>
  
  <p>I am using perf_event_open from userspace and modifying kernel in the perf event handler. I am configuring perf_event with following attribute (mem trans retired) for Intel Broadwel machine.</p>
  
  <pre><code>struct perf_event_attr pe = {
          .type                   = PERF_TYPE_RAW,
          .size                   = sizeof(struct perf_event_attr),
          .sample_period          = 10003,
          .sample_type            = PEBS_SAMPLE_TYPE,
          .exclude_user           = 1,
          .exclude_kernel         = 0,
          .exclude_hv             = 0,
          .disabled               = 0, 
          .config                 = 0x1cd,
          .config1                = 0x3,
          .precise_ip             = 3,
          .exclude_callchain_kernel = 0,
          .read_format            = PERF_FORMAT_GROUP | PERF_FORMAT_ID,
          .task                   = 1,
      };
      perf_event_open(&amp;pe, processId, -1, -1 /*group*/, 0);
  </code></pre>
  
  <p>In the kernel space perf event handler, I have perf_sample_data on each sample event. How can I know whether the sample was taken from interrupt handler or the sample was from process context?</p>