static unsigned int free_index;
static struct kref index_kref; /* Keeps track of allocated trace channels */
+int ust_channels_overwrite_by_default = 0;
+int ust_channels_request_collection_by_default = 1;
+
static struct ltt_channel_setting *lookup_channel(const char *name)
{
struct ltt_channel_setting *iter;
*/
struct ust_channel *ltt_channels_trace_alloc(unsigned int *nr_channels,
int overwrite,
+ int request_collection,
int active)
{
struct ust_channel *channel = NULL;
channel[iter->index].subbuf_size = iter->subbuf_size;
channel[iter->index].subbuf_cnt = iter->subbuf_cnt;
channel[iter->index].overwrite = overwrite;
+ channel[iter->index].request_collection = request_collection;
channel[iter->index].active = active;
channel[iter->index].channel_name = iter->name;
}
int *buf_struct_shmids;
struct ust_buffer **buf;
int overwrite:1;
+ /* whether collection is requested upon trace start */
+ int request_collection:1;
int active:1;
unsigned int n_subbufs_order;
unsigned long commit_count_mask; /*
extern int ltt_channels_get_index_from_name(const char *name);
extern struct ust_channel *ltt_channels_trace_alloc(unsigned int *nr_channels,
int overwrite,
+ int request_collection,
int active);
extern void ltt_channels_trace_free(struct ust_channel *channels);
extern int _ltt_channels_get_event_id(const char *channel, const char *name);
extern int ltt_channels_get_event_id(const char *channel, const char *name);
+extern int ust_channels_overwrite_by_default;
+extern int ust_channels_request_collection_by_default;
+
#endif /* UST_CHANNELS_H */
};
/* volatile because shared between the listener and the main thread */
-volatile sig_atomic_t buffers_to_export = 0;
+int buffers_to_export = 0;
struct trctl_msg {
/* size: the size of all the fields except size itself */
}
for(i=0; i < trace->nr_channels; i++) {
- /* iterate on all cpus */
- for(j=0; j<trace->channels[i].n_cpus; j++) {
- char *buf;
- asprintf(&buf, "%s_%d", trace->channels[i].channel_name, j);
- result = ustcomm_request_consumer(pid, buf);
- if(result == -1) {
- WARN("Failed to request collection for channel %s. Is the daemon available?", trace->channels[i].channel_name);
- /* continue even if fail */
+ if(trace->channels[i].request_collection) {
+ /* iterate on all cpus */
+ for(j=0; j<trace->channels[i].n_cpus; j++) {
+ char *buf;
+ asprintf(&buf, "%s_%d", trace->channels[i].channel_name, j);
+ result = ustcomm_request_consumer(pid, buf);
+ if(result == -1) {
+ WARN("Failed to request collection for channel %s. Is the daemon available?", trace->channels[i].channel_name);
+ /* continue even if fail */
+ }
+ free(buf);
+ STORE_SHARED(buffers_to_export, LOAD_SHARED(buffers_to_export)+1);
}
- free(buf);
- buffers_to_export++;
}
}
*/
if(uatomic_read(&buf->consumed) == 0) {
DBG("decrementing buffers_to_export");
- buffers_to_export--;
+ STORE_SHARED(buffers_to_export, LOAD_SHARED(buffers_to_export)-1);
}
break;
}
}
+ if(getenv("UST_OVERWRITE")) {
+ int val = atoi(getenv("UST_OVERWRITE"));
+ if(val == 0 || val == 1) {
+ STORE_SHARED(ust_channels_overwrite_by_default, val);
+ }
+ else {
+ WARN("invalid value for UST_OVERWRITE");
+ }
+ }
+
+ if(getenv("UST_AUTOCOLLECT")) {
+ int val = atoi(getenv("UST_AUTOCOLLECT"));
+ if(val == 0 || val == 1) {
+ STORE_SHARED(ust_channels_request_collection_by_default, val);
+ }
+ else {
+ WARN("invalid value for UST_AUTOCOLLECT");
+ }
+ }
+
if(getenv("UST_TRACE")) {
char trace_name[] = "auto";
char trace_type[] = "ustrelay";
static void __attribute__((destructor)) keepalive()
{
- if(trace_recording() && buffers_to_export) {
+ if(trace_recording() && LOAD_SHARED(buffers_to_export)) {
int total = 0;
DBG("Keeping process alive for consumer daemon...");
- while(buffers_to_export) {
+ while(LOAD_SHARED(buffers_to_export)) {
const int interv = 200000;
restarting_usleep(interv);
total += interv;
/* free app, keeping socket file */
ustcomm_fini_app(&ustcomm_app, 1);
- buffers_to_export = 0;
+ STORE_SHARED(buffers_to_export, 0);
have_listener = 0;
init_socket();
create_listener();