{"action":"created","comment":{"url":"https://api.github.com/repos/iovisor/bcc/pulls/comments/53822339","id":53822339,"diff_hunk":"@@ -57,18 +57,25 @@ def signal_ignore(signal, frame):\n bpf_text = \"\"\"\n #include <uapi/linux/ptrace.h>\n \n-struct key_t {\n+#define MAP_SIZE 10000\n+\n+struct val_t {\n     u64 ip;\n+    u64 value;\n };\n-BPF_HASH(counts, struct key_t);\n+BPF_TABLE(\"array\", int, struct val_t, counts, MAP_SIZE);\n \n int trace_count(struct pt_regs *ctx) {\n     FILTER\n-    struct key_t key = {};\n-    u64 zero = 0, *val;\n-    key.ip = ctx->ip;\n-    val = counts.lookup_or_init(&key, &zero);\n-    (*val)++;\n+    struct val_t *val;\n+    u64 zero = 0;\n+    u32 key = ctx->ip % MAP_SIZE;","path":"tools/funccount.py","position":23,"original_position":23,"commit_id":"d6dc9b6214947a33df6744e62dd227b276cd57a3","original_commit_id":"d6dc9b6214947a33df6744e62dd227b276cd57a3","user":{"login":"4ast","id":12205493,"avatar_url":"https://avatars.githubusercontent.com/u/12205493?v=3","gravatar_id":"","url":"https://api.github.com/users/4ast","html_url":"https://github.com/4ast","followers_url":"https://api.github.com/users/4ast/followers","following_url":"https://api.github.com/users/4ast/following{/other_user}","gists_url":"https://api.github.com/users/4ast/gists{/gist_id}","starred_url":"https://api.github.com/users/4ast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4ast/subscriptions","organizations_url":"https://api.github.com/users/4ast/orgs","repos_url":"https://api.github.com/users/4ast/repos","events_url":"https://api.github.com/users/4ast/events{/privacy}","received_events_url":"https://api.github.com/users/4ast/received_events","type":"User","site_admin":false},"body":"probably not, but we're not trying to optimize hash distribution here. It's a workaround for crash.\r\nDoing extra math here will only make it slower.","created_at":"2016-02-23T18:11:20Z","updated_at":"2016-02-23T18:11:20Z","html_url":"https://github.com/iovisor/bcc/pull/415#discussion_r53822339","pull_request_url":"https://api.github.com/repos/iovisor/bcc/pulls/415","_links":{"self":{"href":"https://api.github.com/repos/iovisor/bcc/pulls/comments/53822339"},"html":{"href":"https://github.com/iovisor/bcc/pull/415#discussion_r53822339"},"pull_request":{"href":"https://api.github.com/repos/iovisor/bcc/pulls/415"}}},"pull_request":{"url":"https://api.github.com/repos/iovisor/bcc/pulls/415","id":60295836,"html_url":"https://github.com/iovisor/bcc/pull/415","diff_url":"https://github.com/iovisor/bcc/pull/415.diff","patch_url":"https://github.com/iovisor/bcc/pull/415.patch","issue_url":"https://api.github.com/repos/iovisor/bcc/issues/415","number":415,"state":"open","locked":false,"title":"funccount: use array map instead of hash","user":{"login":"4ast","id":12205493,"avatar_url":"https://avatars.githubusercontent.com/u/12205493?v=3","gravatar_id":"","url":"https://api.github.com/users/4ast","html_url":"https://github.com/4ast","followers_url":"https://api.github.com/users/4ast/followers","following_url":"https://api.github.com/users/4ast/following{/other_user}","gists_url":"https://api.github.com/users/4ast/gists{/gist_id}","starred_url":"https://api.github.com/users/4ast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4ast/subscriptions","organizations_url":"https://api.github.com/users/4ast/orgs","repos_url":"https://api.github.com/users/4ast/repos","events_url":"https://api.github.com/users/4ast/events{/privacy}","received_events_url":"https://api.github.com/users/4ast/received_events","type":"User","site_admin":false},"body":"hash map is not safe when used in recursive context.\r\nIf kprobes are placed in the middle of memory allocator functions,\r\nthe recursive call of bpf_prog->map_update->kmalloc may crash.\r\nExample: funccount '*spin*' may dead lock the cpu.\r\nInstead use array map as a hash table.\r\nAfter the fix it works fine:\r\n$ sudo ./funccount.py '*spin*'\r\nTracing 33 functions for \"*spin*\"... Hit Ctrl-C to end.\r\n^C\r\nADDR             FUNC                          COUNT\r\nffffffff818dc121 _raw_spin_unlock_bh             779\r\nffffffff818dc461 _raw_spin_lock_bh              1359\r\nffffffff810990a1 mutex_spin_on_owner           11510\r\nffffffff818dc3f1 _raw_spin_trylock             14687\r\nffffffff810990f1 mutex_optimistic_spin         28618\r\nffffffff818dc2a1 _raw_spin_lock_irq            57933\r\nffffffff818dc211 _raw_spin_lock_irqsave       337914\r\nffffffff818dc0a1 __lock_text_start            360507\r\nffffffff818dc431 _raw_spin_lock               729764\r\nDetaching...\r\n\r\nSigned-off-by: Alexei Starovoitov <ast@fb.com>","created_at":"2016-02-23T06:50:38Z","updated_at":"2016-02-23T18:11:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5fbca455d738ba620c88d8e2bc1ce63102a9a3e2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/iovisor/bcc/pulls/415/commits","review_comments_url":"https://api.github.com/repos/iovisor/bcc/pulls/415/comments","review_comment_url":"https://api.github.com/repos/iovisor/bcc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iovisor/bcc/issues/415/comments","statuses_url":"https://api.github.com/repos/iovisor/bcc/statuses/d6dc9b6214947a33df6744e62dd227b276cd57a3","head":{"label":"iovisor:ast_dev","ref":"ast_dev","sha":"d6dc9b6214947a33df6744e62dd227b276cd57a3","user":{"login":"iovisor","id":12766186,"avatar_url":"https://avatars.githubusercontent.com/u/12766186?v=3","gravatar_id":"","url":"https://api.github.com/users/iovisor","html_url":"https://github.com/iovisor","followers_url":"https://api.github.com/users/iovisor/followers","following_url":"https://api.github.com/users/iovisor/following{/other_user}","gists_url":"https://api.github.com/users/iovisor/gists{/gist_id}","starred_url":"https://api.github.com/users/iovisor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iovisor/subscriptions","organizations_url":"https://api.github.com/users/iovisor/orgs","repos_url":"https://api.github.com/users/iovisor/repos","events_url":"https://api.github.com/users/iovisor/events{/privacy}","received_events_url":"https://api.github.com/users/iovisor/received_events","type":"Organization","site_admin":false},"repo":{"id":34921116,"name":"bcc","full_name":"iovisor/bcc","owner":{"login":"iovisor","id":12766186,"avatar_url":"https://avatars.githubusercontent.com/u/12766186?v=3","gravatar_id":"","url":"https://api.github.com/users/iovisor","html_url":"https://github.com/iovisor","followers_url":"https://api.github.com/users/iovisor/followers","following_url":"https://api.github.com/users/iovisor/following{/other_user}","gists_url":"https://api.github.com/users/iovisor/gists{/gist_id}","starred_url":"https://api.github.com/users/iovisor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iovisor/subscriptions","organizations_url":"https://api.github.com/users/iovisor/orgs","repos_url":"https://api.github.com/users/iovisor/repos","events_url":"https://api.github.com/users/iovisor/events{/privacy}","received_events_url":"https://api.github.com/users/iovisor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/iovisor/bcc","description":"BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more","fork":false,"url":"https://api.github.com/repos/iovisor/bcc","forks_url":"https://api.github.com/repos/iovisor/bcc/forks","keys_url":"https://api.github.com/repos/iovisor/bcc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iovisor/bcc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iovisor/bcc/teams","hooks_url":"https://api.github.com/repos/iovisor/bcc/hooks","issue_events_url":"https://api.github.com/repos/iovisor/bcc/issues/events{/number}","events_url":"https://api.github.com/repos/iovisor/bcc/events","assignees_url":"https://api.github.com/repos/iovisor/bcc/assignees{/user}","branches_url":"https://api.github.com/repos/iovisor/bcc/branches{/branch}","tags_url":"https://api.github.com/repos/iovisor/bcc/tags","blobs_url":"https://api.github.com/repos/iovisor/bcc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iovisor/bcc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iovisor/bcc/git/refs{/sha}","trees_url":"https://api.github.com/repos/iovisor/bcc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iovisor/bcc/statuses/{sha}","languages_url":"https://api.github.com/repos/iovisor/bcc/languages","stargazers_url":"https://api.github.com/repos/iovisor/bcc/stargazers","contributors_url":"https://api.github.com/repos/iovisor/bcc/contributors","subscribers_url":"https://api.github.com/repos/iovisor/bcc/subscribers","subscription_url":"https://api.github.com/repos/iovisor/bcc/subscription","commits_url":"https://api.github.com/repos/iovisor/bcc/commits{/sha}","git_commits_url":"https://api.github.com/repos/iovisor/bcc/git/commits{/sha}","comments_url":"https://api.github.com/repos/iovisor/bcc/comments{/number}","issue_comment_url":"https://api.github.com/repos/iovisor/bcc/issues/comments{/number}","contents_url":"https://api.github.com/repos/iovisor/bcc/contents/{+path}","compare_url":"https://api.github.com/repos/iovisor/bcc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iovisor/bcc/merges","archive_url":"https://api.github.com/repos/iovisor/bcc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iovisor/bcc/downloads","issues_url":"https://api.github.com/repos/iovisor/bcc/issues{/number}","pulls_url":"https://api.github.com/repos/iovisor/bcc/pulls{/number}","milestones_url":"https://api.github.com/repos/iovisor/bcc/milestones{/number}","notifications_url":"https://api.github.com/repos/iovisor/bcc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iovisor/bcc/labels{/name}","releases_url":"https://api.github.com/repos/iovisor/bcc/releases{/id}","deployments_url":"https://api.github.com/repos/iovisor/bcc/deployments","created_at":"2015-05-01T19:52:32Z","updated_at":"2016-02-21T21:52:07Z","pushed_at":"2016-02-23T06:50:38Z","git_url":"git://github.com/iovisor/bcc.git","ssh_url":"git@github.com:iovisor/bcc.git","clone_url":"https://github.com/iovisor/bcc.git","svn_url":"https://github.com/iovisor/bcc","homepage":"","size":1965,"stargazers_count":374,"watchers_count":374,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":59,"mirror_url":null,"open_issues_count":44,"forks":59,"open_issues":44,"watchers":374,"default_branch":"master"}},"base":{"label":"iovisor:master","ref":"master","sha":"d1a0e7f2c1c3c6c20712e9c2d23304ce2eccf01b","user":{"login":"iovisor","id":12766186,"avatar_url":"https://avatars.githubusercontent.com/u/12766186?v=3","gravatar_id":"","url":"https://api.github.com/users/iovisor","html_url":"https://github.com/iovisor","followers_url":"https://api.github.com/users/iovisor/followers","following_url":"https://api.github.com/users/iovisor/following{/other_user}","gists_url":"https://api.github.com/users/iovisor/gists{/gist_id}","starred_url":"https://api.github.com/users/iovisor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iovisor/subscriptions","organizations_url":"https://api.github.com/users/iovisor/orgs","repos_url":"https://api.github.com/users/iovisor/repos","events_url":"https://api.github.com/users/iovisor/events{/privacy}","received_events_url":"https://api.github.com/users/iovisor/received_events","type":"Organization","site_admin":false},"repo":{"id":34921116,"name":"bcc","full_name":"iovisor/bcc","owner":{"login":"iovisor","id":12766186,"avatar_url":"https://avatars.githubusercontent.com/u/12766186?v=3","gravatar_id":"","url":"https://api.github.com/users/iovisor","html_url":"https://github.com/iovisor","followers_url":"https://api.github.com/users/iovisor/followers","following_url":"https://api.github.com/users/iovisor/following{/other_user}","gists_url":"https://api.github.com/users/iovisor/gists{/gist_id}","starred_url":"https://api.github.com/users/iovisor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iovisor/subscriptions","organizations_url":"https://api.github.com/users/iovisor/orgs","repos_url":"https://api.github.com/users/iovisor/repos","events_url":"https://api.github.com/users/iovisor/events{/privacy}","received_events_url":"https://api.github.com/users/iovisor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/iovisor/bcc","description":"BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more","fork":false,"url":"https://api.github.com/repos/iovisor/bcc","forks_url":"https://api.github.com/repos/iovisor/bcc/forks","keys_url":"https://api.github.com/repos/iovisor/bcc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iovisor/bcc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iovisor/bcc/teams","hooks_url":"https://api.github.com/repos/iovisor/bcc/hooks","issue_events_url":"https://api.github.com/repos/iovisor/bcc/issues/events{/number}","events_url":"https://api.github.com/repos/iovisor/bcc/events","assignees_url":"https://api.github.com/repos/iovisor/bcc/assignees{/user}","branches_url":"https://api.github.com/repos/iovisor/bcc/branches{/branch}","tags_url":"https://api.github.com/repos/iovisor/bcc/tags","blobs_url":"https://api.github.com/repos/iovisor/bcc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iovisor/bcc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iovisor/bcc/git/refs{/sha}","trees_url":"https://api.github.com/repos/iovisor/bcc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iovisor/bcc/statuses/{sha}","languages_url":"https://api.github.com/repos/iovisor/bcc/languages","stargazers_url":"https://api.github.com/repos/iovisor/bcc/stargazers","contributors_url":"https://api.github.com/repos/iovisor/bcc/contributors","subscribers_url":"https://api.github.com/repos/iovisor/bcc/subscribers","subscription_url":"https://api.github.com/repos/iovisor/bcc/subscription","commits_url":"https://api.github.com/repos/iovisor/bcc/commits{/sha}","git_commits_url":"https://api.github.com/repos/iovisor/bcc/git/commits{/sha}","comments_url":"https://api.github.com/repos/iovisor/bcc/comments{/number}","issue_comment_url":"https://api.github.com/repos/iovisor/bcc/issues/comments{/number}","contents_url":"https://api.github.com/repos/iovisor/bcc/contents/{+path}","compare_url":"https://api.github.com/repos/iovisor/bcc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iovisor/bcc/merges","archive_url":"https://api.github.com/repos/iovisor/bcc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iovisor/bcc/downloads","issues_url":"https://api.github.com/repos/iovisor/bcc/issues{/number}","pulls_url":"https://api.github.com/repos/iovisor/bcc/pulls{/number}","milestones_url":"https://api.github.com/repos/iovisor/bcc/milestones{/number}","notifications_url":"https://api.github.com/repos/iovisor/bcc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iovisor/bcc/labels{/name}","releases_url":"https://api.github.com/repos/iovisor/bcc/releases{/id}","deployments_url":"https://api.github.com/repos/iovisor/bcc/deployments","created_at":"2015-05-01T19:52:32Z","updated_at":"2016-02-21T21:52:07Z","pushed_at":"2016-02-23T06:50:38Z","git_url":"git://github.com/iovisor/bcc.git","ssh_url":"git@github.com:iovisor/bcc.git","clone_url":"https://github.com/iovisor/bcc.git","svn_url":"https://github.com/iovisor/bcc","homepage":"","size":1965,"stargazers_count":374,"watchers_count":374,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":59,"mirror_url":null,"open_issues_count":44,"forks":59,"open_issues":44,"watchers":374,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/iovisor/bcc/pulls/415"},"html":{"href":"https://github.com/iovisor/bcc/pull/415"},"issue":{"href":"https://api.github.com/repos/iovisor/bcc/issues/415"},"comments":{"href":"https://api.github.com/repos/iovisor/bcc/issues/415/comments"},"review_comments":{"href":"https://api.github.com/repos/iovisor/bcc/pulls/415/comments"},"review_comment":{"href":"https://api.github.com/repos/iovisor/bcc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iovisor/bcc/pulls/415/commits"},"statuses":{"href":"https://api.github.com/repos/iovisor/bcc/statuses/d6dc9b6214947a33df6744e62dd227b276cd57a3"}}}}