(Commit message majorly collected from Jason Gunthorpe) Reduce the chance of false positive from page_maybe_dma_pinned() by keeping track if the mm_struct has ever been used with pin_user_pages(). This allows cases that might drive up the page ref_count to avoid any penalty from handling dma_pinned pages. Future work is planned, to provide a more sophisticated solution, likely to turn it into a real counter. For now, make it atomic_t but use it as a boolean for simplicity.
Showing the changes to kernel (1 of 3 files). Show all
Unified · Split
| @@ -1011,6 +1011,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, · 1010 unmodified lines | |||
| 1011 | mm_pgtables_bytes_init(mm); | 1011 | mm_pgtables_bytes_init(mm); |
| 1012 | mm->map_count = 0; | 1012 | mm->map_count = 0; |
| 1013 | mm->locked_vm = 0; | 1013 | mm->locked_vm = 0; |
| 1014 | atomic_set(&mm->has_pinned, 0); | ||
| 1014 | atomic64_set(&mm->pinned_vm, 0); | 1015 | atomic64_set(&mm->pinned_vm, 0); |
| 1015 | memset(&mm->rss_stat, 0, sizeof(mm->rss_stat)); | 1016 | memset(&mm->rss_stat, 0, sizeof(mm->rss_stat)); |
| 1016 | spin_lock_init(&mm->page_table_lock); | 1017 | spin_lock_init(&mm->page_table_lock); |