如何在perf sched记录中更改输入文件名

时间:2017-05-06 18:25:55

标签: linux record perf

我需要证明当进程运行时我删除了这个进程的ELF文件数量的空闲块和文件系统中的节点不会增加,并且在我杀死进程后它们会增加。我还需要在此过程的整个生命周期中显示延迟,因此我使用EditBlogEntryFormContainer = reduxForm({ form: 'EditBlogEntryForm', getFormState: (state) => state.form, // <-- default of reduxForm validate })(EditBlogEntryFormContainer); ,但它会生成一个文件并保存记录结果,这会破坏我的第一部分任务。当我尝试(以root身份登录)使用时:

perf shed record ./Prog

我得到了

perf sched record -i /mnt/disk1 ./Prog &

有人能告诉我如何更改其他文件系统中的文件输入文件吗?

1 个答案:

答案 0 :(得分:0)

perf sched record无法根据手册页http://man7.org/linux/man-pages/man1/perf-sched.1.html更改输出文件(-i用于输入文件而非目录)

  -i, --input=<file>
     

输入文件名。 (默认值:perf.data,除非stdin是fifo)

并实施: http://elixir.free-electrons.com/linux/v4.8/source/tools/perf/builtin-sched.c#L1896

tools/perf/builtin-sched.c
static int __cmd_record(int argc, const char **argv)
{
    unsigned int rec_argc, i, j;
    const char **rec_argv;
    const char * const record_args[] = {
        "record",
        "-a",
        "-R",
        "-m", "1024",
        "-c", "1",
        "-e", "sched:sched_switch",
        "-e", "sched:sched_stat_wait",
        "-e", "sched:sched_stat_sleep",
        "-e", "sched:sched_stat_iowait",
        "-e", "sched:sched_stat_runtime",
        "-e", "sched:sched_process_fork",
        "-e", "sched:sched_wakeup",
        "-e", "sched:sched_wakeup_new",
        "-e", "sched:sched_migrate_task",
    };
...
    return cmd_record(i, rec_argv, NULL);
}

int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
{
    const struct option sched_options[] = {
    OPT_STRING('i', "input", &input_name, "file",
            "input file name"),
    OPT_INCR('v', "verbose", &verbose,
            "be more verbose (show symbol address, etc)"),
    OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
            "dump raw trace in ASCII"),
    OPT_END()
    };
....    

static int perf_sched__read_events(struct perf_sched *sched)
{
...
    struct perf_data_file file = {
        .path = input_name,
        .mode = PERF_DATA_MODE_READ,
        .force = sched->force,
    };

但是!内置sched.c的__cmd_record调用builtin_record.c的默认cmd_record,其中-o选项指定输出文件:http://elixir.free-electrons.com/linux/v4.8/source/tools/perf/builtin-record.c#L1380

    OPT_STRING('o', "output", &record.file.path, "file",
            "output file name"),

因此,您可以通过更改当前目录来更改perf sched record的目标路径,也可以尝试perf sched record -o /mnt/disk1/perf.data ./Prog &。不要使用目录名作为-i(报告输入)/ -o(记录输出)perf选项的参数。