linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [bug report] mm/mremap: add MREMAP[_MUST]_RELOCATE_ANON support for large folios
@ 2025-06-25 15:22 Dan Carpenter
  2025-06-25 15:30 ` Lorenzo Stoakes
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-06-25 15:22 UTC (permalink / raw)
  To: lorenzo.stoakes; +Cc: linux-mm

Hello Lorenzo Stoakes,

The patch a7fc0d8bd77d: "mm/mremap: add MREMAP[_MUST]_RELOCATE_ANON
support for large folios" from Jun 9, 2025, leads to the following
static checker warning:

mm/mremap.c:945 relocate_anon_pud() warn: sleeping in atomic context
mm/mremap.c:989 relocate_anon_pmd() warn: sleeping in atomic context

mm/mremap.c
    910 static bool relocate_anon_pud(struct pagetable_move_control *pmc,
    911 		pud_t *pudp, bool undo)
    912 {
    913 	spinlock_t *ptl;
    914 	pud_t pud;
    915 	struct folio *folio;
    916 	struct page *page;
    917 	bool ret;
    918 	unsigned long old_addr = pmc->old_addr;
    919 	unsigned long new_addr = pmc->new_addr;
    920 
    921 	VM_WARN_ON(old_addr & ~HPAGE_PUD_MASK);
    922 	VM_WARN_ON(new_addr & ~HPAGE_PUD_MASK);
    923 
    924 	ptl = pud_trans_huge_lock(pudp, pmc->old);
    925 	if (!ptl)
    926 		return false;
    927 
    928 	pud = pudp_get(pudp);
    929 	if (!pud_present(pud)) {
    930 		ret = true;
    931 		goto out;
    932 	}
    933 	if (!pud_leaf(pud)) {
    934 		ret = false;
    935 		goto out;
    936 	}
    937 
    938 	page = pud_page(pud);
    939 	if (!page) {
    940 		ret = true;
    941 		goto out;
    942 	}
    943 
    944 	folio = page_folio(page);
--> 945 	ret = relocate_large_folio(pmc, old_addr, new_addr, folio, undo);
                      ^^^^^^^^^^^^^^^^^^^^
This is a sleeping function because it takes the folio_lock().

    946 
    947 out:
    948 	spin_unlock(ptl);

but we're holding a spinlock so we're not allowed to sleep.

    949 	return ret;
    950 }

regards,
dan carpenter


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

* Re: [bug report] mm/mremap: add MREMAP[_MUST]_RELOCATE_ANON support for large folios
  2025-06-25 15:22 [bug report] mm/mremap: add MREMAP[_MUST]_RELOCATE_ANON support for large folios Dan Carpenter
@ 2025-06-25 15:30 ` Lorenzo Stoakes
  0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Stoakes @ 2025-06-25 15:30 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-mm

On Wed, Jun 25, 2025 at 10:22:02AM -0500, Dan Carpenter wrote:
> Hello Lorenzo Stoakes,
>
> The patch a7fc0d8bd77d: "mm/mremap: add MREMAP[_MUST]_RELOCATE_ANON
> support for large folios" from Jun 9, 2025, leads to the following
> static checker warning:
>
> mm/mremap.c:945 relocate_anon_pud() warn: sleeping in atomic context
> mm/mremap.c:989 relocate_anon_pmd() warn: sleeping in atomic context
>
> mm/mremap.c
>     910 static bool relocate_anon_pud(struct pagetable_move_control *pmc,
>     911 		pud_t *pudp, bool undo)
>     912 {
>     913 	spinlock_t *ptl;
>     914 	pud_t pud;
>     915 	struct folio *folio;
>     916 	struct page *page;
>     917 	bool ret;
>     918 	unsigned long old_addr = pmc->old_addr;
>     919 	unsigned long new_addr = pmc->new_addr;
>     920
>     921 	VM_WARN_ON(old_addr & ~HPAGE_PUD_MASK);
>     922 	VM_WARN_ON(new_addr & ~HPAGE_PUD_MASK);
>     923
>     924 	ptl = pud_trans_huge_lock(pudp, pmc->old);
>     925 	if (!ptl)
>     926 		return false;
>     927
>     928 	pud = pudp_get(pudp);
>     929 	if (!pud_present(pud)) {
>     930 		ret = true;
>     931 		goto out;
>     932 	}
>     933 	if (!pud_leaf(pud)) {
>     934 		ret = false;
>     935 		goto out;
>     936 	}
>     937
>     938 	page = pud_page(pud);
>     939 	if (!page) {
>     940 		ret = true;
>     941 		goto out;
>     942 	}
>     943
>     944 	folio = page_folio(page);
> --> 945 	ret = relocate_large_folio(pmc, old_addr, new_addr, folio, undo);
>                       ^^^^^^^^^^^^^^^^^^^^
> This is a sleeping function because it takes the folio_lock().
>
>     946
>     947 out:
>     948 	spin_unlock(ptl);
>
> but we're holding a spinlock so we're not allowed to sleep.

Yeah, agreed, this is broken.

Am working on a major respin that will address this issue.

Thanks for the report!

>
>     949 	return ret;
>     950 }
>
> regards,
> dan carpenter
>


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

end of thread, other threads:[~2025-06-25 15:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-25 15:22 [bug report] mm/mremap: add MREMAP[_MUST]_RELOCATE_ANON support for large folios Dan Carpenter
2025-06-25 15:30 ` Lorenzo Stoakes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox