# \[PATCH v4 01/14\] memory-failure: fetch compound\_head after pgmap\_pfn\_valid()

- From: Joao Martins \<hidden\>
- Date: 2021-08-27 14:59:25 
- List: linux-doc
- Page: https://ratatoskr.run/linux-doc/2021/08/6510544
- Thread: https://ratatoskr.run/linux-mm/2021/08/6510545/t.md

```text
memory_failure_dev_pagemap() at the moment assumes base pages (e.g.
dax_lock_page()).  For devmap with compound pages fetch the
compound_head in case a tail page memory failure is being handled.

Currently this is a nop, but in the advent of compound pages in
dev_pagemap it allows memory_failure_dev_pagemap() to keep working.

Reported-by: Jane Chu <redacted>
Signed-off-by: Joao Martins <redacted>
Reviewed-by: Naoya Horiguchi <redacted>
Reviewed-by: Dan Williams <redacted>
Reviewed-by: Muchun Song <redacted>
---
 mm/memory-failure.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 60df8fcd0444..beee19a5aa0f 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1538,6 +1538,12 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags,
 		goto out;
 	}
 
+	/*
+	 * Pages instantiated by device-dax (not filesystem-dax)
+	 * may be compound pages.
+	 */
+	page = compound_head(page);
+
 	/*
 	 * Prevent the inode from being freed while we are interrogating
 	 * the address_space, typically this would be handled by
-- 
2.17.1

```
