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

bpftool: Fix typo in MAX_NUM_METRICS macro name

Correct typo in bpftool profiler and change all instances of 'MATRICS' to
'METRICS' in the profiler.bpf.c file.

Signed-off-by: Swan Beaujard <beaujardswan@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/bpf/20240602225812.81171-1-beaujardswan@gmail.com

authored by

Swan Beaujard and committed by
Daniel Borkmann
ce5249b9 a450d36b

+7 -7
+7 -7
tools/bpf/bpftool/skeleton/profiler.bpf.c
··· 40 40 41 41 const volatile __u32 num_cpu = 1; 42 42 const volatile __u32 num_metric = 1; 43 - #define MAX_NUM_MATRICS 4 43 + #define MAX_NUM_METRICS 4 44 44 45 45 SEC("fentry/XXX") 46 46 int BPF_PROG(fentry_XXX) 47 47 { 48 - struct bpf_perf_event_value___local *ptrs[MAX_NUM_MATRICS]; 48 + struct bpf_perf_event_value___local *ptrs[MAX_NUM_METRICS]; 49 49 u32 key = bpf_get_smp_processor_id(); 50 50 u32 i; 51 51 52 52 /* look up before reading, to reduce error */ 53 - for (i = 0; i < num_metric && i < MAX_NUM_MATRICS; i++) { 53 + for (i = 0; i < num_metric && i < MAX_NUM_METRICS; i++) { 54 54 u32 flag = i; 55 55 56 56 ptrs[i] = bpf_map_lookup_elem(&fentry_readings, &flag); ··· 58 58 return 0; 59 59 } 60 60 61 - for (i = 0; i < num_metric && i < MAX_NUM_MATRICS; i++) { 61 + for (i = 0; i < num_metric && i < MAX_NUM_METRICS; i++) { 62 62 struct bpf_perf_event_value___local reading; 63 63 int err; 64 64 ··· 99 99 SEC("fexit/XXX") 100 100 int BPF_PROG(fexit_XXX) 101 101 { 102 - struct bpf_perf_event_value___local readings[MAX_NUM_MATRICS]; 102 + struct bpf_perf_event_value___local readings[MAX_NUM_METRICS]; 103 103 u32 cpu = bpf_get_smp_processor_id(); 104 104 u32 i, zero = 0; 105 105 int err; 106 106 u64 *count; 107 107 108 108 /* read all events before updating the maps, to reduce error */ 109 - for (i = 0; i < num_metric && i < MAX_NUM_MATRICS; i++) { 109 + for (i = 0; i < num_metric && i < MAX_NUM_METRICS; i++) { 110 110 err = bpf_perf_event_read_value(&events, cpu + i * num_cpu, 111 111 (void *)(readings + i), 112 112 sizeof(*readings)); ··· 116 116 count = bpf_map_lookup_elem(&counts, &zero); 117 117 if (count) { 118 118 *count += 1; 119 - for (i = 0; i < num_metric && i < MAX_NUM_MATRICS; i++) 119 + for (i = 0; i < num_metric && i < MAX_NUM_METRICS; i++) 120 120 fexit_update_maps(i, &readings[i]); 121 121 } 122 122 return 0;