• D
    mm: change locked_vm's type from unsigned long to atomic_long_t · 53f4e528
    Daniel Jordan 提交于
    hulk inclusion
    category: feature
    bugzilla: 13228
    CVE: NA
    ---------------------------
    
    Currently, mmap_sem must be held as writer to modify the locked_vm field
    in mm_struct.
    
    This creates a bottleneck when multithreading VFIO page pinning because
    each thread holds the mmap_sem as reader for the majority of the pinning
    time but also takes mmap_sem as writer regularly, for short times, when
    modifying locked_vm.
    
    The problem gets worse when other workloads compete for CPU with ktask
    threads doing page pinning because the other workloads force ktask
    threads that hold mmap_sem as writer off the CPU, blocking ktask threads
    trying to get mmap_sem as reader for an excessively long time (the
    mmap_sem reader wait time grows linearly with the thread count).
    
    Requiring mmap_sem for locked_vm also abuses mmap_sem by making it
    protect data that could be synchronized separately.
    
    So, decouple locked_vm from mmap_sem by making locked_vm an
    atomic_long_t.  locked_vm's old type was unsigned long and changing it
    to a signed type makes it lose half its capacity, but that's only a
    concern for 32-bit systems and LONG_MAX * PAGE_SIZE is 8T on x86 in that
    case, so there's headroom.
    
    Now that mmap_sem is not taken as writer here, ktask threads holding
    mmap_sem as reader can run more often.  Performance results appear later
    in the series.
    
    On powerpc, this was cross-compiled-tested only.
    
    [XXX Can send separately.]
    Signed-off-by: NDaniel Jordan <daniel.m.jordan@oracle.com>
    Signed-off-by: NHongbo Yao <yaohongbo@huawei.com>
    Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
    Tested-by: NHongbo Yao <yaohongbo@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    53f4e528
debug.c 4.5 KB