Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf record: Add support for arch_sdt_arg_parse_op() on s390

commit e5e66adfe45a6 ("perf regs: Remove __weak attributive arch_sdt_arg_parse_op() function")
removes arch_sdt_arg_parse_op() functions and reveals missing s390 support.
The following warning is printed:

Unknown ELF machine 22, standard arguments parse will be skipped.

ELF machine 22 is the EM_S390 host. This happens with command
# ./perf record -v -- stress-ng -t 1s --matrix 0
when the event is not specified.

Add s390 specific __perf_sdt_arg_parse_op_s390() function to support
-architecture calls to arch_sdt_arg_parse_op() for s390.
The warning disappears.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Tested-by: Jan Polensky <japo@linux.ibm.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Thomas Richter and committed by
Namhyung Kim
46a009cf 5c980ab2

+82
+78
tools/perf/util/perf-regs-arch/perf_regs_s390.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 3 + #include <errno.h> 4 + #include <regex.h> 3 5 #include "../perf_regs.h" 4 6 #include "../../arch/s390/include/perf_regs.h" 7 + #include "debug.h" 8 + 9 + #include <linux/zalloc.h> 10 + #include <linux/kernel.h> 5 11 6 12 uint64_t __perf_reg_mask_s390(bool intr __maybe_unused) 7 13 { ··· 100 94 uint64_t __perf_reg_sp_s390(void) 101 95 { 102 96 return PERF_REG_S390_R15; 97 + } 98 + 99 + /* %rXX */ 100 + #define SDT_OP_REGEX1 "^(%r([0-9]|1[0-5]))$" 101 + /* +-###(%rXX) */ 102 + #define SDT_OP_REGEX2 "^([+-]?[0-9]+\\(%r([0-9]|1[0-5])\\))$" 103 + static regex_t sdt_op_regex1, sdt_op_regex2; 104 + 105 + static int sdt_init_op_regex(void) 106 + { 107 + static int initialized; 108 + int ret = 0; 109 + 110 + if (initialized) 111 + return 0; 112 + 113 + ret = regcomp(&sdt_op_regex1, SDT_OP_REGEX1, REG_EXTENDED); 114 + if (ret) 115 + goto error; 116 + initialized = 1; 117 + 118 + ret = regcomp(&sdt_op_regex2, SDT_OP_REGEX2, REG_EXTENDED); 119 + if (ret) 120 + goto free_regex1; 121 + initialized = 2; 122 + 123 + return 0; 124 + 125 + free_regex1: 126 + regfree(&sdt_op_regex1); 127 + error: 128 + pr_debug4("Regex compilation error, initialized %d\n", initialized); 129 + initialized = 0; 130 + return ret; 131 + } 132 + 133 + /* 134 + * Parse OP and convert it into uprobe format, which is, +/-NUM(%gprREG). 135 + * Possible variants of OP are: 136 + * Format Example 137 + * ------------------------- 138 + * NUM(%rREG) 48(%r1) 139 + * -NUM(%rREG) -48(%r1) 140 + * +NUM(%rREG) +48(%r1) 141 + * %rREG %r1 142 + */ 143 + int __perf_sdt_arg_parse_op_s390(char *old_op, char **new_op) 144 + { 145 + int ret, new_len; 146 + regmatch_t rm[6]; 147 + 148 + *new_op = NULL; 149 + ret = sdt_init_op_regex(); 150 + if (ret) 151 + return -EINVAL; 152 + 153 + if (!regexec(&sdt_op_regex1, old_op, ARRAY_SIZE(rm), rm, 0) || 154 + !regexec(&sdt_op_regex2, old_op, ARRAY_SIZE(rm), rm, 0)) { 155 + new_len = 1; /* NULL byte */ 156 + new_len += (int)(rm[1].rm_eo - rm[1].rm_so); 157 + *new_op = zalloc(new_len); 158 + if (!*new_op) 159 + return -ENOMEM; 160 + 161 + scnprintf(*new_op, new_len, "%.*s", 162 + (int)(rm[1].rm_eo - rm[1].rm_so), old_op + rm[1].rm_so); 163 + } else { 164 + pr_debug4("Skipping unsupported SDT argument: %s\n", old_op); 165 + return SDT_ARG_SKIP; 166 + } 167 + 168 + return SDT_ARG_VALID; 103 169 }
+3
tools/perf/util/perf_regs.c
··· 23 23 case EM_X86_64: 24 24 ret = __perf_sdt_arg_parse_op_x86(old_op, new_op); 25 25 break; 26 + case EM_S390: 27 + ret = __perf_sdt_arg_parse_op_s390(old_op, new_op); 28 + break; 26 29 default: 27 30 pr_debug("Unknown ELF machine %d, standard arguments parse will be skipped.\n", 28 31 e_machine);
+1
tools/perf/util/perf_regs.h
··· 62 62 const char *__perf_reg_name_s390(int id); 63 63 uint64_t __perf_reg_ip_s390(void); 64 64 uint64_t __perf_reg_sp_s390(void); 65 + int __perf_sdt_arg_parse_op_s390(char *old_op, char **new_op); 65 66 66 67 int __perf_sdt_arg_parse_op_x86(char *old_op, char **new_op); 67 68 uint64_t __perf_reg_mask_x86(bool intr);