My OS is CentOS 7 latest. I set the isolcpus and transparent_hugepage=never default_hugepagesz=1G hugepagesz=1G in the cmdline to isolate cpus and enable huge pages with 1G per page. And I move all the irqs that can be binded to specified CPU cores.
My init function for using huge pages
bool initSharedMemory(const char* nm, std::size_t bytes){
int tid = ftok(nm, 'R');
if (tid == -1) {
fprintf(stderr, "ftok error: %d - %s\n", tid, strerror(-tid));
return false;
}
mSHMID = shmget(tid, bytes, SHM_HUGETLB | IPC_CREAT | SHM_R | SHM_W);
if (mSHMID < 0) {
fprintf(stderr, "shmget error: %d - %s\n", mSHMID, strerror(-mSHMID));
return false;
}
mMemory = (uint8_t*)shmat(mSHMID, nullptr, 0);
if (mMemory == (uint8_t*)(-1)) {
fprintf(stderr, "shmat error\n");
return false;
}
mSize = bytes;
return true;
}
I run my program with taskset and perf record. I find that there are some kallsyms about huge page clear,
99.73% test_stx2 test_stx2 [.] Stx::run [.] Stx::run -
0.03% test_stx2 [kernel.kallsyms] [k] clear_page [k] clear_page_c_e -
0.03% test_stx2 [kernel.kallsyms] [k] clear_huge_page [k] _cond_resched -
0.03% test_stx2 [kernel.kallsyms] [k] _cond_resched [k] clear_huge_page -
0.03% test_stx2 [kernel.kallsyms] [k] clear_huge_page [k] clear_page -
0.02% test_stx2 [kernel.kallsyms] [k] clear_page_c_e [k] clear_huge_page -
0.02% test_stx2 [kernel.kallsyms] [k] clear_huge_page [k] clear_huge_page -
0.02% test_stx2 test_stx2 [.] std::__fill_n_a<unsigned long*, unsigned long, unsigned long> [.] std::__fill_n_a<unsigned long*, unsigned long, unsigned long> -
0.00% test_stx2 [kernel.kallsyms] [.] retint_userspace_restore_args [.] retint_userspace_restore_args -
0.00% test_stx2 [kernel.kallsyms] [k] task_tick_fair [k] task_tick_fair -
0.00% test_stx2 [kernel.kallsyms] [k] irq_exit [k] irq_exit -
0.00% test_stx2 [kernel.kallsyms] [k] zone_statistics [k] zone_statistics -
0.00% test_stx2 [kernel.kallsyms] [k] do_softirq [k] do_softirq -
0.00% test_stx2 [kernel.kallsyms] [k] __update_cpu_load [k] __update_cpu_load -
0.00% test_stx2 [kernel.kallsyms] [k] scheduler_tick [k] scheduler_tick -
0.00% test_stx2 [kernel.kallsyms] [k] trigger_load_balance [k] trigger_load_balance -
0.00% test_stx2 [kernel.kallsyms] [k] __hrtimer_run_queues [k] __hrtimer_run_queues -
0.00% test_stx2 [kernel.kallsyms] [k] run_posix_cpu_timers [k] run_posix_cpu_timers -
0.00% test_stx2 [kernel.kallsyms] [k] zone_statistics [k] __inc_zone_state -
0.00% test_stx2 [kernel.kallsyms] [.] retint_userspace_restore_args [.] irq_return -
0.00% test_stx2 [kernel.kallsyms] [k] __inc_zone_state [k] zone_statistics -
0.00% test_stx2 [kernel.kallsyms] [.] handle_mm_fault [.] handle_mm_fault -
0.00% test_stx2 [kernel.kallsyms] [.] __do_page_fault [.] __do_page_fault -
0.00% test_stx2 [kernel.kallsyms] [k] __x86_indirect_thunk_rax [k] read_tsc
I cannot understand that why there are some clear_page operation. -
Aucun commentaire:
Enregistrer un commentaire