{"action":"created","issue":{"url":"https://api.github.com/repos/iovisor/bcc/issues/1300","repository_url":"https://api.github.com/repos/iovisor/bcc","labels_url":"https://api.github.com/repos/iovisor/bcc/issues/1300/labels{/name}","comments_url":"https://api.github.com/repos/iovisor/bcc/issues/1300/comments","events_url":"https://api.github.com/repos/iovisor/bcc/issues/1300/events","html_url":"https://github.com/iovisor/bcc/issues/1300","id":251365467,"number":1300,"title":"Question about why trace point inserting fails","user":{"login":"yncxcw","id":7780675,"avatar_url":"https://avatars3.githubusercontent.com/u/7780675?v=4","gravatar_id":"","url":"https://api.github.com/users/yncxcw","html_url":"https://github.com/yncxcw","followers_url":"https://api.github.com/users/yncxcw/followers","following_url":"https://api.github.com/users/yncxcw/following{/other_user}","gists_url":"https://api.github.com/users/yncxcw/gists{/gist_id}","starred_url":"https://api.github.com/users/yncxcw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yncxcw/subscriptions","organizations_url":"https://api.github.com/users/yncxcw/orgs","repos_url":"https://api.github.com/users/yncxcw/repos","events_url":"https://api.github.com/users/yncxcw/events{/privacy}","received_events_url":"https://api.github.com/users/yncxcw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-18T21:40:28Z","updated_at":"2017-08-18T21:57:55Z","closed_at":null,"body":"hi, all\r\n\r\nThis is my questions about using bcc to trace some kernel functions, here is my script:\r\n\r\n`from __future__ import print_function\r\nfrom bcc import BPF\r\nimport time\r\n\r\n\r\nbpf_text=\"\"\"\r\n#include <uapi/linux/ptrace.h>\r\n#include <linux/blkdev.h>\r\n#include <linux/mmzone.h>\r\n\r\n\r\nint kprobe__balance_pgdat(struct pt_regs* ctx)\r\n{\r\n    bpf_trace_printk(\"node\");\r\n    return 0;\r\n}\r\n\"\"\"\r\n\r\nb=BPF(text=bpf_text)\r\n\r\nprint(\"Tracing... Hit Ctrl-C to end.\")\r\n\r\nwhile 1:\r\n    # Read message from kernel pipe\r\n    try:\r\n        (task,pid,cpu,flags,ts,msg)=b.trac_fields()\r\n        (_tag,node_id)=msg.split(\" \")\r\n    except KeyboardInterrupt:\r\n        print(\"over\")\r\n        break`\r\n\r\nI want to trace kernel function balance_pgdat, but fails with following errors:\r\n`\r\n raceback (most recent call last):\r\n  File \"balance_pgdat.py\", line 19, in <module>\r\n    b=BPF(text=bpf_text)\r\n  File \"/usr/lib/python2.7/dist-packages/bcc/__init__.py\", line 302, in __init__\r\n    self._trace_autoload()\r\n  File \"/usr/lib/python2.7/dist-packages/bcc/__init__.py\", line 914, in _trace_autoload\r\n    self.attach_kprobe(event=fn.name[8:], fn_name=fn.name)\r\n  File \"/usr/lib/python2.7/dist-packages/bcc/__init__.py\", line 522, in attach_kprobe\r\n    raise Exception(\"Failed to attach BPF to kprobe\")\r\nException: Failed to attach BPF to kprobe\r\n `\r\n\r\nThen I also tried kpeob like this: kprobe \"p:balance_pgdat\"\r\n`\r\nERROR: func balance_pgdat not in /sys/kernel/debug/tracing/available_filter_functions.\r\nEither it doesn't exist, or, it might be unsafe to kprobe. Exiting. Use -F to override\r\nand get:\r\n`\r\n\r\nI have cheked balance_pgdat is not in  /sys/kernel/debug/tracing/available_filter_functions, but defined here: http://elixir.free-electrons.com/linux/latest/source/mm/vmscan.c#L3237\r\n\r\nSo I am wondering if bcc/kprobe can only work for part of the kernel functions or I have some mis-configurations. But after I installed bcc, I tried my its examples, it truely worked.\r\n\r\nAppreciate for anyone's help\r\n\r\nWei\r\n\r\n\r\n\r\n\r\n                                                                                                                     "},"comment":{"url":"https://api.github.com/repos/iovisor/bcc/issues/comments/323469982","html_url":"https://github.com/iovisor/bcc/issues/1300#issuecomment-323469982","issue_url":"https://api.github.com/repos/iovisor/bcc/issues/1300","id":323469982,"user":{"login":"drzaeus77","id":3770556,"avatar_url":"https://avatars2.githubusercontent.com/u/3770556?v=4","gravatar_id":"","url":"https://api.github.com/users/drzaeus77","html_url":"https://github.com/drzaeus77","followers_url":"https://api.github.com/users/drzaeus77/followers","following_url":"https://api.github.com/users/drzaeus77/following{/other_user}","gists_url":"https://api.github.com/users/drzaeus77/gists{/gist_id}","starred_url":"https://api.github.com/users/drzaeus77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drzaeus77/subscriptions","organizations_url":"https://api.github.com/users/drzaeus77/orgs","repos_url":"https://api.github.com/users/drzaeus77/repos","events_url":"https://api.github.com/users/drzaeus77/events{/privacy}","received_events_url":"https://api.github.com/users/drzaeus77/received_events","type":"User","site_admin":false},"created_at":"2017-08-18T21:57:55Z","updated_at":"2017-08-18T21:57:55Z","body":"Likely `balance_pgdat` is inlined by the compiler, which would make it difficult to trace. Why not use a tracepoint instead. For instance, I see that `trace_mm_vmscan_kswapd_wake` is right before to the call to `balance_pgdat` in `kswapd`.\r\n\r\nFor examples, look for usage of `TRACEPOINT_PROBE` in tools/* or see the [reference_guide](https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md#3-tracepoints)"}}
{"actor":{"display_login":"drzaeus77"}}