diff options
author | Otavio Salvador <otavio@ossystems.com.br> | 2017-03-17 17:57:30 -0300 |
---|---|---|
committer | Otavio Salvador <otavio@ossystems.com.br> | 2017-03-17 17:57:30 -0300 |
commit | a4418c438de6ad397fd17f006ca86257fb9ec5a6 (patch) | |
tree | 7d3d0aae806d05271a8952e9db50ff0d0e9ce22a /mm/hugetlb.c | |
parent | 94b0fc511e4db848d7bd0260dad0e977d3da2d72 (diff) | |
parent | d9e0350d2575a20ee7783427da9bd6b6107eb983 (diff) |
Merge tag 'v4.1.39' into 4.1-2.0.x-imx
Linux 4.1.39
* tag 'v4.1.39': (138 commits)
Linux 4.1.39
KVM: x86: remove data variable from kvm_get_msr_common
KVM: VMX: Fix host initiated access to guest MSR_TSC_AUX
KVM: x86: pass host_initiated to functions that read MSRs
perf/core: Fix the perf_cpu_time_max_percent check
perf/core: Make sysctl_perf_cpu_time_max_percent conform to documentation
perf/core: Fix implicitly enable dynamic interrupt throttle
perf/core: Fix dynamic interrupt throttle
Fix missing sanity check in /dev/sg
printk: use rcuidle console tracepoint
vfs: fix uninitialized flags in splice_to_pipe()
drm/radeon: Use mode h/vdisplay fields to hide out of bounds HW cursor
ARM: 8658/1: uaccess: fix zeroing of 64-bit get_user()
drm/dp/mst: fix kernel oops when turning off secondary monitor
[media] siano: make it work again with CONFIG_VMAP_STACK
mmc: core: fix multi-bit bus width without high-speed mode
futex: Move futex_init() to core_initcall
xen-netfront: Delete rx_refill_timer in xennet_disconnect_backend()
scsi: aacraid: Fix INTx/MSI-x issue with older controllers
cpumask: use nr_cpumask_bits for parsing functions
...
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Diffstat (limited to 'mm/hugetlb.c')
-rw-r--r-- | mm/hugetlb.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 88b472bec71d..2f47f0332a2c 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1387,23 +1387,32 @@ free: } /* - * When releasing a hugetlb pool reservation, any surplus pages that were - * allocated to satisfy the reservation must be explicitly freed if they were - * never used. - * Called with hugetlb_lock held. + * This routine has two main purposes: + * 1) Decrement the reservation count (resv_huge_pages) by the value passed + * in unused_resv_pages. This corresponds to the prior adjustments made + * to the associated reservation map. + * 2) Free any unused surplus pages that may have been allocated to satisfy + * the reservation. As many as unused_resv_pages may be freed. + * + * Called with hugetlb_lock held. However, the lock could be dropped (and + * reacquired) during calls to cond_resched_lock. Whenever dropping the lock, + * we must make sure nobody else can claim pages we are in the process of + * freeing. Do this by ensuring resv_huge_page always is greater than the + * number of huge pages we plan to free when dropping the lock. */ static void return_unused_surplus_pages(struct hstate *h, unsigned long unused_resv_pages) { unsigned long nr_pages; - /* Uncommit the reservation */ - h->resv_huge_pages -= unused_resv_pages; - /* Cannot return gigantic pages currently */ if (hstate_is_gigantic(h)) - return; + goto out; + /* + * Part (or even all) of the reservation could have been backed + * by pre-allocated pages. Only free surplus pages. + */ nr_pages = min(unused_resv_pages, h->surplus_huge_pages); /* @@ -1413,12 +1422,22 @@ static void return_unused_surplus_pages(struct hstate *h, * when the nodes with surplus pages have no free pages. * free_pool_huge_page() will balance the the freed pages across the * on-line nodes with memory and will handle the hstate accounting. + * + * Note that we decrement resv_huge_pages as we free the pages. If + * we drop the lock, resv_huge_pages will still be sufficiently large + * to cover subsequent pages we may free. */ while (nr_pages--) { + h->resv_huge_pages--; + unused_resv_pages--; if (!free_pool_huge_page(h, &node_states[N_MEMORY], 1)) - break; + goto out; cond_resched_lock(&hugetlb_lock); } + +out: + /* Fully uncommit the reservation */ + h->resv_huge_pages -= unused_resv_pages; } /* |