为什么内核函数调用clear_huge_page还是会出现?

问题描述

我的操作系统是最新的 CentOS 7。我在 cmdline 中设置了 isolcpus 和 transparent_hugepage=never default_hugepagesz=1G hugepagesz=1G 来隔离 cpus 并启用每页 1G 的大页面。我移动了所有可以绑定到指定 cpu 内核的 irq。

我使用大页面的初始化函数

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;
}

我使用任务集和性能记录运行我的程序。我发现有一些关于大页面清除的 kallsyms,

 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>           -
 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                  

我不明白为什么会有一些 clear_page 操作。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)