summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2010-03-02 15:57:58 -0800
committerJosh Stone <jistone@redhat.com>2010-03-02 16:05:18 -0800
commitd105f6642677bd9ef1b20d1ba180ba0163cb0fa6 (patch)
tree49c4869c7c4a687e692bb33beabab3b008beb43d
parent9b3c54b2fc836e20a0a7895aa759938e62eaacf9 (diff)
downloadsystemtap-steved-d105f6642677bd9ef1b20d1ba180ba0163cb0fa6.tar.gz
systemtap-steved-d105f6642677bd9ef1b20d1ba180ba0163cb0fa6.tar.xz
systemtap-steved-d105f6642677bd9ef1b20d1ba180ba0163cb0fa6.zip
PR11246 cont'd: Add options for cache control
--disable-cache : turn off all caching --clean-cache : clean up stale entries and then quit --poison-cache : force regeneration of items that would have hit the cache These are undocumented for now, until we decide whether they are generally useful. * main.cxx (main): Parse the new options. * session.h (systemtap_session): Add poison_cache; document the others. * clean.cxx (clean_cache): No longer static. (get_stapconf_from_cache, get_script_from_cache): Respect poison. * tapsets.cxx (tracepoint_builder::get_tracequery_module): Ditto. (dwarf_cast_expanding_visitor::filter_special_modules): Ditto.
-rw-r--r--cache.cxx10
-rw-r--r--cache.h2
-rw-r--r--main.cxx31
-rw-r--r--session.h13
-rw-r--r--tapsets.cxx4
5 files changed, 49 insertions, 11 deletions
diff --git a/cache.cxx b/cache.cxx
index 6b51f21c..13436439 100644
--- a/cache.cxx
+++ b/cache.cxx
@@ -42,8 +42,6 @@ struct cache_ent_info {
void unlink() const;
};
-static void clean_cache(systemtap_session& s);
-
void
add_stapconf_to_cache(systemtap_session& s)
@@ -101,6 +99,9 @@ add_script_to_cache(systemtap_session& s)
bool
get_stapconf_from_cache(systemtap_session& s)
{
+ if (s.poison_cache)
+ return false;
+
string stapconf_dest_path = s.tmpdir + "/" + s.stapconf_name;
int fd_stapconf;
@@ -132,6 +133,9 @@ get_stapconf_from_cache(systemtap_session& s)
bool
get_script_from_cache(systemtap_session& s)
{
+ if (s.poison_cache)
+ return false;
+
string module_dest_path = s.tmpdir + "/" + s.module_name + ".ko";
string c_src_path = s.hash_path;
int fd_module, fd_c;
@@ -215,7 +219,7 @@ get_script_from_cache(systemtap_session& s)
}
-static void
+void
clean_cache(systemtap_session& s)
{
if (s.cache_path != "")
diff --git a/cache.h b/cache.h
index 548fa8c8..209daf5c 100644
--- a/cache.h
+++ b/cache.h
@@ -4,4 +4,6 @@ bool get_script_from_cache(systemtap_session& s);
void add_stapconf_to_cache(systemtap_session& s);
bool get_stapconf_from_cache(systemtap_session& s);
+void clean_cache(systemtap_session& s);
+
/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
diff --git a/main.cxx b/main.cxx
index 6d3f649b..9cc0370d 100644
--- a/main.cxx
+++ b/main.cxx
@@ -537,6 +537,7 @@ main (int argc, char * const argv [])
s.symtab = false;
s.use_cache = true;
s.use_script_cache = true;
+ s.poison_cache = false;
s.tapset_compile_coverage = false;
s.need_uprobes = false;
s.consult_symtab = false;
@@ -633,6 +634,9 @@ main (int argc, char * const argv [])
#define LONG_OPT_OMIT_WERROR 8
#define LONG_OPT_CLIENT_OPTIONS 9
#define LONG_OPT_HELP 10
+#define LONG_OPT_DISABLE_CACHE 11
+#define LONG_OPT_POISON_CACHE 12
+#define LONG_OPT_CLEAN_CACHE 13
// NB: also see find_hash(), usage(), switch stmt below, stap.1 man page
static struct option long_options[] = {
{ "kelf", 0, &long_opt, LONG_OPT_KELF },
@@ -651,6 +655,9 @@ main (int argc, char * const argv [])
{ OWE4 OWE6 OWE1 OWE2 OWE3 OWE5, 0, &long_opt, LONG_OPT_OMIT_WERROR },
{ "client-options", 0, &long_opt, LONG_OPT_CLIENT_OPTIONS },
{ "help", 0, &long_opt, LONG_OPT_HELP },
+ { "disable-cache", 0, &long_opt, LONG_OPT_DISABLE_CACHE },
+ { "poison-cache", 0, &long_opt, LONG_OPT_POISON_CACHE },
+ { "clean-cache", 0, &long_opt, LONG_OPT_CLEAN_CACHE },
{ NULL, 0, NULL, 0 }
};
int grc = getopt_long (argc, argv, "hVvtp:I:e:o:R:r:a:m:kgPc:x:D:bs:uqwl:d:L:FS:B:W",
@@ -948,6 +955,30 @@ main (int argc, char * const argv [])
case LONG_OPT_HELP:
usage (s, 0);
break;
+
+ // The caching options should not be available to server clients
+ case LONG_OPT_DISABLE_CACHE:
+ if (client_options) {
+ cerr << "ERROR: --disable-cache is invalid with --client-options" << endl;
+ exit(1);
+ }
+ s.use_cache = s.use_script_cache = false;
+ break;
+ case LONG_OPT_POISON_CACHE:
+ if (client_options) {
+ cerr << "ERROR: --poison-cache is invalid with --client-options" << endl;
+ exit(1);
+ }
+ s.poison_cache = true;
+ break;
+ case LONG_OPT_CLEAN_CACHE:
+ if (client_options) {
+ cerr << "ERROR: --clean-cache is invalid with --client-options" << endl;
+ exit(1);
+ }
+ clean_cache(s);
+ exit(0);
+
default:
exit(1);
}
diff --git a/session.h b/session.h
index ccf6c1da..1df94680 100644
--- a/session.h
+++ b/session.h
@@ -127,12 +127,13 @@ struct systemtap_session
// and/or main.cxx(main).
// Cache data
- bool use_cache;
- bool use_script_cache;
- std::string cache_path;
- std::string hash_path;
- std::string stapconf_path;
- hash *base_hash;
+ bool use_cache; // control all caching
+ bool use_script_cache; // control caching of pass-3/4 output
+ bool poison_cache; // consider the cache to be write-only
+ std::string cache_path; // usually ~/.systemtap/cache
+ std::string hash_path; // path to the cached script module
+ std::string stapconf_path; // path to the cached stapconf
+ hash *base_hash; // hash common to all caching
// dwarfless operation
bool consult_symtab;
diff --git a/tapsets.cxx b/tapsets.cxx
index 1ffbcec8..90dedbe9 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -2773,7 +2773,7 @@ void dwarf_cast_expanding_visitor::filter_special_modules(string& module)
{
// see if the cached module exists
cached_module = find_typequery_hash(s, module);
- if (!cached_module.empty())
+ if (!cached_module.empty() && !s.poison_cache)
{
int fd = open(cached_module.c_str(), O_RDONLY);
if (fd != -1)
@@ -6539,7 +6539,7 @@ tracepoint_builder::get_tracequery_module(systemtap_session& s,
{
// see if the cached module exists
tracequery_path = find_tracequery_hash(s, headers);
- if (!tracequery_path.empty())
+ if (!tracequery_path.empty() && !s.poison_cache)
{
int fd = open(tracequery_path.c_str(), O_RDONLY);
if (fd != -1)