mm initialization on fork/exec is spread all over the place, which makes the code look inconsistent. We have mm_init(), which is supposed to init/nullify mm's internals, but it doesn't init all the fields it should: - on fork ->mmap,mm_rb,vmacache_seqnum,map_count,mm_cpumask,locked_vm are zeroed in dup_mmap(); - on fork ->pmd_huge_pte is zeroed in dup_mm(), immediately before calling mm_init(); - ->cpu_vm_mask_var ptr is initialized by mm_init_cpumask(), which is called before mm_init() on both fork and exec; - ->context is initialized by init_new_context(), which is called after mm_init() on both fork and exec; Let's consolidate all the initializations in mm_init() to make the code look cleaner.
Showing the changes to include (1 of 3 files). Show all
Unified · Split
| @@ -461,6 +461,7 @@ static inline void mm_init_cpumask(struct mm_struct *mm) · 460 unmodified lines | |||
| 461 | #ifdef CONFIG_CPUMASK_OFFSTACK | 461 | #ifdef CONFIG_CPUMASK_OFFSTACK |
| 462 | mm->cpu_vm_mask_var = &mm->cpumask_allocation; | 462 | mm->cpu_vm_mask_var = &mm->cpumask_allocation; |
| 463 | #endif | 463 | #endif |
| 464 | cpumask_clear(mm->cpu_vm_mask_var); | ||
| 464 | } | 465 | } |
| 465 | 466 | ||
| 466 | /* Future-safe accessor for struct mm_struct's cpu_vm_mask. */ | 467 | /* Future-safe accessor for struct mm_struct's cpu_vm_mask. */ |