{"id":260029,"date":"2015-06-24T14:40:03","date_gmt":"2015-06-24T10:40:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=260029"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=260029","title":{"rendered":"\u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Linux"},"content":{"rendered":"<p>     \t\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043f\u0430\u0440\u0443 \u043b\u0435\u0442 \u044f&nbsp;\u043f\u0438\u0448\u0443 \u043f\u043e\u0434 \u044f\u0434\u0440\u043e Linux \u0438&nbsp;\u0447\u0430\u0441\u0442\u043e \u0432\u0438\u0436\u0443, \u043a\u0430\u043a \u043b\u044e\u0434\u0438 \u0441\u0442\u0440\u0430\u0434\u0430\u044e\u0442 \u043e\u0442&nbsp;\u043d\u0435\u0437\u043d\u0430\u043d\u0438\u044f \u0434\u0430\u0432\u043d\u0438\u0448\u043d\u0438\u0445, \u043e\u0431\u0449\u0435\u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0438&nbsp;(\u043f\u043e\u0447\u0442\u0438) \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <nobr>\u043a\u0430\u043a-\u0442\u043e<\/nobr> \u0440\u0430\u0437 \u043c\u044b&nbsp;\u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u043b\u0438 \u0441\u0435\u0442\u044c \u043d\u0430 <a href=\"http:\/\/metrotek.spb.ru\/ethond.html\">\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0435\u0438\u043d\u043a\u0430\u0440\u043d\u0430\u0446\u0438\u0438<\/a> <a href=\"http:\/\/metrotek.spb.ru\/b3et.html\">\u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u0431\u043e\u0440\u0430<\/a> \u0438&nbsp;\u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0437\u0430&nbsp;\u0447\u0443\u0434\u0435\u0441\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0441&nbsp;\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u041f\u0435\u0440\u0432\u044b\u043c \u043d\u0430\u0448\u0438\u043c \u043f\u043e\u0437\u044b\u0432\u043e\u043c \u0431\u044b\u043b\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u044f\u0434\u0440\u0430 \u0438&nbsp;\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432&nbsp;\u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 <code>printk<\/code>, \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043b\u043e\u0433\u0438, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u0445&nbsp;<nobr>\u043a\u0430\u043a\u0438\u043c-\u043d\u0438\u0431\u0443\u0434\u044c<\/nobr> \u043f\u0438\u0442\u043e\u043d\u043e\u043c \u0438&nbsp;\u043f\u043e\u0442\u043e\u043c \u0434\u043e\u043b\u0433\u043e \u0434\u0443\u043c\u0430\u0442\u044c. \u041d\u043e&nbsp;\u043d\u0435&nbsp;\u0437\u0440\u044f \u044f&nbsp;\u0447\u0438\u0442\u0430\u043b <a href=\"http:\/\/lwn.net\">lwn.net<\/a>. \u042f&nbsp;\u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b, \u0447\u0442\u043e \u0432&nbsp;\u044f\u0434\u0440\u0435 \u0435\u0441\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0438&nbsp;\u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0438&nbsp;\u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f\u0434\u0440\u0430: \u0442\u0435&nbsp;\u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b, \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b&nbsp;\u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c <nobr>\u043a\u0430\u043a\u0438\u0435-\u0442\u043e<\/nobr> \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0438\u0437&nbsp;\u044f\u0434\u0440\u0430, \u0430&nbsp;\u0437\u0430\u0442\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412&nbsp;\u044f\u0434\u0440\u0435 Linux \u0442\u0430\u043a\u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 3:  <\/p>\n<ol>\n<li>tracepoints<\/li>\n<li>kprobes<\/li>\n<li>perf events<\/li>\n<\/ol>\n<p>  \u041d\u0430&nbsp;\u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u0438\u0445 3 \u0444\u0438\u0447 \u044f\u0434\u0440\u0430 \u0441\u0442\u0440\u043e\u044f\u0442\u0441\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0432\u0441\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0438 \u0438&nbsp;\u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0434\u043b\u044f Linux, \u0432&nbsp;\u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 <code>ftrace<\/code>, <code>perf<\/code>, <code>SystemTap<\/code>, <code>ktap<\/code> \u0438&nbsp;\u0434\u0440\u0443\u0433\u0438\u0435. \u0412&nbsp;\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f&nbsp;\u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u043e\u043d\u0438 (\u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b) \u0434\u0430\u044e\u0442, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u0430&nbsp;\u0432&nbsp;\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0430\u0437\u044b \u043c\u044b&nbsp;\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0443\u0436\u0435 \u043d\u0430&nbsp;\u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0442\u0443\u043b\u0437\u044b.<\/p>\n<h2>Kernel tracepoints<\/h2>\n<p>  Kernel tracepoints&nbsp;&mdash; \u044d\u0442\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u044f\u0434\u0440\u0430, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430. \u0414\u0430, \u0432\u044b&nbsp;\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043d\u044f\u043b\u0438, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0432\u0430\u0436\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u044f\u0434\u0440\u0430 (\u0441\u0435\u0442\u044c, \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a) \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043e. \u041d\u0430&nbsp;\u043c\u043e\u0451\u043c \u044f\u0434\u0440\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e tracepoint\u2019\u043e\u0432&nbsp;\u0442\u0430\u043a\u043e\u0435:  <\/p>\n<pre>[etn]$ perf list tracepointt | wc -l   1271<\/pre>\n<p>  \u0421\u0440\u0435\u0434\u0438 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c kmalloc:  <\/p>\n<pre>[etn]$ perf list tracepoint | grep &quot;kmalloc &quot;   kmem:kmalloc                                       [Tracepoint event]<\/pre>\n<p>  \u0410&nbsp;\u0432\u043e\u0442 \u0442\u0430\u043a \u043e\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430&nbsp;\u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432&nbsp;\u044f\u0434\u0435\u0440\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"http:\/\/lxr.free-electrons.com\/source\/mm\/slab.c?v=3.18#L3481\"><code>__do_kmalloc<\/code><\/a>:  <\/p>\n<pre><code>\/**  *  __do_kmalloc - allocate memory  *  @size: how many bytes of memory are required.  *  @flags: the type of memory to allocate (see kmalloc).  *  @caller: function caller for debug tracking of the caller  *\/ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,                                           unsigned long caller) {         struct kmem_cache *cachep;         void *ret;          cachep = kmalloc_slab(size, flags);         if (unlikely(ZERO_OR_NULL_PTR(cachep)))                 return cachep;         ret = slab_alloc(cachep, flags, caller);          trace_kmalloc(caller, ret,                       size, cachep-&gt;size, flags);          return ret; } <\/code><\/pre>\n<p>  <code>trace_kmalloc<\/code>&nbsp;&mdash; \u044d\u0442\u043e \u0438&nbsp;\u0435\u0441\u0442\u044c tracepoint.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u0435 tracepoint\u2019\u044b&nbsp;\u043f\u0438\u0448\u0443\u0442 \u0432\u044b\u0432\u043e\u0434 \u0432&nbsp;\u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u0439 \u0431\u0443\u0444\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432&nbsp;\/sys\/kernel\/debug\/tracing\/trace:  <\/p>\n<pre>[~]# mount -t debugfs none \/sys\/kernel\/debug [~]# cd \/sys\/kernel\/debug\/tracing\/ [tracing]# echo 1 &gt; events\/kmem\/kmalloc\/enable  [tracing]# tail trace bash-10921 [000] .... 1127940.937139: kmalloc: call_site=ffffffff8122f0f5 ptr=ffff8800aaecb900 bytes_req=48 bytes_alloc=64 gfp_flags=GFP_KERNEL bash-10921 [000] .... 1127940.937139: kmalloc: call_site=ffffffff8122f084 ptr=ffff8800ca008800 bytes_req=2048 bytes_alloc=2048 gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_NORETRY bash-10921 [000] .... 1127940.937139: kmalloc: call_site=ffffffff8122f084 ptr=ffff8800aaecbd80 bytes_req=64 bytes_alloc=64 gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_NORETRY tail-11005 [001] .... 1127940.937451: kmalloc: call_site=ffffffff81219297 ptr=ffff8800aecf5f00 bytes_req=240 bytes_alloc=256 gfp_flags=GFP_KERNEL|GFP_ZERO tail-11005 [000] .... 1127940.937518: kmalloc: call_site=ffffffff81267801 ptr=ffff880123e8bd80 bytes_req=128 bytes_alloc=128 gfp_flags=GFP_KERNEL tail-11005 [000] .... 1127940.937519: kmalloc: call_site=ffffffff81267786 ptr=ffff880077faca00 bytes_req=504 bytes_alloc=512 gfp_flags=GFP_KERNEL<\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e tra\u0441epoint \u00abkmem:kmalloc\u00bb, \u043a\u0430\u043a \u0438&nbsp;\u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435, \u043f\u043e&nbsp;\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d, \u0442\u0430\u043a \u0447\u0442\u043e \u0435\u0433\u043e \u043d\u0430\u0434\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c, \u0441\u043a\u0430\u0437\u0430\u0432 1 \u0432&nbsp;\u0435\u0433\u043e <code>enable<\/code> \u0444\u0430\u0439\u043b.<\/p>\n<p>  \u0412\u044b&nbsp;\u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0430\u043c\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c tracepoint \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u044f\u0434\u0440\u0430. \u041d\u043e, <nobr>\u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445<\/nobr>, \u044d\u0442\u043e \u043d\u0435&nbsp;\u0442\u0430\u043a \u0443\u0436&nbsp;\u0438&nbsp;\u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e tracepoint\u2019\u044b&nbsp;&mdash; \u043d\u0435&nbsp;\u0441\u0430\u043c\u044b\u0439 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438&nbsp;\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 <acronym>API<\/acronym>: \u0441\u043c\u043e\u0442\u0440\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432&nbsp;<a href=\"http:\/\/lxr.free-electrons.com\/source\/samples\/trace_events\/?v=3.18\"><em>samples\/trace_events\/<\/em><\/a> (\u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0435 \u044d\u0442\u0438 tracepoint\u2019\u044b&nbsp;&mdash; \u044d\u0442\u043e \u0447\u0451\u0440\u043d\u0430\u044f \u043c\u0430\u0433\u0438\u044f <nobr>C-\u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432<\/nobr>, \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u043b\u0438 \u0438&nbsp;\u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0442\u043e&nbsp;\u043d\u0435&nbsp;\u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f). \u0410&nbsp;<nobr>\u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445<\/nobr>, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043e\u043d\u0438 \u043d\u0435&nbsp;\u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432&nbsp;\u0432\u0430\u0448\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0435, \u043f\u043e\u043a\u0443\u0434\u0430 \u0443&nbsp;\u0432\u0430\u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d <code>CONFIG_MODULE_SIG<\/code> (\u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0430) \u0438&nbsp;\u043d\u0435\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0438 (\u043e\u043d&nbsp;\u0443&nbsp;\u0432\u0435\u043d\u0434\u043e\u0440\u0430 \u044f\u0434\u0440\u0430 \u0432\u0430\u0448\u0435\u0433\u043e \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u0430). \u0421\u043c\u043e\u0442\u0440\u0438 \u0434\u0443\u0448\u0435\u0440\u0430\u0437\u0434\u0438\u0440\u0430\u044e\u0449\u0438\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0432&nbsp;lkml <a href=\"https:\/\/lkml.org\/lkml\/2014\/2\/13\/488\">[1]<\/a>, <a href=\"https:\/\/lkml.org\/lkml\/2014\/3\/4\/925\">[2]<\/a>.<\/p>\n<p>  \u041a\u043e\u0440\u043e\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, tracepoint\u2019\u044b&nbsp;\u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438&nbsp;\u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u0430\u044f \u0432\u0435\u0449\u044c, \u043d\u043e&nbsp;\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0435\u0439&nbsp;\u0440\u0443\u043a\u0430\u043c\u0438 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u0438&nbsp;\u043d\u0435&nbsp;\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f&nbsp;&mdash; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>ftrace<\/code> \u0438\u043b\u0438 <code>perf<\/code>.<\/p>\n<h2>kprobes<\/h2>\n<p>  \u0415\u0441\u043b\u0438 tracepoint\u2019\u044b&nbsp;&mdash; \u044d\u0442\u043e \u043c\u0435\u0442\u043a\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u043e&nbsp;<code>kprobes<\/code>&nbsp;&mdash; \u044d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430. \u0421&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e kprobes \u0432\u044b&nbsp;\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u044f\u0434\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432&nbsp;<em>\u043b\u044e\u0431\u043e\u043c<\/em> \u043c\u0435\u0441\u0442\u0435, \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432&nbsp;\u043d\u0451\u043c \u0447\u0442\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u0438&nbsp;\u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043a\u0430\u043a \u043d\u0438&nbsp;\u0432&nbsp;\u0447\u0451\u043c \u043d\u0438&nbsp;\u0431\u044b\u0432\u0430\u043b\u043e.<\/p>\n<p>  \u041a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f: \u0432\u044b&nbsp;\u043f\u0438\u0448\u0435\u0442\u0435 \u0441\u0432\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u044f\u0434\u0440\u0430, \u0432&nbsp;\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430&nbsp;\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u044f\u0434\u0440\u0430 (\u0447\u0438\u0442\u0430\u0439, \u0444\u0443\u043d\u043a\u0446\u0438\u044e) \u0438\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043b\u044e\u0431\u043e\u0439 \u0430\u0434\u0440\u0435\u0441.<\/p>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u0442\u043e \u0432\u0441\u0451 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<ul>\n<li>\u041c\u044b&nbsp;\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0432\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u044f\u0434\u0440\u0430, \u0432&nbsp;\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a.<\/li>\n<li>\u041c\u044b&nbsp;\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430&nbsp;\u043d\u0435\u043a\u0438\u0439 \u0430\u0434\u0440\u0435\u0441 A, \u0431\u0443\u0434\u044c \u0442\u043e&nbsp;\u043f\u0440\u043e\u0441\u0442\u043e \u0430\u0434\u0440\u0435\u0441 \u0438\u043b\u0438 <nobr>\u043a\u0430\u043a\u0430\u044f-\u043d\u0438\u0431\u0443\u0434\u044c<\/nobr> \u0444\u0443\u043d\u043a\u0446\u0438\u044f.<\/li>\n<li>\u041f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430 <em>kprobe<\/em> \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e&nbsp;\u0430\u0434\u0440\u0435\u0441\u0443, \u0410&nbsp;\u0438&nbsp;\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0438\u0445&nbsp;\u043d\u0430&nbsp;CPU trap (<code>int 3<\/code> \u0434\u043b\u044f x86).<\/li>\n<li>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0434\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043e&nbsp;\u0430\u0434\u0440\u0435\u0441\u0430 A, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043f\u043e&nbsp;\u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b, \u0430&nbsp;\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0438\u043c \u0432&nbsp;\u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f <em>kprobes<\/em>.<\/li>\n<li>\u041f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430 <em>kprobes<\/em> \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u043d\u0430&nbsp;\u0430\u0434\u0440\u0435\u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043d\u0430\u0445\u043e\u0434\u0438\u0442, \u043a\u0442\u043e \u0431\u044b\u043b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u043f\u043e&nbsp;\u0430\u0434\u0440\u0435\u0441\u0443, \u0410&nbsp;\u0438&nbsp;\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u0448 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a.<\/li>\n<li>\u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u0438&nbsp;\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/li>\n<\/ul>\n<p>  \u0412&nbsp;\u044f\u0434\u0440\u0435 \u0435\u0441\u0442\u044c 3 \u0432\u0438\u0434\u0430 kprobes:  <\/p>\n<ul>\n<li>kprobes&nbsp;&mdash; \u00ab\u0431\u0430\u0437\u043e\u0432\u0430\u044f\u00bb \u043f\u0440\u043e\u0431\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u044f\u0434\u0440\u0430.<\/li>\n<li>jprobes&nbsp;&mdash; jump probe, \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432&nbsp;\u043d\u0430\u0447\u0430\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u043e&nbsp;\u0437\u0430\u0442\u043e \u0434\u0430\u0451\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a&nbsp;\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u0422\u0430\u043a\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435&nbsp;\u0437\u0430&nbsp;\u0441\u0447\u0451\u0442 trap\u2019\u043e\u0432, \u0430&nbsp;\u0447\u0435\u0440\u0435\u0437 <code>setjmp\/longjmp<\/code> (\u043e\u0442\u0441\u044e\u0434\u0430 \u0438&nbsp;\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435), \u0442\u043e&nbsp;\u0435\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u0430.<\/li>\n<li>kretprobes&nbsp;&mdash; return probe, \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0445\u043e\u0434\u043e\u043c \u0438\u0437&nbsp;\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438&nbsp;\u0434\u0430\u0451\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a&nbsp;\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/li>\n<\/ul>\n<p>  \u0421&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e kprobes \u043c\u044b&nbsp;\u043c\u043e\u0436\u0435\u043c \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043a\u043e\u0434 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e miscdevice \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430. \u042f&nbsp;\u0445\u043e\u0447\u0443 \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e <nobr>\u043a\u0442\u043e-\u0442\u043e<\/nobr> \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0432&nbsp;\u043c\u043e\u0451 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u0437\u043d\u0430\u0442\u044c \u043f\u043e&nbsp;\u043a\u0430\u043a\u043e\u043c\u0443 \u043e\u0442\u0441\u0442\u0443\u043f\u0443 \u0438&nbsp;\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0439\u0442.<br \/>  \u0412&nbsp;\u043c\u043e\u0451\u043c miscdevice \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre>ssize_t etn_write(struct file *filp, const char __user *buf,            size_t count, loff_t *f_pos)<\/pre>\n<p>  \u042f&nbsp;\u043d\u0430\u043f\u0438\u0441\u0430\u043b <a href=\"https:\/\/gist.github.com\/dzeban\/a19c711d6b6b1d72e594\">\u043f\u0440\u043e\u0441\u0442\u043e\u0439 jprobe \u043c\u043e\u0434\u0443\u043b\u044c<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0438\u0448\u0435\u0442 \u0432&nbsp;\u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u043b\u043e\u0433 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 \u0438&nbsp;\u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435.  <\/p>\n<pre>root@etn:~# tail -F \/var\/log\/kern.log Jan  1 00:00:42 etn kernel: [   42.923717] ETN JPROBE: jprobe_init:46: Planted jprobe at bf00f7a8, handler addr bf071000 Jan  1 00:00:43 etn kernel: [   43.194840] ETN JPROBE: trace_etn_write:23: Writing 2 bytes at offset 4 Jan  1 00:00:43 etn kernel: [   43.201827] ETN JPROBE: trace_etn_write:23: Writing 2 bytes at offset 4<\/pre>\n<p>  \u041a\u043e\u0440\u043e\u0447\u0435, \u0432\u0435\u0449\u044c \u043c\u043e\u0449\u043d\u0430\u044f, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435&nbsp;\u0448\u0438\u0431\u043a\u043e \u0443\u0434\u043e\u0431\u043d\u043e: \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a&nbsp;\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u043d\u0435\u0442 (\u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u0441\u0442\u0443\u043f \u043e\u0442&nbsp;<code>ebp<\/code>), \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c \u044f\u0434\u0440\u0430, \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c <nobr>\u0438 \u0442. \u043f.<\/nobr> \u0415\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432&nbsp;<a href=\"http:\/\/lxr.free-electrons.com\/source\/samples\/kprobes\/?v=3.18\"><em>samples\/kprobes<\/em><\/a>. \u041d\u043e&nbsp;\u0437\u0430\u0447\u0435\u043c \u0432\u0441\u0451 \u044d\u0442\u043e, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c SystemTap?<\/p>\n<h2>Perf events<\/h2>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u043d\u0435&nbsp;\u043d\u0430\u0434\u043e \u043f\u0443\u0442\u0430\u0442\u044c \u00abperf events\u00bb \u0438&nbsp;\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 <code>perf<\/code>&nbsp;&mdash; \u043f\u0440\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u00abPerf events\u00bb&nbsp;&mdash; \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a&nbsp;\u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430\u043c \u0432&nbsp;PMU (Performance Monitoring Unit), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e CPU. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u0438\u043c \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c, \u0432\u044b&nbsp;\u043c\u043e\u0436\u0435\u0442\u0435 \u0441&nbsp;\u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u044f\u0434\u0440\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u043c\u0430\u0445\u043e\u0432 \u0432&nbsp;L1 \u043a\u0435\u0448\u0435, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442&nbsp;\u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u0430\u044f \u0443&nbsp;\u0432\u0430\u0441 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430, \u0431\u0443\u0434\u044c \u0442\u043e&nbsp;ARM \u0438\u043b\u0438 amd64. \u041f\u0440\u0430\u0432\u0434\u0430, \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0432&nbsp;\u044f\u0434\u0440\u0435:-) \u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e&nbsp;\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"http:\/\/web.eece.maine.edu\/~vweaver\/projects\/perf_events\/support.html\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  \u0414\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a&nbsp;\u044d\u0442\u0438\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430\u043c, \u0430&nbsp;\u0442\u0430\u043a\u0436\u0435 \u043a&nbsp;\u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0439 \u043a\u0443\u0447\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0434\u043e\u0431\u0440\u0430, \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 <code>perf<\/code>. \u0421&nbsp;\u0435\u0451 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0436\u0435\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b. <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f x86<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre>$ perf list pmu hw sw cache   branch-instructions OR cpu\/branch-instructions\/    [Kernel PMU event]   branch-misses OR cpu\/branch-misses\/                [Kernel PMU event]   bus-cycles OR cpu\/bus-cycles\/                      [Kernel PMU event]   cache-misses OR cpu\/cache-misses\/                  [Kernel PMU event]   cache-references OR cpu\/cache-references\/          [Kernel PMU event]   cpu-cycles OR cpu\/cpu-cycles\/                      [Kernel PMU event]   instructions OR cpu\/instructions\/                  [Kernel PMU event]     cpu-cycles OR cycles                               [Hardware event]   instructions                                       [Hardware event]   cache-references                                   [Hardware event]   cache-misses                                       [Hardware event]   branch-instructions OR branches                    [Hardware event]   branch-misses                                      [Hardware event]   bus-cycles                                         [Hardware event]   ref-cycles                                         [Hardware event]    cpu-clock                                          [Software event]   task-clock                                         [Software event]   page-faults OR faults                              [Software event]   context-switches OR cs                             [Software event]   cpu-migrations OR migrations                       [Software event]   minor-faults                                       [Software event]   major-faults                                       [Software event]   alignment-faults                                   [Software event]   emulation-faults                                   [Software event]   dummy                                              [Software event]    L1-dcache-loads                                    [Hardware cache event]   L1-dcache-load-misses                              [Hardware cache event]   L1-dcache-stores                                   [Hardware cache event]   L1-dcache-store-misses                             [Hardware cache event]   L1-dcache-prefetches                               [Hardware cache event]   L1-icache-loads                                    [Hardware cache event]   L1-icache-load-misses                              [Hardware cache event]   LLC-loads                                          [Hardware cache event]   LLC-load-misses                                    [Hardware cache event]   LLC-stores                                         [Hardware cache event]   LLC-store-misses                                   [Hardware cache event]   dTLB-loads                                         [Hardware cache event]   dTLB-load-misses                                   [Hardware cache event]   dTLB-stores                                        [Hardware cache event]   dTLB-store-misses                                  [Hardware cache event]   iTLB-loads                                         [Hardware cache event]   iTLB-load-misses                                   [Hardware cache event]   branch-loads                                       [Hardware cache event]   branch-load-misses                                 [Hardware cache event]<\/pre>\n<p>  <\/div>\n<\/div>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0410 \u0432\u043e\u0442 \u0447\u0442\u043e \u043d\u0430 ARM<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre>root@etn:~# perf list pmu hw sw cache    cpu-cycles OR cycles                               [Hardware event]   instructions                                       [Hardware event]   cache-references                                   [Hardware event]   cache-misses                                       [Hardware event]   branch-instructions OR branches                    [Hardware event]   branch-misses                                      [Hardware event]   stalled-cycles-frontend OR idle-cycles-frontend    [Hardware event]   stalled-cycles-backend OR idle-cycles-backend      [Hardware event]   ref-cycles                                         [Hardware event]    cpu-clock                                          [Software event]   task-clock                                         [Software event]   page-faults OR faults                              [Software event]   context-switches OR cs                             [Software event]   cpu-migrations OR migrations                       [Software event]   minor-faults                                       [Software event]   major-faults                                       [Software event]   alignment-faults                                   [Software event]   emulation-faults                                   [Software event]   dummy                                              [Software event]    L1-dcache-loads                                    [Hardware cache event]   L1-dcache-load-misses                              [Hardware cache event]   L1-dcache-stores                                   [Hardware cache event]   L1-dcache-store-misses                             [Hardware cache event]   L1-icache-load-misses                              [Hardware cache event]   dTLB-load-misses                                   [Hardware cache event]   dTLB-store-misses                                  [Hardware cache event]   iTLB-load-misses                                   [Hardware cache event]   branch-loads                                       [Hardware cache event]   branch-load-misses                                 [Hardware cache event]<\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e x86 \u043f\u043e\u0431\u043e\u0433\u0430\u0447\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430&nbsp;\u0442\u0430\u043a\u0438\u0435 \u0432\u0435\u0449\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a&nbsp;\u00abperf events\u00bb \u0431\u044b\u043b \u0441\u0434\u0435\u043b\u0430\u043d \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <a href=\"http:\/\/web.eece.maine.edu\/~vweaver\/projects\/perf_events\/perf_event_open.html\"><code>perf_event_open<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0432\u044b&nbsp;\u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0435 \u0441\u0430\u043c event \u0438&nbsp;\u043a\u043e\u043d\u0444\u0438\u0433, \u0432&nbsp;\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0432\u044b&nbsp;\u0445\u043e\u0442\u0438\u0442\u0435 \u0441&nbsp;\u044d\u0442\u0438\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c. \u0412&nbsp;\u043e\u0442\u0432\u0435\u0442 \u0432\u044b&nbsp;\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440, \u0438\u0437&nbsp;\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 <code>perf<\/code>\u2019\u043e\u043c&nbsp;\u043f\u043e&nbsp;\u0441\u043e\u0431\u044b\u0442\u0438\u044e.<\/p>\n<p>  \u041f\u043e\u0432\u0435\u0440\u0445 \u044d\u0442\u043e\u0433\u043e, <code>perf<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0438\u0447, \u0432\u0440\u043e\u0434\u0435 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438, \u0432\u044b\u0432\u043e\u0434\u0430 \u0432&nbsp;\u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b, \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u0439 \u0438&nbsp;\u043f\u0440.&nbsp;\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432&nbsp;<code>perf<\/code> \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u0438\u0445\u0430\u044e\u0442 \u0432\u0441\u0451, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e: \u043e\u0442&nbsp;tracepoint\u2019\u043e\u0432&nbsp;\u0434\u043e&nbsp;<a href=\"https:\/\/lwn.net\/Articles\/643139\/\">eBPF<\/a> \u0438&nbsp;\u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e&nbsp;\u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0435\u0441\u044c <code>ftrace<\/code> \u0445\u043e\u0442\u044f\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c\u044e <code>perf<\/code> <a href=\"http:\/\/thread.gmane.org\/gmane.linux.kernel\/1136520\">[3]<\/a> <a href=\"https:\/\/lkml.org\/lkml\/2013\/10\/16\/15\">[4]<\/a>.<\/p>\n<p>  \u041a\u043e\u0440\u043e\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u00abperf_events\u00bb \u0441\u0430\u043c\u0438 \u043f\u043e&nbsp;\u0441\u0435\u0431\u0435 \u043c\u0430\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b, \u0430&nbsp;\u0441\u0430\u043c <code>perf<\/code> \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0437\u0430\u0442\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u043a\u0430\u0436\u0443 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<p>  \u0413\u043e\u0432\u043e\u0440\u0438\u043c:  <\/p>\n<pre>root@etn:~# perf timechart record apt-get update ... root@etn:~# perf timechart -i perf.data -o timechart.svg<\/pre>\n<p>  \u0418&nbsp;\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0435 \u0447\u0443\u0434\u043e:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/339\/39e\/f84\/33939ef84fa44053a2c8ab5a20c3cd00.png\" alt=\"Perf timechart\"\/>Perf timechart<\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434<\/h2>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0437\u043d\u0430\u044f \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0443 \u0438&nbsp;\u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432&nbsp;\u044f\u0434\u0440\u0435, \u0432\u044b&nbsp;\u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c \u0441\u0435\u0431\u0435 \u0438&nbsp;\u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0430\u043c, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043a\u0430\u043a <code>ftrace<\/code>, <code>perf<\/code> \u0438&nbsp;<code>SystemTap<\/code>, \u043d\u043e&nbsp;\u043e\u0431&nbsp;\u044d\u0442\u043e\u043c \u0432&nbsp;\u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0430\u0437.<\/p>\n<h2>\u041f\u043e\u0447\u0438\u0442\u0430\u0442\u044c<\/h2>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/events.linuxfoundation.org\/sites\/events\/files\/slides\/kernel_profiling_debugging_tools_0.pdf\">https:\/\/events.linuxfoundation.org\/sites\/events\/files\/slides\/kernel_profiling_debugging_tools_0.pdf<\/a><\/li>\n<li><a href=\"http:\/\/events.linuxfoundation.org\/sites\/events\/files\/lcjp13_zannoni.pdf\">http:\/\/events.linuxfoundation.org\/sites\/events\/files\/lcjp13_zannoni.pdf<\/a><\/li>\n<li><em>tracepoints<\/em>:\n<ul>\n<li><a href=\"http:\/\/lxr.free-electrons.com\/source\/Documentation\/trace\/tracepoints.txt?v=3.13\">Documentation\/trace\/tracepoints.txt<\/a><\/li>\n<li><a href=\"http:\/\/lttng.org\/files\/thesis\/desnoyers-dissertation-2009-12-v27.pdf\">http:\/\/lttng.org\/files\/thesis\/desnoyers-dissertation-<nobr>2009-12-v27<\/nobr>.pdf<\/a><\/li>\n<li><a href=\"http:\/\/lwn.net\/Articles\/379903\/\">http:\/\/lwn.net\/Articles\/379903\/<\/a><\/li>\n<li><a href=\"http:\/\/lwn.net\/Articles\/381064\/\">http:\/\/lwn.net\/Articles\/381064\/<\/a><\/li>\n<li><a href=\"http:\/\/lwn.net\/Articles\/383362\/\">http:\/\/lwn.net\/Articles\/383362\/<\/a><\/li>\n<\/ul>\n<\/li>\n<li><em>kprobes<\/em>:\n<ul>\n<li><a href=\"http:\/\/lxr.free-electrons.com\/source\/Documentation\/kprobes.txt?v=3.13\">Documentation\/kprobes.txt<\/a><\/li>\n<li><a href=\"https:\/\/lwn.net\/Articles\/132196\/\">https:\/\/lwn.net\/Articles\/132196\/<\/a><\/li>\n<\/ul>\n<\/li>\n<li><em>perf_events<\/em>:\n<ul>\n<li><a href=\"http:\/\/web.eece.maine.edu\/~vweaver\/projects\/perf_events\/\">http:\/\/web.eece.maine.edu\/~vweaver\/projects\/perf_events\/<\/a><\/li>\n<li><a href=\"https:\/\/lwn.net\/Articles\/441209\/\">https:\/\/lwn.net\/Articles\/441209\/<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/261003\/\"> http:\/\/habrahabr.ru\/post\/261003\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043f\u0430\u0440\u0443 \u043b\u0435\u0442 \u044f&nbsp;\u043f\u0438\u0448\u0443 \u043f\u043e\u0434 \u044f\u0434\u0440\u043e Linux \u0438&nbsp;\u0447\u0430\u0441\u0442\u043e \u0432\u0438\u0436\u0443, \u043a\u0430\u043a \u043b\u044e\u0434\u0438 \u0441\u0442\u0440\u0430\u0434\u0430\u044e\u0442 \u043e\u0442&nbsp;\u043d\u0435\u0437\u043d\u0430\u043d\u0438\u044f \u0434\u0430\u0432\u043d\u0438\u0448\u043d\u0438\u0445, \u043e\u0431\u0449\u0435\u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0438&nbsp;(\u043f\u043e\u0447\u0442\u0438) \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <nobr>\u043a\u0430\u043a-\u0442\u043e<\/nobr> \u0440\u0430\u0437 \u043c\u044b&nbsp;\u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u043b\u0438 \u0441\u0435\u0442\u044c \u043d\u0430 <a href=\"http:\/\/metrotek.spb.ru\/ethond.html\">\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0435\u0438\u043d\u043a\u0430\u0440\u043d\u0430\u0446\u0438\u0438<\/a> <a href=\"http:\/\/metrotek.spb.ru\/b3et.html\">\u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u0431\u043e\u0440\u0430<\/a> \u0438&nbsp;\u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0437\u0430&nbsp;\u0447\u0443\u0434\u0435\u0441\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0441&nbsp;\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u041f\u0435\u0440\u0432\u044b\u043c \u043d\u0430\u0448\u0438\u043c \u043f\u043e\u0437\u044b\u0432\u043e\u043c \u0431\u044b\u043b\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u044f\u0434\u0440\u0430 \u0438&nbsp;\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432&nbsp;\u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 <code>printk<\/code>, \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043b\u043e\u0433\u0438, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u0445&nbsp;<nobr>\u043a\u0430\u043a\u0438\u043c-\u043d\u0438\u0431\u0443\u0434\u044c<\/nobr> \u043f\u0438\u0442\u043e\u043d\u043e\u043c \u0438&nbsp;\u043f\u043e\u0442\u043e\u043c \u0434\u043e\u043b\u0433\u043e \u0434\u0443\u043c\u0430\u0442\u044c. \u041d\u043e&nbsp;\u043d\u0435&nbsp;\u0437\u0440\u044f \u044f&nbsp;\u0447\u0438\u0442\u0430\u043b <a href=\"http:\/\/lwn.net\">lwn.net<\/a>. \u042f&nbsp;\u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b, \u0447\u0442\u043e \u0432&nbsp;\u044f\u0434\u0440\u0435 \u0435\u0441\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0438&nbsp;\u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0438&nbsp;\u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f\u0434\u0440\u0430: \u0442\u0435&nbsp;\u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b, \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b&nbsp;\u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c <nobr>\u043a\u0430\u043a\u0438\u0435-\u0442\u043e<\/nobr> \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0438\u0437&nbsp;\u044f\u0434\u0440\u0430, \u0430&nbsp;\u0437\u0430\u0442\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-260029","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/260029","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=260029"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/260029\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=260029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=260029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=260029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}