[PATCH OLK-5.10] hugelb: do not sleep during spinlock hugetlb_lock

hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICLL1L -------------------------------- Commit 539370f5231b ("hugetlb: drain pcp for movable zone before alloc") try to drain pcp memory during hugepage allocation, however flush_work called by __drain_all_pages may sleep during draining. Fix this by moving this before alloc_pool_huge_page which hugetlb_lock is already unlocked before page allocation. Fixes: 539370f5231b ("hugetlb: drain pcp for movable zone before alloc") Signed-off-by: Wupeng Ma <mawupeng1@huawei.com> --- mm/hugetlb.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 5307e9c2b0538..1369aeab88858 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3035,6 +3035,7 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, struct page *page; LIST_HEAD(page_list); NODEMASK_ALLOC(nodemask_t, node_alloc_noretry, GFP_KERNEL); + bool drained = false; /* * Bit mask controlling how hard we retry per-node allocations. @@ -3109,14 +3110,6 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, break; } - /* - * drain pcp for movable zone to increase the success rate for - * hugetlb memory allocation if movable_node enabled - */ - if ((nid != NUMA_NO_NODE) && movable_node_is_enabled() && - count > persistent_huge_pages(h)) - hugetlb_drain_movable_pcp(h, nid); - while (count > persistent_huge_pages(h)) { /* * If this allocation races such that we no longer need the @@ -3128,6 +3121,16 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, /* yield cpu to avoid soft lockup */ cond_resched(); + /* + * drain pcp for movable zone to increase the success rate + * for hugetlb memory allocation if movable_node enabled + */ + if (!drained && (nid != NUMA_NO_NODE) && + movable_node_is_enabled()) { + hugetlb_drain_movable_pcp(h, nid); + drained = true; + } + ret = alloc_pool_huge_page(h, nodes_allowed, node_alloc_noretry); spin_lock_irq(&hugetlb_lock); -- 2.43.0

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/17566 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/WYA... 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://gitee.com/openeuler/kernel/pulls/17566 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/WYA...
participants (2)
-
patchwork bot
-
Wupeng Ma