builtin-lock.c (cc2367eebb0c3c5501cddd5823e5feda7b57f706) builtin-lock.c (eca949b2b4addd941d369d4c2014b87f3c3e203b)
1// SPDX-License-Identifier: GPL-2.0
2#include <errno.h>
3#include <inttypes.h>
4#include "builtin.h"
5#include "perf.h"
6
7#include "util/evlist.h" // for struct evsel_str_handler
8#include "util/evsel.h"
9#include "util/symbol.h"
10#include "util/thread.h"
11#include "util/header.h"
12#include "util/target.h"
13#include "util/callchain.h"
14#include "util/lock-contention.h"
1// SPDX-License-Identifier: GPL-2.0
2#include <errno.h>
3#include <inttypes.h>
4#include "builtin.h"
5#include "perf.h"
6
7#include "util/evlist.h" // for struct evsel_str_handler
8#include "util/evsel.h"
9#include "util/symbol.h"
10#include "util/thread.h"
11#include "util/header.h"
12#include "util/target.h"
13#include "util/callchain.h"
14#include "util/lock-contention.h"
15#include "util/bpf_skel/lock_data.h"
15
16#include <subcmd/pager.h>
17#include <subcmd/parse-options.h>
18#include "util/trace-event.h"
19#include "util/tracepoint.h"
20
21#include "util/debug.h"
22#include "util/session.h"

--- 33 unchanged lines hidden (view full) ---

56static bool combine_locks;
57static bool show_thread_stats;
58static bool use_bpf;
59static unsigned long bpf_map_entries = 10240;
60static int max_stack_depth = CONTENTION_STACK_DEPTH;
61static int stack_skip = CONTENTION_STACK_SKIP;
62static int print_nr_entries = INT_MAX / 2;
63
16
17#include <subcmd/pager.h>
18#include <subcmd/parse-options.h>
19#include "util/trace-event.h"
20#include "util/tracepoint.h"
21
22#include "util/debug.h"
23#include "util/session.h"

--- 33 unchanged lines hidden (view full) ---

57static bool combine_locks;
58static bool show_thread_stats;
59static bool use_bpf;
60static unsigned long bpf_map_entries = 10240;
61static int max_stack_depth = CONTENTION_STACK_DEPTH;
62static int stack_skip = CONTENTION_STACK_SKIP;
63static int print_nr_entries = INT_MAX / 2;
64
64static enum {
65 LOCK_AGGR_ADDR,
66 LOCK_AGGR_TASK,
67 LOCK_AGGR_CALLER,
68} aggr_mode = LOCK_AGGR_ADDR;
65static enum lock_aggr_mode aggr_mode = LOCK_AGGR_ADDR;
69
70static struct thread_stat *thread_stat_find(u32 tid)
71{
72 struct rb_node *node;
73 struct thread_stat *st;
74
75 node = thread_stats.rb_node;
76 while (node) {

--- 1537 unchanged lines hidden (view full) ---

1614 .force = force,
1615 };
1616 struct lock_contention con = {
1617 .target = &target,
1618 .result = &lockhash_table[0],
1619 .map_nr_entries = bpf_map_entries,
1620 .max_stack = max_stack_depth,
1621 .stack_skip = stack_skip,
66
67static struct thread_stat *thread_stat_find(u32 tid)
68{
69 struct rb_node *node;
70 struct thread_stat *st;
71
72 node = thread_stats.rb_node;
73 while (node) {

--- 1537 unchanged lines hidden (view full) ---

1611 .force = force,
1612 };
1613 struct lock_contention con = {
1614 .target = &target,
1615 .result = &lockhash_table[0],
1616 .map_nr_entries = bpf_map_entries,
1617 .max_stack = max_stack_depth,
1618 .stack_skip = stack_skip,
1619 .aggr_mode = show_thread_stats ? LOCK_AGGR_TASK : LOCK_AGGR_CALLER,
1622 };
1623
1624 session = perf_session__new(use_bpf ? NULL : &data, &eops);
1625 if (IS_ERR(session)) {
1626 pr_err("Initializing perf session failed\n");
1627 return PTR_ERR(session);
1628 }
1629

--- 56 unchanged lines hidden (view full) ---

1686 }
1687
1688 if (setup_output_field(true, output_fields))
1689 goto out_delete;
1690
1691 if (select_key(true))
1692 goto out_delete;
1693
1620 };
1621
1622 session = perf_session__new(use_bpf ? NULL : &data, &eops);
1623 if (IS_ERR(session)) {
1624 pr_err("Initializing perf session failed\n");
1625 return PTR_ERR(session);
1626 }
1627

--- 56 unchanged lines hidden (view full) ---

1684 }
1685
1686 if (setup_output_field(true, output_fields))
1687 goto out_delete;
1688
1689 if (select_key(true))
1690 goto out_delete;
1691
1694 if (show_thread_stats)
1695 aggr_mode = LOCK_AGGR_TASK;
1696 else
1697 aggr_mode = LOCK_AGGR_CALLER;
1698
1699 if (use_bpf) {
1700 lock_contention_start();
1701 if (argc)
1702 evlist__start_workload(con.evlist);
1703
1704 /* wait for signal */
1705 pause();
1706

--- 286 unchanged lines hidden ---
1692 if (use_bpf) {
1693 lock_contention_start();
1694 if (argc)
1695 evlist__start_workload(con.evlist);
1696
1697 /* wait for signal */
1698 pause();
1699

--- 286 unchanged lines hidden ---