*参照元 [#w8d569df] #backlinks *説明 [#t96f1f13] -パス: [[linux-4.4.1/mm/memory.c]] -FIXME: これは何? --説明 **引数 [#k90c29a7] -struct mm_struct *mm -- --[[linux-4.4.1/mm_struct]] -struct vm_area_struct *vma -- --[[linux-4.4.1/vm_area_struct]] -pmd_t *pmd -- --[[linux-4.4.1/pmd_t]] -unsigned long address -- **返り値 [#u2274928] -int -- **参考 [#cbd8e90f] *実装 [#gfec7a44] int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, pmd_t *pmd, unsigned long address) { spinlock_t *ptl; pgtable_t new = pte_alloc_one(mm, address); int wait_split_huge_page; if (!new) return -ENOMEM; - --[[linux-4.4.1/spinlock_t]] --[[linux-4.4.1/pgtable_t]] --[[linux-4.4.1/pte_alloc_one()]] /* * Ensure all pte setup (eg. pte page lock and page clearing) are * visible before the pte is made visible to other CPUs by being * put into page tables. * * The other side of the story is the pointer chasing in the page * table walking code (when walking the page table without locking; * ie. most of the time). Fortunately, these data accesses consist * of a chain of data-dependent loads, meaning most CPUs (alpha * being the notable exception) will already guarantee loads are * seen in-order. See the alpha page table accessors for the * smp_read_barrier_depends() barriers in page table walking code. */ smp_wmb(); /* Could be smp_wmb__xxx(before|after)_spin_lock */ - --[[linux-4.4.1/smp_wmb()]] ptl = pmd_lock(mm, pmd); wait_split_huge_page = 0; - --[[linux-4.4.1/pmd_lock()]] if (likely(pmd_none(*pmd))) { /* Has another populated it ? */ atomic_long_inc(&mm->nr_ptes); pmd_populate(mm, pmd, new); new = NULL; - --[[linux-4.4.1/likely()]] --[[linux-4.4.1/pmd_none()]] --[[linux-4.4.1/atomic_long_inc()]] --[[linux-4.4.1/pmd_populate()]] } else if (unlikely(pmd_trans_splitting(*pmd))) wait_split_huge_page = 1; - --[[linux-4.4.1/unlikely()]] --[[linux-4.4.1/pmd_trans_splitting()]] spin_unlock(ptl); - --[[linux-4.4.1/spin_unlock()]] if (new) pte_free(mm, new); - --[[linux-4.4.1/pte_free()]] if (wait_split_huge_page) wait_split_huge_page(vma->anon_vma, pmd); - --[[linux-4.4.1/wait_split_huge_page()]] return 0; } *コメント [#qc949721]