From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Mike Kravetz <mike.kravetz@oracle.com>,
Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Michal Hocko <mhocko@kernel.org>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.4 04/84] hugetlbfs: on restore reserve error path retain subpool reservation
Date: Thu, 20 Jun 2019 19:56:01 +0200 [thread overview]
Message-ID: <20190620174338.192463610@linuxfoundation.org> (raw)
In-Reply-To: <20190620174337.538228162@linuxfoundation.org>
[ Upstream commit 0919e1b69ab459e06df45d3ba6658d281962db80 ]
When a huge page is allocated, PagePrivate() is set if the allocation
consumed a reservation. When freeing a huge page, PagePrivate is checked.
If set, it indicates the reservation should be restored. PagePrivate
being set at free huge page time mostly happens on error paths.
When huge page reservations are created, a check is made to determine if
the mapping is associated with an explicitly mounted filesystem. If so,
pages are also reserved within the filesystem. The default action when
freeing a huge page is to decrement the usage count in any associated
explicitly mounted filesystem. However, if the reservation is to be
restored the reservation/use count within the filesystem should not be
decrementd. Otherwise, a subsequent page allocation and free for the same
mapping location will cause the file filesystem usage to go 'negative'.
Filesystem Size Used Avail Use% Mounted on
nodev 4.0G -4.0M 4.1G - /opt/hugepool
To fix, when freeing a huge page do not adjust filesystem usage if
PagePrivate() is set to indicate the reservation should be restored.
I did not cc stable as the problem has been around since reserves were
added to hugetlbfs and nobody has noticed.
Link: http://lkml.kernel.org/r/20190328234704.27083-2-mike.kravetz@oracle.com
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
mm/hugetlb.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index d7f65a8c629b..fd932e7a25dd 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1221,12 +1221,23 @@ void free_huge_page(struct page *page)
ClearPagePrivate(page);
/*
- * A return code of zero implies that the subpool will be under its
- * minimum size if the reservation is not restored after page is free.
- * Therefore, force restore_reserve operation.
+ * If PagePrivate() was set on page, page allocation consumed a
+ * reservation. If the page was associated with a subpool, there
+ * would have been a page reserved in the subpool before allocation
+ * via hugepage_subpool_get_pages(). Since we are 'restoring' the
+ * reservtion, do not call hugepage_subpool_put_pages() as this will
+ * remove the reserved page from the subpool.
*/
- if (hugepage_subpool_put_pages(spool, 1) == 0)
- restore_reserve = true;
+ if (!restore_reserve) {
+ /*
+ * A return code of zero implies that the subpool will be
+ * under its minimum size if the reservation is not restored
+ * after page is free. Therefore, force restore_reserve
+ * operation.
+ */
+ if (hugepage_subpool_put_pages(spool, 1) == 0)
+ restore_reserve = true;
+ }
spin_lock(&hugetlb_lock);
clear_page_huge_active(page);
--
2.20.1
next prev parent reply other threads:[~2019-06-20 18:32 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-20 17:55 [PATCH 4.4 00/84] 4.4.183-stable review Greg Kroah-Hartman
2019-06-20 17:55 ` [PATCH 4.4 01/84] fs/fat/file.c: issue flush after the writeback of FAT Greg Kroah-Hartman
2019-06-20 17:55 ` [PATCH 4.4 02/84] sysctl: return -EINVAL if val violates minmax Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 03/84] ipc: prevent lockup on alloc_msg and free_msg Greg Kroah-Hartman
2019-06-20 17:56 ` Greg Kroah-Hartman [this message]
2019-06-20 17:56 ` [PATCH 4.4 05/84] mm/cma.c: fix crash on CMA allocation if bitmap allocation fails Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 06/84] mm/cma_debug.c: fix the break condition in cma_maxchunk_get() Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 07/84] kernel/sys.c: prctl: fix false positive in validate_prctl_map() Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 08/84] mfd: intel-lpss: Set the device in reset state when init Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 09/84] mfd: twl6040: Fix device init errors for ACCCTL register Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 10/84] perf/x86/intel: Allow PEBS multi-entry in watermark mode Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 11/84] drm/bridge: adv7511: Fix low refresh rate selection Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 12/84] ntp: Allow TAI-UTC offset to be set to zero Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 13/84] f2fs: fix to avoid panic in do_recover_data() Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 14/84] f2fs: fix to do sanity check on valid block count of segment Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 15/84] iommu/vt-d: Set intel_iommu_gfx_mapped correctly Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 16/84] ALSA: hda - Register irq handler after the chip initialization Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 17/84] nvmem: core: fix read buffer in place Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 18/84] fuse: retrieve: cap requested size to negotiated max_write Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 19/84] nfsd: allow fh_want_write to be called twice Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 20/84] x86/PCI: Fix PCI IRQ routing table memory leak Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 21/84] platform/chrome: cros_ec_proto: check for NULL transfer function Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 22/84] soc: mediatek: pwrap: Zero initialize rdata in pwrap_init_cipher Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 23/84] clk: rockchip: Turn on "aclk_dmac1" for suspend on rk3288 Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 24/84] ARM: dts: imx6sx: Specify IMX6SX_CLK_IPG as "ahb" clock to SDMA Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 25/84] ARM: dts: imx6sx: Specify IMX6SX_CLK_IPG as "ipg" " Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 26/84] ARM: dts: imx6qdl: Specify IMX6QDL_CLK_IPG " Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 27/84] PCI: rpadlpar: Fix leaked device_node references in add/remove paths Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 28/84] PCI: rcar: Fix a potential NULL pointer dereference Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 29/84] video: hgafb: fix " Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 30/84] video: imsttfb: fix potential NULL pointer dereferences Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 31/84] PCI: xilinx: Check for __get_free_pages() failure Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 32/84] gpio: gpio-omap: add check for off wake capable gpios Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 33/84] dmaengine: idma64: Use actual device for DMA transfers Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 34/84] pwm: tiehrpwm: Update shadow register for disabling PWMs Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 35/84] ARM: dts: exynos: Always enable necessary APIO_1V8 and ABB_1V8 regulators on Arndale Octa Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 36/84] pwm: Fix deadlock warning when removing PWM device Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 37/84] ARM: exynos: Fix undefined instruction during Exynos5422 resume Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 38/84] futex: Fix futex lock the wrong page Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 39/84] Revert "Bluetooth: Align minimum encryption key size for LE and BR/EDR connections" Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 40/84] ALSA: seq: Cover unsubscribe_port() in list_mutex Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 41/84] libata: Extend quirks for the ST1000LM024 drives with NOLPM quirk Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 42/84] mm/list_lru.c: fix memory leak in __memcg_init_list_lru_node Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 43/84] fs/ocfs2: fix race in ocfs2_dentry_attach_lock() Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 44/84] [PATCH] signal/ptrace: Dont leak unitialized kernel memory with PTRACE_PEEK_SIGINFO Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 45/84] ptrace: restore smp_rmb() in __ptrace_may_access() Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 46/84] i2c: acorn: fix i2c warning Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 47/84] bcache: fix stack corruption by PRECEDING_KEY() Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 48/84] cgroup: Use css_tryget() instead of css_tryget_online() in task_get_css() Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 49/84] ASoC: cs42xx8: Add regcache mask dirty Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 50/84] Drivers: misc: fix out-of-bounds access in function param_set_kgdbts_var Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 51/84] scsi: lpfc: add check for loss of ndlp when sending RRQ Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 52/84] scsi: bnx2fc: fix incorrect cast to u64 on shift operation Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 53/84] usbnet: ipheth: fix racing condition Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 54/84] KVM: x86/pmu: do not mask the value that is written to fixed PMUs Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 55/84] KVM: s390: fix memory slot handling for KVM_SET_USER_MEMORY_REGION Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 56/84] drm/vmwgfx: integer underflow in vmw_cmd_dx_set_shader() leading to an invalid read Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 57/84] drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define() Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 58/84] USB: Fix chipmunk-like voice when using Logitech C270 for recording audio Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 59/84] USB: usb-storage: Add new ID to ums-realtek Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 60/84] USB: serial: pl2303: add Allied Telesis VT-Kit3 Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 61/84] USB: serial: option: add support for Simcom SIM7500/SIM7600 RNDIS mode Greg Kroah-Hartman
2019-06-20 17:56 ` [PATCH 4.4 62/84] USB: serial: option: add Telit 0x1260 and 0x1261 compositions Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 63/84] ax25: fix inconsistent lock state in ax25_destroy_timer Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 64/84] be2net: Fix number of Rx queues used for flow hashing Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 65/84] ipv6: flowlabel: fl6_sock_lookup() must use atomic_inc_not_zero Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 66/84] lapb: fixed leak of control-blocks Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 67/84] neigh: fix use-after-free read in pneigh_get_next Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 68/84] sunhv: Fix device naming inconsistency between sunhv_console and sunhv_reg Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 69/84] mISDN: make sure device name is NUL terminated Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 70/84] x86/CPU/AMD: Dont force the CPB cap when running under a hypervisor Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 71/84] perf/ring_buffer: Fix exposing a temporarily decreased data_head Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 72/84] perf/ring_buffer: Add ordering to rb->nest increment Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 73/84] gpio: fix gpio-adp5588 build errors Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 74/84] net: tulip: de4x5: Drop redundant MODULE_DEVICE_TABLE() Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 75/84] i2c: dev: fix potential memory leak in i2cdev_ioctl_rdwr Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 76/84] configfs: Fix use-after-free when accessing sd->s_dentry Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 77/84] ia64: fix build errors by exporting paddr_to_nid() Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 78/84] KVM: PPC: Book3S: Use new mutex to synchronize access to rtas token list Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 79/84] net: sh_eth: fix mdio access in sh_eth_close() for R-Car Gen2 and RZ/A1 SoCs Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 80/84] scsi: libcxgbi: add a check for NULL pointer in cxgbi_check_route() Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 81/84] scsi: libsas: delete sas port if expander discover failed Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 82/84] Revert "crypto: crypto4xx - properly set IV after de- and encrypt" Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 83/84] coredump: fix race condition between mmget_not_zero()/get_task_mm() and core dumping Greg Kroah-Hartman
2019-06-20 17:57 ` [PATCH 4.4 84/84] Abort file_remove_privs() for non-reg. files Greg Kroah-Hartman
2019-06-20 22:11 ` [PATCH 4.4 00/84] 4.4.183-stable review kernelci.org bot
2019-06-21 3:57 ` Naresh Kamboju
2019-06-22 0:43 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190620174338.192463610@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=dave@stgolabs.net \
--cc=iamjoonsoo.kim@lge.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@kernel.org \
--cc=mike.kravetz@oracle.com \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).