~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Copyright 2014, Michael Ellerman, IBM Corp.
  4  */
  5 
  6 #include <stdio.h>
  7 #include <stdlib.h>
  8 #include <sys/ioctl.h>
  9 
 10 #include "ebb.h"
 11 
 12 
 13 /*
 14  * Test counting multiple events using EBBs.
 15  */
 16 int multi_counter(void)
 17 {
 18         struct event events[6];
 19         int i, group_fd;
 20 
 21         SKIP_IF(!ebb_is_supported());
 22 
 23         event_init_named(&events[0], 0x1001C, "PM_CMPLU_STALL_THRD");
 24         event_init_named(&events[1], 0x2D016, "PM_CMPLU_STALL_FXU");
 25         event_init_named(&events[2], 0x30006, "PM_CMPLU_STALL_OTHER_CMPL");
 26         event_init_named(&events[3], 0x4000A, "PM_CMPLU_STALL");
 27         event_init_named(&events[4], 0x600f4, "PM_RUN_CYC");
 28         event_init_named(&events[5], 0x500fa, "PM_RUN_INST_CMPL");
 29 
 30         event_leader_ebb_init(&events[0]);
 31         for (i = 1; i < 6; i++)
 32                 event_ebb_init(&events[i]);
 33 
 34         group_fd = -1;
 35         for (i = 0; i < 6; i++) {
 36                 events[i].attr.exclude_kernel = 1;
 37                 events[i].attr.exclude_hv = 1;
 38                 events[i].attr.exclude_idle = 1;
 39 
 40                 FAIL_IF(event_open_with_group(&events[i], group_fd));
 41                 if (group_fd == -1)
 42                         group_fd = events[0].fd;
 43         }
 44 
 45         ebb_enable_pmc_counting(1);
 46         ebb_enable_pmc_counting(2);
 47         ebb_enable_pmc_counting(3);
 48         ebb_enable_pmc_counting(4);
 49         ebb_enable_pmc_counting(5);
 50         ebb_enable_pmc_counting(6);
 51         setup_ebb_handler(standard_ebb_callee);
 52 
 53         FAIL_IF(ioctl(events[0].fd, PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP));
 54         FAIL_IF(event_read(&events[0]));
 55 
 56         ebb_global_enable();
 57 
 58         mtspr(SPRN_PMC1, pmc_sample_period(sample_period));
 59         mtspr(SPRN_PMC2, pmc_sample_period(sample_period));
 60         mtspr(SPRN_PMC3, pmc_sample_period(sample_period));
 61         mtspr(SPRN_PMC4, pmc_sample_period(sample_period));
 62         mtspr(SPRN_PMC5, pmc_sample_period(sample_period));
 63         mtspr(SPRN_PMC6, pmc_sample_period(sample_period));
 64 
 65         while (ebb_state.stats.ebb_count < 50) {
 66                 FAIL_IF(core_busy_loop());
 67                 FAIL_IF(ebb_check_mmcr0());
 68         }
 69 
 70         ebb_global_disable();
 71         ebb_freeze_pmcs();
 72 
 73         dump_ebb_state();
 74 
 75         for (i = 0; i < 6; i++)
 76                 event_close(&events[i]);
 77 
 78         FAIL_IF(ebb_state.stats.ebb_count == 0);
 79 
 80         return 0;
 81 }
 82 
 83 int main(void)
 84 {
 85         return test_harness(multi_counter, "multi_counter");
 86 }
 87 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php