On Fri, Oct 30, 2020 at 6:00 AM Mike Kravetz <mike.kravetz@xxxxxxxxxx> wrote: > > On 10/28/20 11:13 PM, Muchun Song wrote: > > On Thu, Oct 29, 2020 at 7:42 AM Mike Kravetz <mike.kravetz@xxxxxxxxxx> wrote: > >> > >> On 10/26/20 7:51 AM, Muchun Song wrote: > >>> + > >>> +static inline spinlock_t *vmemmap_pmd_lockptr(pmd_t *pmd) > >>> +{ > >>> + static DEFINE_SPINLOCK(pgtable_lock); > >>> + > >>> + return &pgtable_lock; > >>> +} > >> > >> This is just a global lock. Correct? And hugetlb specific? > > > > Yes, it is a global lock. Originally, I wanted to use the pmd lock(e.g. > > pmd_lockptr()). But we need to allocate memory for the spinlock and > > initialize it when ALLOC_SPLIT_PTLOCKS. It may increase the > > complexity. > > > > And I think that here alloc/free hugetlb pages is not a frequent operation. > > So I finally use a global lock. Maybe it is enough. > > > >> > >> It should be OK as the page table entries for huegtlb pages will not > >> overlap with other entries. > > > > Does "hugetlb specific" mean the pmd lock? or per hugetlb lock? > > If it is pmd lock, this is fine to me. If not, it may not be enough. > > Because the lock also guards the splitting of pmd pgtable. > > By "hugetlb specific", I was trying to say that only hugetlb code would > use this lock. It is not a concern now. However, there has been talk > about other code doing something similar to remove struct pages. If that > ever happens then we will need a different locking scheme. Agreed, It is not a concern now :) > > Disregard my statement about there being no overlap. I was confusing > page tables for huge pages with page tables for mappings mmap entries > of huge pages. > -- > Mike Kravetz -- Yours, Muchun