diff mbox series

[2/6] mm: memory: use a folio in validate_page_before_insert()

Message ID 20231107135216.415926-3-wangkefeng.wang@huawei.com (mailing list archive)
State New
Headers show
Series mm: cleanup and use more folio in page fault | expand

Commit Message

Kefeng Wang Nov. 7, 2023, 1:52 p.m. UTC
Use a folio in validate_page_before_insert() to save two
compound_head() calls.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/memory.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Sidhartha Kumar Nov. 7, 2023, 6:17 p.m. UTC | #1
On 11/7/23 5:52 AM, Kefeng Wang wrote:
> Use a folio in validate_page_before_insert() to save two
> compound_head() calls.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>   mm/memory.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/memory.c b/mm/memory.c
> index 1f18ed4a5497..b1bff4d245da 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1836,9 +1836,12 @@ pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
>   
>   static int validate_page_before_insert(struct page *page)
>   {
> -	if (PageAnon(page) || PageSlab(page) || page_has_type(page))
> +	struct folio *folio = page_folio(page);
> +
> +	if (folio_test_anon(folio) || folio_test_slab(folio) ||
> +	    page_has_type(page))
>   		return -EINVAL;
> -	flush_dcache_page(page);
> +	flush_dcache_folio(folio);
>   	return 0;
>   }
>   
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
diff mbox series

Patch

diff --git a/mm/memory.c b/mm/memory.c
index 1f18ed4a5497..b1bff4d245da 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1836,9 +1836,12 @@  pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
 
 static int validate_page_before_insert(struct page *page)
 {
-	if (PageAnon(page) || PageSlab(page) || page_has_type(page))
+	struct folio *folio = page_folio(page);
+
+	if (folio_test_anon(folio) || folio_test_slab(folio) ||
+	    page_has_type(page))
 		return -EINVAL;
-	flush_dcache_page(page);
+	flush_dcache_folio(folio);
 	return 0;
 }