gpt4 book ai didi

linux - 如何更改 perf sched 记录中的输入文件名

转载 作者:太空宇宙 更新时间:2023-11-04 12:29:00 33 4
gpt4 key购买 nike

我需要证明,当进程运行时,我删除了这个进程的 ELF 文件,文件系统中的空闲 block 和节点数不会增加,而在我终止进程后,它们会增加。我还需要显示此过程的整个生命周期中的延迟,因此我正在使用 perf shed record ./Prog,但它会创建一个文件并在其中保存记录结果,这会破坏我任务的第一部分.当我尝试(以 root 身份登录)使用时:

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

我明白了

Workload failed: permission denied

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

最佳答案

根据手册页 http://man7.org/linux/man-pages/man1/perf-sched.1.html

perf sched record 没有更改输出文件的选项(-i 用于输入文件 而不是目录)

  -i, --input=<file>

Input file name. (default: perf.data unless stdin is a 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,
};

但是! builtin-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(记录输出)性能选项的参数。

关于linux - 如何更改 perf sched 记录中的输入文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43823954/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com