All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] hugetlb: Fix comments about avoiding atomic allocation of vmemmap pages
@ 2022-03-16  3:16 luofei
  2022-03-16  8:48 ` Muchun Song
  0 siblings, 1 reply; 2+ messages in thread
From: luofei @ 2022-03-16  3:16 UTC (permalink / raw)
  To: mike.kravetz, akpm; +Cc: linux-mm, linux-kernel, luofei

Since there is no longer an atomic allocation of vmemmap pages,
but a fixed flag(GFP_KERNEL | __GFP_NORETRY | __GFP_THISNODE) is
used. The description of atomicity here is some what inappropriate.

And the atomic parameter naming of update_and_free_page() may
be misleading, add a comment here.

Signed-off-by: luofei <luofei@unicloud.com>
---
 mm/hugetlb.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index f8ca7cca3c1a..fbf598bbc4e3 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1569,10 +1569,12 @@ static void __update_and_free_page(struct hstate *h, struct page *page)
 }
 
 /*
- * As update_and_free_page() can be called under any context, so we cannot
- * use GFP_KERNEL to allocate vmemmap pages. However, we can defer the
- * actual freeing in a workqueue to prevent from using GFP_ATOMIC to allocate
- * the vmemmap pages.
+ * Freeing hugetlb pages in done in update_and_free_page(). When freeing
+ * a hugetlb page, vmemmap pages may need to be allocated. The routine
+ * alloc_huge_page_vmemmap() can possibly sleep as it uses GFP_KERNEL.
+ * However, update_and_free_page() can be called under any context. To
+ * avoid the possibility of sleeping in a context where sleeping is not
+ * allowed, defer the actual freeing in a workqueue where sleeping is allowed.
  *
  * free_hpage_workfn() locklessly retrieves the linked list of pages to be
  * freed and frees them one-by-one. As the page->mapping pointer is going
@@ -1616,6 +1618,10 @@ static inline void flush_free_hpage_work(struct hstate *h)
 		flush_work(&free_hpage_work);
 }
 
+/*
+ * atomic == true indicates called from a context where sleeping is
+ * not allowed.
+ */
 static void update_and_free_page(struct hstate *h, struct page *page,
 				 bool atomic)
 {
@@ -1625,7 +1631,8 @@ static void update_and_free_page(struct hstate *h, struct page *page,
 	}
 
 	/*
-	 * Defer freeing to avoid using GFP_ATOMIC to allocate vmemmap pages.
+	 * Defer freeing to avoid possible sleeping when allocating
+	 * vmemmap pages.
 	 *
 	 * Only call schedule_work() if hpage_freelist is previously
 	 * empty. Otherwise, schedule_work() had been called but the workfn
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] hugetlb: Fix comments about avoiding atomic allocation of vmemmap pages
  2022-03-16  3:16 [PATCH v2] hugetlb: Fix comments about avoiding atomic allocation of vmemmap pages luofei
@ 2022-03-16  8:48 ` Muchun Song
  0 siblings, 0 replies; 2+ messages in thread
From: Muchun Song @ 2022-03-16  8:48 UTC (permalink / raw)
  To: luofei; +Cc: Mike Kravetz, Andrew Morton, Linux Memory Management List, LKML

On Wed, Mar 16, 2022 at 11:16 AM luofei <luofei@unicloud.com> wrote:
>
> Since there is no longer an atomic allocation of vmemmap pages,
> but a fixed flag(GFP_KERNEL | __GFP_NORETRY | __GFP_THISNODE) is
> used. The description of atomicity here is some what inappropriate.
>
> And the atomic parameter naming of update_and_free_page() may
> be misleading, add a comment here.
>
> Signed-off-by: luofei <luofei@unicloud.com>

Reviewed-by: Muchun Song <songmuchun@bytedance.com>

Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-16  8:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16  3:16 [PATCH v2] hugetlb: Fix comments about avoiding atomic allocation of vmemmap pages luofei
2022-03-16  8:48 ` Muchun Song

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.