|
Packit |
577717 |
/* pfmlib_intel_netburst_perf_event.c : perf_event Intel Netburst functions
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Copyright (c) 2011 Google, Inc
|
|
Packit |
577717 |
* Contributed by Stephane Eranian <eranian@gmail.com>
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
Packit |
577717 |
* of this software and associated documentation files (the "Software"), to deal
|
|
Packit |
577717 |
* in the Software without restriction, including without limitation the rights
|
|
Packit |
577717 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
Packit |
577717 |
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
Packit |
577717 |
* subject to the following conditions:
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* The above copyright notice and this permission notice shall be included in all
|
|
Packit |
577717 |
* copies or substantial portions of the Software.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
Packit |
577717 |
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
Packit |
577717 |
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
Packit |
577717 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
Packit |
577717 |
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
|
Packit |
577717 |
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* This file implements the common code for all Intel X86 processors.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
#include <sys/types.h>
|
|
Packit |
577717 |
#include <string.h>
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
#include <stdarg.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* private headers */
|
|
Packit |
577717 |
#include "pfmlib_priv.h"
|
|
Packit |
577717 |
#include "pfmlib_intel_netburst_priv.h"
|
|
Packit |
577717 |
#include "pfmlib_perf_event_priv.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
pfm_netburst_get_perf_encoding(void *this, pfmlib_event_desc_t *e)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
const netburst_entry_t *pe = this_pe(this);
|
|
Packit |
577717 |
struct perf_event_attr *attr = e->os_data;
|
|
Packit |
577717 |
int perf_code = pe[e->event].perf_code;
|
|
Packit |
577717 |
uint64_t escr;
|
|
Packit |
577717 |
int ret;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
ret = pfm_netburst_get_encoding(this, e);
|
|
Packit |
577717 |
if (ret != PFM_SUCCESS)
|
|
Packit |
577717 |
return ret;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
attr->type = PERF_TYPE_RAW;
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* codes[0] = ESCR
|
|
Packit |
577717 |
* codes[1] = CCCR
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* cleanup event_select, and install perf specific code
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
escr = e->codes[0] & ~(0x3full << 25);
|
|
Packit |
577717 |
escr |= perf_code << 25;
|
|
Packit |
577717 |
attr->config = (escr << 32) | e->codes[1];
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return PFM_SUCCESS;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
void
|
|
Packit |
577717 |
pfm_netburst_perf_validate_pattrs(void *this, pfmlib_event_desc_t *e)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int i, compact;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for (i = 0; i < e->npattrs; i++) {
|
|
Packit |
577717 |
compact = 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* umasks never conflict */
|
|
Packit |
577717 |
if (e->pattrs[i].type == PFM_ATTR_UMASK)
|
|
Packit |
577717 |
continue;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* with perf_events, u and k are handled at the OS level
|
|
Packit |
577717 |
* via exclude_user, exclude_kernel.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
if (e->pattrs[i].ctrl == PFM_ATTR_CTRL_PMU) {
|
|
Packit |
577717 |
if (e->pattrs[i].idx == NETBURST_ATTR_U
|
|
Packit |
577717 |
|| e->pattrs[i].idx == NETBURST_ATTR_K)
|
|
Packit |
577717 |
compact = 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if (e->pattrs[i].ctrl == PFM_ATTR_CTRL_PERF_EVENT) {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* no PEBS support (for now) */
|
|
Packit |
577717 |
if (e->pattrs[i].idx == PERF_ATTR_PR)
|
|
Packit |
577717 |
compact = 1;
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* No hypervisor on Intel */
|
|
Packit |
577717 |
if (e->pattrs[i].idx == PERF_ATTR_H)
|
|
Packit |
577717 |
compact = 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (compact) {
|
|
Packit |
577717 |
pfmlib_compact_pattrs(e, i);
|
|
Packit |
577717 |
i--;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|