[PATCH v4 OLK-6.6] hugetlb: drain pcp for movable zone before alloc
hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/8761 -------------------------------- Memory retained in Per-CPU Pages (PCP) caches can prevent hugepage allocations from succeeding despite sufficient free system memory. This occurs because hugepage allocations don't actively trigger PCP draining. Reproduction: - Alloc page and free the page via put_page to release to pcp - Observe hugepage reservation failure Solution: Actively drain PCP during hugetlb memory allocation for movable node. Verification: This issue can be reproduce easily in zone movable with the following step: w/o this patch # numactl -m 2 dd if=/dev/urandom of=/dev/shm/testfile bs=4k count=64 # rm -f /dev/shm/testfile # sync # echo 3 > /proc/sys/vm/drop_caches # echo 2048 > /sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepages # cat /sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepages 2029 w/ this patch # numactl -m 2 dd if=/dev/urandom of=/dev/shm/testfile bs=4k count=64 # rm -f /dev/shm/testfile # sync # echo 3 > /proc/sys/vm/drop_caches # echo 2048 > /sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepages # cat /sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepages 2044 Commit 3a1587ef612c ("mm/numa_remote: introduce hugetlb_nowatermark mode for remote node") already bring the basic mechanism and this patch extends it to movable_node_is_enabled(). Since param h is not used, remove it. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Wupeng Ma <mawupeng1@huawei.com> --- mm/hugetlb.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index d8fe41a77cd2..c61232d4d582 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3835,22 +3835,26 @@ static int adjust_pool_surplus(struct hstate *h, nodemask_t *nodes_allowed, return 1; } -#ifdef CONFIG_ZONE_EXTMEM -static void hugetlb_drain_remote_pcp(struct hstate *h, int nid) +static void hugetlb_drain_zone(struct zone *zone) { - pg_data_t *pgdat = NODE_DATA(nid); - struct zone *zone; - - zone = &pgdat->node_zones[ZONE_EXTMEM]; + if (!zone_managed_pages(zone)) + return; - if (zone_managed_pages(zone)) - drain_all_pages(zone); + drain_all_pages(zone); } -#else -static inline void hugetlb_drain_remote_pcp(struct hstate *h, int nid) + +static void hugetlb_drain_pcp(int nid) { -} + pg_data_t *pgdat = NODE_DATA(nid); + + if (movable_node_is_enabled()) + hugetlb_drain_zone(&pgdat->node_zones[ZONE_MOVABLE]); + +#ifdef CONFIG_ZONE_EXTMEM + if (numa_remote_hugetlb_nowatermark(nid)) + hugetlb_drain_zone(&pgdat->node_zones[ZONE_EXTMEM]); #endif +} #define persistent_huge_pages(h) (h->nr_huge_pages - h->surplus_huge_pages) static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, @@ -3947,8 +3951,8 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, /* yield cpu to avoid soft lockup */ cond_resched(); - if ((nid != NUMA_NO_NODE) && numa_remote_hugetlb_nowatermark(nid) && !drained) { - hugetlb_drain_remote_pcp(h, nid); + if ((nid != NUMA_NO_NODE) && !drained) { + hugetlb_drain_pcp(nid); drained = true; } -- 2.43.0
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/21333 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/FSR... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/21333 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/FSR...
participants (2)
-
patchwork bot -
Wupeng Ma