2022-01-17 06:55:36

by Matthew Wilcox

[permalink] [raw]
Subject: [PATCH 09/12] mm/readahead: Align file mappings for non-DAX

From: William Kucharski <[email protected]>

When we have the opportunity to use PMDs to map a file, we want to follow
the same rules as DAX.

Signed-off-by: William Kucharski <[email protected]>
Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
---
mm/huge_memory.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index f58524394dc1..28c29a0d854b 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -582,13 +582,10 @@ unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long ret;
loff_t off = (loff_t)pgoff << PAGE_SHIFT;

- if (!IS_DAX(filp->f_mapping->host) || !IS_ENABLED(CONFIG_FS_DAX_PMD))
- goto out;
-
ret = __thp_get_unmapped_area(filp, addr, len, off, flags, PMD_SIZE);
if (ret)
return ret;
-out:
+
return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
}
EXPORT_SYMBOL_GPL(thp_get_unmapped_area);
--
2.34.1


2022-01-17 11:57:34

by Rongwei Wang

[permalink] [raw]
Subject: Re: [PATCH 09/12] mm/readahead: Align file mappings for non-DAX



On 1/16/22 8:18 PM, Matthew Wilcox (Oracle) wrote:
> From: William Kucharski <[email protected]>
>
> When we have the opportunity to use PMDs to map a file, we want to follow
> the same rules as DAX.
>
> Signed-off-by: William Kucharski <[email protected]>
> Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
> ---
> mm/huge_memory.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index f58524394dc1..28c29a0d854b 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -582,13 +582,10 @@ unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr,
> unsigned long ret;
> loff_t off = (loff_t)pgoff << PAGE_SHIFT;
>
> - if (!IS_DAX(filp->f_mapping->host) || !IS_ENABLED(CONFIG_FS_DAX_PMD))
> - goto out;
> -
> ret = __thp_get_unmapped_area(filp, addr, len, off, flags, PMD_SIZE);
> if (ret)
> return ret;
> -out:
> +
> return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
Hi, Matthew

It seems this patch will make all file mappings align with PMD_SIZE? And
support realize all file THP, not only executable file THP?

Actually, what I want to say is we had merged a similar patch to only
align DSO mapping in glibc:

"718fdd8 elf: Properly align PT_LOAD segments [BZ #28676]"


> }
> EXPORT_SYMBOL_GPL(thp_get_unmapped_area);

2022-01-17 12:41:44

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [PATCH 09/12] mm/readahead: Align file mappings for non-DAX

On Mon, Jan 17, 2022 at 11:17:55AM +0800, Rongwei Wang wrote:
> It seems this patch will make all file mappings align with PMD_SIZE?

Only those which are big enough. See __thp_get_unmapped_area():

if (off_end <= off_align || (off_end - off_align) < size)
return 0;

> And
> support realize all file THP, not only executable file THP?

Executables are not the only files which benefit from being mapped
to an aligned address. If you can use a PMD to map a font file,
for example, that's valuable.