struct switch_output switch_output;
unsigned long long samples;
cpu_set_t affinity_mask;
+ unsigned long output_max_size; /* = 0: unlimited */
};
+static volatile int done;
+
static volatile int auxtrace_record__snapshot_started;
static DEFINE_TRIGGER(auxtrace_snapshot_trigger);
static DEFINE_TRIGGER(switch_output_trigger);
trigger_is_ready(&switch_output_trigger);
}
+static bool record__output_max_size_exceeded(struct record *rec)
+{
+ return rec->output_max_size &&
+ (rec->bytes_written >= rec->output_max_size);
+}
+
static int record__write(struct record *rec, struct mmap *map __maybe_unused,
void *bf, size_t size)
{
rec->bytes_written += size;
+ if (record__output_max_size_exceeded(rec) && !done) {
+ fprintf(stderr, "[ perf record: perf size limit reached (%" PRIu64 " KB),"
+ " stopping session ]\n",
+ rec->bytes_written >> 10);
+ done = 1;
+ }
+
if (switch_output_size(rec))
trigger_hit(&switch_output_trigger);
return record__write(rec, map, bf, size);
}
-static volatile int done;
static volatile int signr = -1;
static volatile int child_finished;
return 0;
}
+static int parse_output_max_size(const struct option *opt,
+ const char *str, int unset)
+{
+ unsigned long *s = (unsigned long *)opt->value;
+ static struct parse_tag tags_size[] = {
+ { .tag = 'B', .mult = 1 },
+ { .tag = 'K', .mult = 1 << 10 },
+ { .tag = 'M', .mult = 1 << 20 },
+ { .tag = 'G', .mult = 1 << 30 },
+ { .tag = 0 },
+ };
+ unsigned long val;
+
+ if (unset) {
+ *s = 0;
+ return 0;
+ }
+
+ val = parse_tag_value(str, tags_size);
+ if (val != (unsigned long) -1) {
+ *s = val;
+ return 0;
+ }
+
+ return -1;
+}
+
static int record__parse_mmap_pages(const struct option *opt,
const char *str,
int unset __maybe_unused)
"n", "Compressed records using specified level (default: 1 - fastest compression, 22 - greatest compression)",
record__parse_comp_level),
#endif
+ OPT_CALLBACK(0, "max-size", &record.output_max_size,
+ "size", "Limit the maximum size of the output file", parse_output_max_size),
OPT_END()
};