{"id":295,"date":"2015-02-09T19:39:13","date_gmt":"2015-02-09T11:39:13","guid":{"rendered":"http:\/\/finaldie.com\/blog\/?p=295"},"modified":"2015-02-09T19:43:59","modified_gmt":"2015-02-09T11:43:59","slug":"compile-mutrace-on-rhel6","status":"publish","type":"post","link":"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/","title":{"rendered":"Compile mutrace on RHEL6"},"content":{"rendered":"<h1>Why mutrace<\/h1>\n<p>Recently, I want to profile the linux user lock(pthread mutex\/rwlock) performance of a project, and there are few options for this purpose:<\/p>\n<ul>\n<li>valgrind(drd)<\/li>\n<li>systemtap(futexes.stp)<\/li>\n<li>lttng<\/li>\n<li>mutrace<\/li>\n<\/ul>\n<p>Finally, I selected the <strong>mutrace<\/strong> due to:<\/p>\n<ol>\n<li><strong>valgrind(drd):<\/strong> It&#8217;s really slow, cannot provide credible information.<\/li>\n<li><strong>systemtap(futexes.stp):<\/strong> It&#8217;s really great in profiling kernel, but the user layer profile need to additional efforts to setup the environment(some debuginfo pkg).<\/li>\n<li><strong>lttng:<\/strong> There is only rpm pkg available on RHEL7, have to compile by myself. And there are more than one dependency lib, hard to fix the dependency issue.<\/li>\n<li><strong>mutrace:<\/strong> There is no rpm pkg available on RHEL6, have to compile by myself, and fortunately it&#8217;s not very hard to pass the compilation.<\/li>\n<\/ol>\n<h1>Installation Steps<\/h1>\n<p>To get it done, need a few steps:<\/p>\n<ol>\n<li>Get the source code\n<pre><code>git clone git:\/\/git.0pointer.net\/mutrace.git\n<\/code><\/pre>\n<\/li>\n<li>Modify the autoconf required version from 2.68 to 2.63\n<pre><code>diff --git a\/configure.ac b\/configure.ac\nindex fcb1397..0d36e41 100644\n--- a\/configure.ac\n+++ b\/configure.ac\n@@ -18,7 +18,7 @@\n# You should have received a copy of the GNU Lesser General Public\n# License along with mutrace. If not, see &lt;http:\/\/www.gnu.org\/licenses\/&gt;.\n\n-AC_PREREQ([2.68])\n+AC_PREREQ([2.63])\n\nAC_INIT([mutrace], [0.2], [mzzhgenpr (at) 0pointer (dot) net])\nAC_CONFIG_SRCDIR([mutrace.c])\n<\/code><\/pre>\n<\/li>\n<li>Upgrade gcc version to at least gcc 4.6<\/p>\n<\/li>\n<li>\n<p>Do some code changes for <strong>backtrace-symbols.c<\/strong> to pass the compilation<\/p>\n<pre><code>diff --git a\/backtrace-symbols.c b\/backtrace-symbols.c\nindex 0a0d751..6f84c56 100644\n--- a\/backtrace-symbols.c\n+++ b\/backtrace-symbols.c\n@@ -34,6 +34,8 @@\n  along with this program; if not, write to the Free Software\n  Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  *\/\n\n+#include \"config.h\"\n+\n#define fatal(a, b) exit(1)\n#define bfd_fatal(a) exit(1)\n#define bfd_nonfatal(a) exit(1)\n@@ -44,13 +46,13 @@\n#define true 1\n#define false 0\n\n-#define _GNU_SOURCE\n+\/\/#define _GNU_SOURCE\n#include &lt;string.h&gt;\n#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n#include &lt;execinfo.h&gt;\n#include &lt;bfd.h&gt;\n-#include &lt;libiberty.h&gt;\n+\/\/#include &lt;libiberty.h&gt;\n#include &lt;dlfcn.h&gt;\n#include &lt;link.h&gt;\n#if 0\n<\/code><\/pre>\n<\/li>\n<li>Run <strong>.\/bootstrap.sh<\/strong> to generate Makefile<\/p>\n<\/li>\n<li>Change &#8216;-O0&#8217; to &#8216;-O2&#8217; from CFLAGS in the Makefile<\/li>\n<li>Run <strong>make<\/strong> and <strong>make install<\/strong><\/li>\n<\/ol>\n<h1>In the end<\/h1>\n<p>Now, <strong>mutrace<\/strong>, <strong>matrace<\/strong> and the other related libraries have been generated, profile your program by:<\/p>\n<pre><code>mutrace -r $test_app ...\n<\/code><\/pre>\n<p>And big thanks to the original author @Lennart Poettering<\/p>\n<h1>References<\/h1>\n<p><a href=\"http:\/\/0pointer.de\/blog\/projects\/mutrace.html\">http:\/\/0pointer.de\/blog\/projects\/mutrace.html<\/a><br \/>\n<a href=\"http:\/\/0pointer.net\/blog\/projects\/mutrace2.html\">http:\/\/0pointer.net\/blog\/projects\/mutrace2.html<\/a><\/p>\n<p>have a fun :)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Why mutrace Recently, I want to profile the linux user lock(pthread mutex\/rwlock) performance of a project, and there are few options for this purpose: valgrind(drd) systemtap(futexes.stp) lttng mutrace Finally, I selected the mutrace due to: valgrind(drd): It&#8217;s really slow, cannot provide credible information. systemtap(futexes.stp): It&#8217;s really great in profiling kernel, but the user layer profile &#8230; <a title=\"Compile mutrace on RHEL6\" class=\"read-more\" href=\"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/\" aria-label=\"More on Compile mutrace on RHEL6\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[13,16,15,14,7],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Compile mutrace on RHEL6 - Final Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Compile mutrace on RHEL6 - Final Blog\" \/>\n<meta property=\"og:description\" content=\"Why mutrace Recently, I want to profile the linux user lock(pthread mutex\/rwlock) performance of a project, and there are few options for this purpose: valgrind(drd) systemtap(futexes.stp) lttng mutrace Finally, I selected the mutrace due to: valgrind(drd): It&#8217;s really slow, cannot provide credible information. systemtap(futexes.stp): It&#8217;s really great in profiling kernel, but the user layer profile ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/\" \/>\n<meta property=\"og:site_name\" content=\"Final Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hu.yuzhang\" \/>\n<meta property=\"article:published_time\" content=\"2015-02-09T11:39:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-02-09T11:43:59+00:00\" \/>\n<meta name=\"author\" content=\"final\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hyzwowtools\" \/>\n<meta name=\"twitter:site\" content=\"@hyzwowtools\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"final\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/\",\"url\":\"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/\",\"name\":\"Compile mutrace on RHEL6 - Final Blog\",\"isPartOf\":{\"@id\":\"https:\/\/finaldie.com\/blog\/#website\"},\"datePublished\":\"2015-02-09T11:39:13+00:00\",\"dateModified\":\"2015-02-09T11:43:59+00:00\",\"author\":{\"@id\":\"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3\"},\"breadcrumb\":{\"@id\":\"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/finaldie.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Compile mutrace on RHEL6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/finaldie.com\/blog\/#website\",\"url\":\"https:\/\/finaldie.com\/blog\/\",\"name\":\"Final Blog\",\"description\":\"As simple as possible...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/finaldie.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3\",\"name\":\"final\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/finaldie.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g\",\"caption\":\"final\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Compile mutrace on RHEL6 - Final Blog","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:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/","og_locale":"en_US","og_type":"article","og_title":"Compile mutrace on RHEL6 - Final Blog","og_description":"Why mutrace Recently, I want to profile the linux user lock(pthread mutex\/rwlock) performance of a project, and there are few options for this purpose: valgrind(drd) systemtap(futexes.stp) lttng mutrace Finally, I selected the mutrace due to: valgrind(drd): It&#8217;s really slow, cannot provide credible information. systemtap(futexes.stp): It&#8217;s really great in profiling kernel, but the user layer profile ... Read more","og_url":"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/","og_site_name":"Final Blog","article_publisher":"https:\/\/www.facebook.com\/hu.yuzhang","article_published_time":"2015-02-09T11:39:13+00:00","article_modified_time":"2015-02-09T11:43:59+00:00","author":"final","twitter_card":"summary_large_image","twitter_creator":"@hyzwowtools","twitter_site":"@hyzwowtools","twitter_misc":{"Written by":"final","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/","url":"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/","name":"Compile mutrace on RHEL6 - Final Blog","isPartOf":{"@id":"https:\/\/finaldie.com\/blog\/#website"},"datePublished":"2015-02-09T11:39:13+00:00","dateModified":"2015-02-09T11:43:59+00:00","author":{"@id":"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3"},"breadcrumb":{"@id":"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/finaldie.com\/blog\/compile-mutrace-on-rhel6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/finaldie.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Compile mutrace on RHEL6"}]},{"@type":"WebSite","@id":"https:\/\/finaldie.com\/blog\/#website","url":"https:\/\/finaldie.com\/blog\/","name":"Final Blog","description":"As simple as possible...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/finaldie.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3","name":"final","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/finaldie.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g","caption":"final"}}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts\/295"}],"collection":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/comments?post=295"}],"version-history":[{"count":16,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts\/295\/revisions"}],"predecessor-version":[{"id":311,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts\/295\/revisions\/311"}],"wp:attachment":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/media?parent=295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/categories?post=295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/tags?post=295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}