日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

numabalance

發(fā)布時間:2023/12/8 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 numabalance 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
numabalance的本意是讓進程和其使用的memory在同一個numa節(jié)點上,這樣延遲最小。但是這需要 調(diào)動器來做大量的工作來遷移進程和memory到同一個node上,這樣對某些場景性能會有比較大的損耗。 一般debug時候如果perf top中看到遷移進程的函數(shù)則建議觀點numabalance試試 numabalance遷移的過程如下: 在每個時鐘中斷update_process_times->scheduler_tick void scheduler_tick(void) {#這個函數(shù)會調(diào)用調(diào)度器的定義的hook函數(shù),以fair 調(diào)度為例curr->sched_class->task_tick(rq, curr, 0);} static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued) {struct cfs_rq *cfs_rq;struct sched_entity *se = &curr->se;#調(diào)度器選擇下一個要執(zhí)行的函數(shù)for_each_sched_entity(se) {cfs_rq = cfs_rq_of(se);entity_tick(cfs_rq, se, queued);} #只有開了numabalance這個if條件才會成立,可見只有開了numabalance才會遷移進程和memory到同一個node上if (static_branch_unlikely(&sched_numa_balancing))task_tick_numa(rq, curr); } void task_tick_numa(struct rq *rq, struct task_struct *curr) {if (now > curr->node_stamp + period) {if (!curr->node_stamp)curr->numa_scan_period = task_scan_start(curr);curr->node_stamp += period; #這里每個jiffies掃描一次,這里添加一個work,其回調(diào)函數(shù)是task_numa_work,這個函數(shù)最主要的工作就是調(diào)用change_prot_numa把 #所有映射到VMA的PTE頁表項該為PAGE_NONEif (!time_before(jiffies, curr->mm->numa_next_scan)) {init_task_work(work, task_numa_work); /* TODO: move this into sched_fork() */task_work_add(curr, work, true);}} } 這樣改的目的是當下次訪問這個頁時就會發(fā)生缺頁中斷,這樣我們就可以在缺頁中斷中遷移進程和其使用的頁 static int handle_pte_fault(struct vm_fault *vmf) { #由于我們在中斷中我們把頁的pte改成none了,一次下面這個if條件會成立if (pte_protnone(vmf->orig_pte) && vma_is_accessible(vmf->vma))return do_numa_page(vmf); }static int do_numa_page(struct vm_fault *vmf) {last_cpupid = page_cpupid_last(page);page_nid = page_to_nid(page);#需要遷移目的node id target_nid。如果target_nid等于-1,則表示頁就在自己的numa節(jié)點上不用遷移target_nid = numa_migrate_prep(page, vma, vmf->address, page_nid,&flags);pte_unmap_unlock(vmf->pte, vmf->ptl);if (target_nid == -1) {put_page(page);goto out;}/* Migrate to the requested node */#通過下面函數(shù)將頁遷移到自己分配的numa 節(jié)點上migrated = migrate_misplaced_page(page, vma, target_nid);if (migrated) {page_nid = target_nid;flags |= TNF_MIGRATED;} elseflags |= TNF_MIGRATE_FAIL;out: #頁面遷移完成后,再通過task_numa_fault 來遷移taskif (page_nid != -1)task_numa_fault(last_cpupid, page_nid, 1, flags);return 0; }從整個過程看numa balance 會做額外很大工作,因此某些場景下嚴重影響性能,需要關掉.

總結

以上是生活随笔為你收集整理的numabalance的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。