2017-05-06 84 views
0

我需要證明當進程運行時,我刪除此進程的ELF文件文件系統中的空閒塊和節點數不會增加,並且在我終止進程後他們增加。我還需要在整個生命週期中顯示延遲,因此我使用perf shed record ./Prog,但它會生成一個文件並保存記錄結果,並破壞我的第一部分任務。當我嘗試(超級用戶身份登錄)使用方法:如何更改perf perf sched記錄中的輸入文件名

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

我得到

Workload failed: permission denied 

有人能告訴我如何來改變文件的輸入文件是在其他文件系統?

回答

0

perf sched record有根據手冊頁http://man7.org/linux/man-pages/man1/perf-sched.1.html

-i, --input=<file> 

輸入文件名沒有選項可以更改輸出文件(-i是輸入文件沒有目錄)。 (默認:perf.data除非標準輸入是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具有-o選項來指定輸出文件的默認cmd_recordhttp://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選項。