From b278033a7e4632a414502b63ba51fcce36f44f94 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 20 Mar 2009 16:35:06 -0700 Subject: Cache the tracepoint query results To use tracepoints, we build a "tracequery" module that compiles debuginfo for all available tracepoints in the user's kernel. That's a bit of a cumbersome step to do during pass-2 though. This change adds tracequery caching so we only need to compile it once. --- hash.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'hash.cxx') diff --git a/hash.cxx b/hash.cxx index 61caa356..b8d5a0e4 100644 --- a/hash.cxx +++ b/hash.cxx @@ -237,4 +237,22 @@ find_hash (systemtap_session& s, const string& script) find_script_hash(s, script, base); } + +void +find_tracequery_hash (systemtap_session& s) +{ + hash h; + get_base_hash(s, h); + + // The basic hash should be good enough for the tracepoint query module + + // Get the directory path to store our cached module + string result, hashdir; + h.result(result); + if (!create_hashdir(s, result, hashdir)) + return; + + s.tracequery_path = hashdir + "/tracequery_" + result + ".ko"; +} + /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ -- cgit From 2a8c27f6bfdf2e7962def6fc8729ebb5fb54c701 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 25 Mar 2009 15:47:21 -0700 Subject: Add more file stats to the hash For kernel developers, it may be common practice to reuse the same kernel build tree for several kernel variants. Our previous hashing only considered the release version, architecture, and build path, which may all remain constant for such a developer. This change adds the file size and mtime of several kernel version files to the hash, so it should be a bit more robust against collisions. --- hash.cxx | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'hash.cxx') diff --git a/hash.cxx b/hash.cxx index b8d5a0e4..c9121641 100644 --- a/hash.cxx +++ b/hash.cxx @@ -47,6 +47,20 @@ hash::add(const unsigned char *buffer, size_t size) } +void +hash::add_file(const std::string& filename) +{ + struct stat st; + + if (stat(filename.c_str(), &st) == 0) + { + add(filename); + add(st.st_size); + add(st.st_mtime); + } +} + + void hash::result(string& r) { @@ -68,37 +82,33 @@ hash::result(string& r) static void get_base_hash (systemtap_session& s, hash& h) { - struct stat st; - // Hash kernel release and arch. h.add(s.kernel_release); h.add(s.kernel_build_tree); h.add(s.architecture); + // Hash a few kernel version/build-id files too + // (useful for kernel developers reusing a single source tree) + h.add_file(s.kernel_build_tree + "/.config"); + h.add_file(s.kernel_build_tree + "/.version"); + h.add_file(s.kernel_build_tree + "/include/linux/compile.h"); + h.add_file(s.kernel_build_tree + "/include/linux/version.h"); + h.add_file(s.kernel_build_tree + "/include/linux/utsrelease.h"); + // Hash runtime path (that gets added in as "-R path"). h.add(s.runtime_path); // Hash compiler path, size, and mtime. We're just going to assume // we'll be using gcc. XXX: getting kbuild to spit out out would be // better. - string gcc_path = find_executable ("gcc"); - if (stat(gcc_path.c_str(), &st) == 0) - { - h.add(gcc_path); - h.add(st.st_size); - h.add(st.st_mtime); - } + h.add_file(find_executable("gcc")); // Hash the systemtap size and mtime. We could use VERSION/DATE, // but when developing systemtap that doesn't work well (since you // can compile systemtap multiple times in 1 day). Since we don't // know exactly where we're getting run from, we'll use // /proc/self/exe. - if (stat("/proc/self/exe", &st) == 0) - { - h.add(st.st_size); - h.add(st.st_mtime); - } + h.add_file("/proc/self/exe"); } -- cgit From a5e8d632f443c6a882dcabc669236dc4798b1fd7 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 25 Mar 2009 17:25:06 -0700 Subject: Add the kernel tree's git revision to the hash To better support kernel developers who work out of a single source tree, this adds the git HEAD revision to our caching hash. --- hash.cxx | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'hash.cxx') diff --git a/hash.cxx b/hash.cxx index c9121641..649e7ec0 100644 --- a/hash.cxx +++ b/hash.cxx @@ -95,6 +95,10 @@ get_base_hash (systemtap_session& s, hash& h) h.add_file(s.kernel_build_tree + "/include/linux/version.h"); h.add_file(s.kernel_build_tree + "/include/linux/utsrelease.h"); + // If the kernel is a git working directory, then add the git HEAD + // revision to our hash as well. + h.add(git_revision(s.kernel_build_tree)); + // Hash runtime path (that gets added in as "-R path"). h.add(s.runtime_path); -- cgit From d0d806edbff3dbdc70a1c83dc6ac67c88b9606ce Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 26 Mar 2009 14:09:43 -0700 Subject: Skip the git-rev in the hash for now (from a5e8d632) It may be potentially expensive to fork-exec a git call to get the HEAD revision, and it's not clear whether it's even needed. We can always throw this back on if we find a meaningful usage scenario. --- hash.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'hash.cxx') diff --git a/hash.cxx b/hash.cxx index 649e7ec0..3ff6848d 100644 --- a/hash.cxx +++ b/hash.cxx @@ -97,7 +97,10 @@ get_base_hash (systemtap_session& s, hash& h) // If the kernel is a git working directory, then add the git HEAD // revision to our hash as well. - h.add(git_revision(s.kernel_build_tree)); + // XXX avoiding this for now, because it's potentially expensive and has + // uncertain gain. The only corner case that this may help is if a developer + // is switching the source tree without rebuilding the kernel... + ///h.add(git_revision(s.kernel_build_tree)); // Hash runtime path (that gets added in as "-R path"). h.add(s.runtime_path); -- cgit From dcfd7fed7088871f46d9da7183e485877fb2d81f Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Wed, 1 Apr 2009 22:50:47 -0400 Subject: PR10019: --skip-badvars to suppress run-time memory errors too * NEWS: Note this change. * hash.cxx (find_script_hash): Add s.skip_badvars into hash. * translate.cxx (translate_pass): Emit STP_SKIP_BADVARS. * runtime/loc2c-runtime.h (DEREF_FAULT, STORE_DEREF_FAULT): Provide dummy implementation if STP_SKIP_BADVARS. --- hash.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'hash.cxx') diff --git a/hash.cxx b/hash.cxx index 3ff6848d..01013c43 100644 --- a/hash.cxx +++ b/hash.cxx @@ -174,6 +174,7 @@ find_script_hash (systemtap_session& s, const string& script, const hash &base) h.add(s.ignore_vmlinux); // --ignore-vmlinux h.add(s.ignore_dwarf); // --ignore-dwarf h.add(s.consult_symtab); // --kelf, --kmap + h.add(s.skip_badvars); // --skip-badvars if (!s.kernel_symtab_path.empty()) // --kmap { h.add(s.kernel_symtab_path); -- cgit From 1f329b5e2af4710a254e252529e8eee2fab4fd67 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 20 Apr 2009 16:41:52 -0700 Subject: Add a function to hash typequery modules --- hash.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'hash.cxx') diff --git a/hash.cxx b/hash.cxx index 01013c43..45ae05eb 100644 --- a/hash.cxx +++ b/hash.cxx @@ -273,4 +273,24 @@ find_tracequery_hash (systemtap_session& s) s.tracequery_path = hashdir + "/tracequery_" + result + ".ko"; } + +void +find_typequery_hash (systemtap_session& s, const string& name, string& module) +{ + hash h; + get_base_hash(s, h); + + // Add the typequery name to distinguish the hash + h.add(name); + + // Get the directory path to store our cached module + string result, hashdir; + h.result(result); + if (!create_hashdir(s, result, hashdir)) + return; + + module = hashdir + "/typequery_" + result + + (name[0] == 'k' ? ".ko" : ".so"); +} + /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ -- cgit