{"id":762,"date":"2016-04-19T18:02:29","date_gmt":"2016-04-19T18:02:29","guid":{"rendered":"http:\/\/nenadnoveljic.com\/blog\/?p=762"},"modified":"2018-05-17T16:14:28","modified_gmt":"2018-05-17T16:14:28","slug":"dtrace-tracing-specific-kernel-threads","status":"publish","type":"post","link":"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/","title":{"rendered":"DTrace: Tracing Specific Kernel Threads"},"content":{"rendered":"<p>Sometimes we want to focus on profiling specific kernel threads. One approach is to trace everything and then use postprocessing scripts to extract the information of interest. The other is to use DTrace predicates for filtering.<br \/>\nA difficulty with kernel threads is that they all have process id and thread id set to 0. Therefore, I looked into the definition of the <em>_kthread<\/em> structure in <em>\/usr\/include\/sys\/thread.h<\/em> hoping to find alternative filtering citeria:<\/p>\n<pre><code>typedef struct _kthread {\r\n[...truncated...]\r\nvoid\u00a0\u00a0\u00a0 <span style=\"color: #ff0000;\">(*t_startpc<\/span>)(void);\u00a0\u00a0\u00a0\u00a0 \/* <span style=\"color: #ff0000;\">PC where thread started<\/span> *\/\r\n[...truncated...]<\/code><\/pre>\n<p>And there is one: the structure contains the program counter (PC) of the\u00a0procedure where the thread was started.<\/p>\n<p>For example, the following script will profile only Emulex completion threads (<em>emlxs`emlxs_thread<\/em>):<\/p>\n<pre><code>#!\/usr\/sbin\/dtrace -s\r\nprofile-997\r\n\/ <span style=\"color: #ff0000;\">(uintptr_t)curthread-&gt;t_startpc<\/span> == (uintptr_t)&amp;<span style=\"color: #ff0000;\">emlxs`emlxs_thread<\/span> \/\r\n{\r\n  @[stack()] = count() ;\r\n}\r\n\r\n[...truncated...]\r\nunix`pg_cmt_at_capacity+0x2c\r\nunix`disp_getwork+0x1bd\r\nunix`disp+0xd7\r\nunix`swtch+0xad\r\ngenunix`cv_wait+0x60\r\n<span style=\"color: #ff0000;\">emlxs`emlxs_thread<\/span>+0x11d\r\nunix`thread_start+0x8<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The blog post explains how to trace threads based on the first procedure on the stack. <a href=\"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[24,14],"tags":[],"class_list":["post-762","post","type-post","status-publish","format-standard","hentry","category-dtrace","category-solaris"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>DTrace: Tracing Specific Kernel Threads - All-round Database Topics<\/title>\n<meta name=\"description\" content=\"The blog post explains how to trace threads based on the first procedure on the stack.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"DTrace: Tracing Specific Kernel Threads - All-round Database Topics\" \/>\n<meta property=\"og:description\" content=\"The blog post explains how to trace threads based on the first procedure on the stack.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/\" \/>\n<meta property=\"og:site_name\" content=\"All-round Database Topics\" \/>\n<meta property=\"article:published_time\" content=\"2016-04-19T18:02:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-05-17T16:14:28+00:00\" \/>\n<meta name=\"author\" content=\"Nenad Noveljic\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@NenadNoveljic\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nenad Noveljic\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/dtrace-tracing-specific-kernel-threads\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/dtrace-tracing-specific-kernel-threads\\\/\"},\"author\":{\"name\":\"Nenad Noveljic\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\"},\"headline\":\"DTrace: Tracing Specific Kernel Threads\",\"datePublished\":\"2016-04-19T18:02:29+00:00\",\"dateModified\":\"2018-05-17T16:14:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/dtrace-tracing-specific-kernel-threads\\\/\"},\"wordCount\":113,\"commentCount\":0,\"articleSection\":[\"DTrace\",\"Solaris\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/dtrace-tracing-specific-kernel-threads\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/dtrace-tracing-specific-kernel-threads\\\/\",\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/dtrace-tracing-specific-kernel-threads\\\/\",\"name\":\"DTrace: Tracing Specific Kernel Threads - All-round Database Topics\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#website\"},\"datePublished\":\"2016-04-19T18:02:29+00:00\",\"dateModified\":\"2018-05-17T16:14:28+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\"},\"description\":\"The blog post explains how to trace threads based on the first procedure on the stack.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/dtrace-tracing-specific-kernel-threads\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/dtrace-tracing-specific-kernel-threads\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/dtrace-tracing-specific-kernel-threads\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DTrace: Tracing Specific Kernel Threads\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/\",\"name\":\"All-round Database Topics\",\"description\":\"Nenad Noveljic\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\",\"name\":\"Nenad Noveljic\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"caption\":\"Nenad Noveljic\"},\"sameAs\":[\"nenad-noveljic-9b746a6\",\"https:\\\/\\\/x.com\\\/NenadNoveljic\"],\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/author\\\/nenad\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"DTrace: Tracing Specific Kernel Threads - All-round Database Topics","description":"The blog post explains how to trace threads based on the first procedure on the stack.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/","og_locale":"en_US","og_type":"article","og_title":"DTrace: Tracing Specific Kernel Threads - All-round Database Topics","og_description":"The blog post explains how to trace threads based on the first procedure on the stack.","og_url":"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/","og_site_name":"All-round Database Topics","article_published_time":"2016-04-19T18:02:29+00:00","article_modified_time":"2018-05-17T16:14:28+00:00","author":"Nenad Noveljic","twitter_card":"summary_large_image","twitter_creator":"@NenadNoveljic","twitter_misc":{"Written by":"Nenad Noveljic","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/#article","isPartOf":{"@id":"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/"},"author":{"name":"Nenad Noveljic","@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa"},"headline":"DTrace: Tracing Specific Kernel Threads","datePublished":"2016-04-19T18:02:29+00:00","dateModified":"2018-05-17T16:14:28+00:00","mainEntityOfPage":{"@id":"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/"},"wordCount":113,"commentCount":0,"articleSection":["DTrace","Solaris"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/","url":"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/","name":"DTrace: Tracing Specific Kernel Threads - All-round Database Topics","isPartOf":{"@id":"https:\/\/nenadnoveljic.com\/blog\/#website"},"datePublished":"2016-04-19T18:02:29+00:00","dateModified":"2018-05-17T16:14:28+00:00","author":{"@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa"},"description":"The blog post explains how to trace threads based on the first procedure on the stack.","breadcrumb":{"@id":"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nenadnoveljic.com\/blog\/dtrace-tracing-specific-kernel-threads\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nenadnoveljic.com\/blog\/"},{"@type":"ListItem","position":2,"name":"DTrace: Tracing Specific Kernel Threads"}]},{"@type":"WebSite","@id":"https:\/\/nenadnoveljic.com\/blog\/#website","url":"https:\/\/nenadnoveljic.com\/blog\/","name":"All-round Database Topics","description":"Nenad Noveljic","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nenadnoveljic.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa","name":"Nenad Noveljic","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","caption":"Nenad Noveljic"},"sameAs":["nenad-noveljic-9b746a6","https:\/\/x.com\/NenadNoveljic"],"url":"https:\/\/nenadnoveljic.com\/blog\/author\/nenad\/"}]}},"_links":{"self":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/comments?post=762"}],"version-history":[{"count":1,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/762\/revisions"}],"predecessor-version":[{"id":767,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/762\/revisions\/767"}],"wp:attachment":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/media?parent=762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/categories?post=762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/tags?post=762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}