Changes in 4.9.237 ARM: dts: socfpga: fix register entry for timer3 on Arria10 RDMA/rxe: Fix memleak in rxe_mem_init_user RDMA/rxe: Drop pointless checks in rxe_init_ports scsi: libsas: Set data_dir as DMA_NONE if libata marks qc as NODATA drivers/net/wan/lapbether: Added needed_tailroom NFC: st95hf: Fix memleak in st95hf_in_send_cmd firestream: Fix memleak in fs_open ALSA: hda: Fix 2 channel swapping for Tegra drivers/net/wan/lapbether: Set network_header before transmitting xfs: initialize the shortform attr header padding entry irqchip/eznps: Fix build error for !ARC700 builds drivers/net/wan/hdlc_cisco: Add hard_header_len ALSA: hda: fix a runtime pm issue in SOF when integrated GPU is disabled gcov: Disable gcov build with GCC 10 iio: adc: mcp3422: fix locking scope iio: adc: mcp3422: fix locking on error path iio: adc: ti-ads1015: fix conversion when CONFIG_PM is not set iio:light:ltr501 Fix timestamp alignment issue. iio:accel:bmc150-accel: Fix timestamp alignment and prevent data leak. iio:adc:ina2xx Fix timestamp alignment issue. iio:adc:ti-adc081c Fix alignment and data leak issues drivers: iio: magnetometer: Fix sparse endianness warnings cast to restricted __be16 iio:magnetometer:ak8975 Fix alignment and data leak issues. iio:light:max44000 Fix timestamp alignment and prevent data leak. iio: accel: kxsd9: Fix alignment of local buffer. iio:accel:mma7455: Fix timestamp alignment and prevent data leak. iio:accel:mma8452: Fix timestamp alignment and prevent data leak. USB: core: add helpers to retrieve endpoints staging: wlan-ng: fix out of bounds read in prism2sta_probe_usb() btrfs: fix wrong address when faulting in pages in the search ioctl regulator: push allocation in set_consumer_device_supply() out of lock scsi: target: iscsi: Fix data digest calculation scsi: target: iscsi: Fix hang in iscsit_access_np() when getting tpg->np_login_sem rbd: require global CAP_SYS_ADMIN for mapping and unmapping fbcon: remove soft scrollback code fbcon: remove now unusued 'softback_lines' cursor() argument vgacon: remove software scrollback support KVM: VMX: Don't freeze guest when event delivery causes an APIC-access exit video: fbdev: fix OOB read in vga_8planes_imageblit() staging: greybus: audio: fix uninitialized value issue usb: core: fix slab-out-of-bounds Read in read_descriptors USB: serial: ftdi_sio: add IDs for Xsens Mti USB converter USB: serial: option: add support for SIM7070/SIM7080/SIM7090 modules usb: Fix out of sync data toggle if a configured device is reconfigured IB/rxe: Remove a pointless indirection layer RDMA/rxe: Fix the parent sysfs read when the interface has 15 chars gcov: add support for GCC 10.1 net: handle the return value of pskb_carve_frag_list() correctly NFSv4.1 handle ERR_DELAY error reclaiming locking state on delegation recall scsi: pm8001: Fix memleak in pm8001_exec_internal_task_abort scsi: lpfc: Fix FLOGI/PLOGI receive race condition in pt2pt discovery spi: spi-loopback-test: Fix out-of-bounds read SUNRPC: stop printk reading past end of string rapidio: Replace 'select' DMAENGINES 'with depends on' i2c: algo: pca: Reapply i2c bus settings after reset clk: rockchip: Fix initialization of mux_pll_src_4plls_p Drivers: hv: vmbus: Add timeout to vmbus_wait_for_unload MIPS: SNI: Fix MIPS_L1_CACHE_SHIFT perf test: Free formats for perf pmu parse test fbcon: Fix user font detection test at fbcon_resize(). MIPS: SNI: Fix spurious interrupts drm/mediatek: Add exception handing in mtk_drm_probe() if component init fail USB: quirks: Add USB_QUIRK_IGNORE_REMOTE_WAKEUP quirk for BYD zhaoxin notebook USB: UAS: fix disconnect by unplugging a hub usblp: fix race between disconnect() and read() Input: i8042 - add Entroware Proteus EL07R4 to nomux and reset lists serial: 8250_pci: Add Realtek 816a and 816b ehci-hcd: Move include to keep CRC stable powerpc/dma: Fix dma_map_ops::get_required_mask x86/defconfig: Enable CONFIG_USB_XHCI_HCD=y Linux 4.9.237 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I675fbd4859f56d7dfefa3f23bcf61e38c3bebdc1
176 lines
3.8 KiB
C
176 lines
3.8 KiB
C
#include "parse-events.h"
|
|
#include "pmu.h"
|
|
#include "util.h"
|
|
#include "tests.h"
|
|
|
|
/* Simulated format definitions. */
|
|
static struct test_format {
|
|
const char *name;
|
|
const char *value;
|
|
} test_formats[] = {
|
|
{ "krava01", "config:0-1,62-63\n", },
|
|
{ "krava02", "config:10-17\n", },
|
|
{ "krava03", "config:5\n", },
|
|
{ "krava11", "config1:0,2,4,6,8,20-28\n", },
|
|
{ "krava12", "config1:63\n", },
|
|
{ "krava13", "config1:45-47\n", },
|
|
{ "krava21", "config2:0-3,10-13,20-23,30-33,40-43,50-53,60-63\n", },
|
|
{ "krava22", "config2:8,18,48,58\n", },
|
|
{ "krava23", "config2:28-29,38\n", },
|
|
};
|
|
|
|
/* Simulated users input. */
|
|
static struct parse_events_term test_terms[] = {
|
|
{
|
|
.config = (char *) "krava01",
|
|
.val.num = 15,
|
|
.type_val = PARSE_EVENTS__TERM_TYPE_NUM,
|
|
.type_term = PARSE_EVENTS__TERM_TYPE_USER,
|
|
},
|
|
{
|
|
.config = (char *) "krava02",
|
|
.val.num = 170,
|
|
.type_val = PARSE_EVENTS__TERM_TYPE_NUM,
|
|
.type_term = PARSE_EVENTS__TERM_TYPE_USER,
|
|
},
|
|
{
|
|
.config = (char *) "krava03",
|
|
.val.num = 1,
|
|
.type_val = PARSE_EVENTS__TERM_TYPE_NUM,
|
|
.type_term = PARSE_EVENTS__TERM_TYPE_USER,
|
|
},
|
|
{
|
|
.config = (char *) "krava11",
|
|
.val.num = 27,
|
|
.type_val = PARSE_EVENTS__TERM_TYPE_NUM,
|
|
.type_term = PARSE_EVENTS__TERM_TYPE_USER,
|
|
},
|
|
{
|
|
.config = (char *) "krava12",
|
|
.val.num = 1,
|
|
.type_val = PARSE_EVENTS__TERM_TYPE_NUM,
|
|
.type_term = PARSE_EVENTS__TERM_TYPE_USER,
|
|
},
|
|
{
|
|
.config = (char *) "krava13",
|
|
.val.num = 2,
|
|
.type_val = PARSE_EVENTS__TERM_TYPE_NUM,
|
|
.type_term = PARSE_EVENTS__TERM_TYPE_USER,
|
|
},
|
|
{
|
|
.config = (char *) "krava21",
|
|
.val.num = 119,
|
|
.type_val = PARSE_EVENTS__TERM_TYPE_NUM,
|
|
.type_term = PARSE_EVENTS__TERM_TYPE_USER,
|
|
},
|
|
{
|
|
.config = (char *) "krava22",
|
|
.val.num = 11,
|
|
.type_val = PARSE_EVENTS__TERM_TYPE_NUM,
|
|
.type_term = PARSE_EVENTS__TERM_TYPE_USER,
|
|
},
|
|
{
|
|
.config = (char *) "krava23",
|
|
.val.num = 2,
|
|
.type_val = PARSE_EVENTS__TERM_TYPE_NUM,
|
|
.type_term = PARSE_EVENTS__TERM_TYPE_USER,
|
|
},
|
|
};
|
|
|
|
/*
|
|
* Prepare format directory data, exported by kernel
|
|
* at /sys/bus/event_source/devices/<dev>/format.
|
|
*/
|
|
static char *test_format_dir_get(void)
|
|
{
|
|
static char dir[PATH_MAX];
|
|
unsigned int i;
|
|
|
|
snprintf(dir, PATH_MAX, "/tmp/perf-pmu-test-format-XXXXXX");
|
|
if (!mkdtemp(dir))
|
|
return NULL;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(test_formats); i++) {
|
|
static char name[PATH_MAX];
|
|
struct test_format *format = &test_formats[i];
|
|
FILE *file;
|
|
|
|
scnprintf(name, PATH_MAX, "%s/%s", dir, format->name);
|
|
|
|
file = fopen(name, "w");
|
|
if (!file)
|
|
return NULL;
|
|
|
|
if (1 != fwrite(format->value, strlen(format->value), 1, file))
|
|
break;
|
|
|
|
fclose(file);
|
|
}
|
|
|
|
return dir;
|
|
}
|
|
|
|
/* Cleanup format directory. */
|
|
static int test_format_dir_put(char *dir)
|
|
{
|
|
char buf[PATH_MAX];
|
|
snprintf(buf, PATH_MAX, "rm -f %s/*\n", dir);
|
|
if (system(buf))
|
|
return -1;
|
|
|
|
snprintf(buf, PATH_MAX, "rmdir %s\n", dir);
|
|
return system(buf);
|
|
}
|
|
|
|
static struct list_head *test_terms_list(void)
|
|
{
|
|
static LIST_HEAD(terms);
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(test_terms); i++)
|
|
list_add_tail(&test_terms[i].list, &terms);
|
|
|
|
return &terms;
|
|
}
|
|
|
|
int test__pmu(int subtest __maybe_unused)
|
|
{
|
|
char *format = test_format_dir_get();
|
|
LIST_HEAD(formats);
|
|
struct list_head *terms = test_terms_list();
|
|
int ret;
|
|
|
|
if (!format)
|
|
return -EINVAL;
|
|
|
|
do {
|
|
struct perf_event_attr attr;
|
|
|
|
memset(&attr, 0, sizeof(attr));
|
|
|
|
ret = perf_pmu__format_parse(format, &formats);
|
|
if (ret)
|
|
break;
|
|
|
|
ret = perf_pmu__config_terms(&formats, &attr, terms,
|
|
false, NULL);
|
|
if (ret)
|
|
break;
|
|
|
|
ret = -EINVAL;
|
|
|
|
if (attr.config != 0xc00000000002a823)
|
|
break;
|
|
if (attr.config1 != 0x8000400000000145)
|
|
break;
|
|
if (attr.config2 != 0x0400000020041d07)
|
|
break;
|
|
|
|
ret = 0;
|
|
} while (0);
|
|
|
|
perf_pmu__del_formats(&formats);
|
|
test_format_dir_put(format);
|
|
return ret;
|
|
}
|