kvm-stat.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Arch specific functions for perf kvm stat.
  3. *
  4. * Copyright 2014 IBM Corp.
  5. * Author(s): Alexander Yarygin <yarygin@linux.vnet.ibm.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License (version 2 only)
  9. * as published by the Free Software Foundation.
  10. */
  11. #include "../../util/kvm-stat.h"
  12. #include <asm/sie.h>
  13. define_exit_reasons_table(sie_exit_reasons, sie_intercept_code);
  14. define_exit_reasons_table(sie_icpt_insn_codes, icpt_insn_codes);
  15. define_exit_reasons_table(sie_sigp_order_codes, sigp_order_codes);
  16. define_exit_reasons_table(sie_diagnose_codes, diagnose_codes);
  17. define_exit_reasons_table(sie_icpt_prog_codes, icpt_prog_codes);
  18. const char *vcpu_id_str = "id";
  19. const int decode_str_len = 40;
  20. const char *kvm_exit_reason = "icptcode";
  21. const char *kvm_entry_trace = "kvm:kvm_s390_sie_enter";
  22. const char *kvm_exit_trace = "kvm:kvm_s390_sie_exit";
  23. static void event_icpt_insn_get_key(struct perf_evsel *evsel,
  24. struct perf_sample *sample,
  25. struct event_key *key)
  26. {
  27. unsigned long insn;
  28. insn = perf_evsel__intval(evsel, sample, "instruction");
  29. key->key = icpt_insn_decoder(insn);
  30. key->exit_reasons = sie_icpt_insn_codes;
  31. }
  32. static void event_sigp_get_key(struct perf_evsel *evsel,
  33. struct perf_sample *sample,
  34. struct event_key *key)
  35. {
  36. key->key = perf_evsel__intval(evsel, sample, "order_code");
  37. key->exit_reasons = sie_sigp_order_codes;
  38. }
  39. static void event_diag_get_key(struct perf_evsel *evsel,
  40. struct perf_sample *sample,
  41. struct event_key *key)
  42. {
  43. key->key = perf_evsel__intval(evsel, sample, "code");
  44. key->exit_reasons = sie_diagnose_codes;
  45. }
  46. static void event_icpt_prog_get_key(struct perf_evsel *evsel,
  47. struct perf_sample *sample,
  48. struct event_key *key)
  49. {
  50. key->key = perf_evsel__intval(evsel, sample, "code");
  51. key->exit_reasons = sie_icpt_prog_codes;
  52. }
  53. static struct child_event_ops child_events[] = {
  54. { .name = "kvm:kvm_s390_intercept_instruction",
  55. .get_key = event_icpt_insn_get_key },
  56. { .name = "kvm:kvm_s390_handle_sigp",
  57. .get_key = event_sigp_get_key },
  58. { .name = "kvm:kvm_s390_handle_diag",
  59. .get_key = event_diag_get_key },
  60. { .name = "kvm:kvm_s390_intercept_prog",
  61. .get_key = event_icpt_prog_get_key },
  62. { NULL, NULL },
  63. };
  64. static struct kvm_events_ops exit_events = {
  65. .is_begin_event = exit_event_begin,
  66. .is_end_event = exit_event_end,
  67. .child_ops = child_events,
  68. .decode_key = exit_event_decode_key,
  69. .name = "VM-EXIT"
  70. };
  71. const char *kvm_events_tp[] = {
  72. "kvm:kvm_s390_sie_enter",
  73. "kvm:kvm_s390_sie_exit",
  74. "kvm:kvm_s390_intercept_instruction",
  75. "kvm:kvm_s390_handle_sigp",
  76. "kvm:kvm_s390_handle_diag",
  77. "kvm:kvm_s390_intercept_prog",
  78. NULL,
  79. };
  80. struct kvm_reg_events_ops kvm_reg_events_ops[] = {
  81. { .name = "vmexit", .ops = &exit_events },
  82. { NULL, NULL },
  83. };
  84. const char * const kvm_skip_events[] = {
  85. "Wait state",
  86. NULL,
  87. };
  88. int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid)
  89. {
  90. if (strstr(cpuid, "IBM/S390")) {
  91. kvm->exit_reasons = sie_exit_reasons;
  92. kvm->exit_reasons_isa = "SIE";
  93. } else
  94. return -ENOTSUP;
  95. return 0;
  96. }