perf lock contention: Update default map size to 16384
[platform/kernel/linux-starfive.git] / tools / perf / util / bpf_skel / lock_contention.bpf.c
index ed91609..f9d2d79 100644 (file)
@@ -7,9 +7,6 @@
 
 #include "lock_data.h"
 
-/* default buffer size */
-#define MAX_ENTRIES  10240
-
 /* for collect_lock_syms().  4096 was rejected by the verifier */
 #define MAX_CPUS  1024
 
@@ -63,7 +60,7 @@ struct {
        __uint(type, BPF_MAP_TYPE_HASH);
        __uint(key_size, sizeof(__u64));
        __uint(value_size, sizeof(__u32));
-       __uint(max_entries, 16384);
+       __uint(max_entries, MAX_ENTRIES);
 } lock_syms SEC(".maps");
 
 struct {
@@ -124,7 +121,9 @@ int lock_owner;
 int aggr_mode;
 
 /* error stat */
-int lost;
+int task_fail;
+int stack_fail;
+int time_fail;
 
 static inline int can_record(u64 *ctx)
 {
@@ -283,7 +282,7 @@ int contention_begin(u64 *ctx)
                bpf_map_update_elem(&tstamp, &pid, &zero, BPF_ANY);
                pelem = bpf_map_lookup_elem(&tstamp, &pid);
                if (pelem == NULL) {
-                       lost++;
+                       __sync_fetch_and_add(&task_fail, 1);
                        return 0;
                }
        }
@@ -296,7 +295,7 @@ int contention_begin(u64 *ctx)
                pelem->stack_id = bpf_get_stackid(ctx, &stacks,
                                                  BPF_F_FAST_STACK_CMP | stack_skip);
                if (pelem->stack_id < 0)
-                       lost++;
+                       __sync_fetch_and_add(&stack_fail, 1);
        } else if (aggr_mode == LOCK_AGGR_TASK) {
                struct task_struct *task;
 
@@ -340,6 +339,11 @@ int contention_end(u64 *ctx)
                return 0;
 
        duration = bpf_ktime_get_ns() - pelem->timestamp;
+       if ((__s64)duration < 0) {
+               bpf_map_delete_elem(&tstamp, &pid);
+               __sync_fetch_and_add(&time_fail, 1);
+               return 0;
+       }
 
        switch (aggr_mode) {
        case LOCK_AGGR_CALLER: