diff mbox series

[2/2] mm: Remove a call to compound_head() from is_page_hwpoison()

Message ID 20240314012506.1600378-3-willy@infradead.org (mailing list archive)
State New
Headers show
Series Reliable testing for hugetlb | expand

Commit Message

Matthew Wilcox March 14, 2024, 1:25 a.m. UTC
We can call it only once instead of twice.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/page-flags.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

David Hildenbrand March 14, 2024, 10:26 a.m. UTC | #1
On 14.03.24 02:25, Matthew Wilcox (Oracle) wrote:
> We can call it only once instead of twice.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   include/linux/page-flags.h | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 6ebb573c7195..f1d65a72b378 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -1017,9 +1017,12 @@ static inline bool PageHuge(struct page *page)
>    */
>   static inline bool is_page_hwpoison(struct page *page)
>   {
> +	struct folio *folio;
> +
>   	if (PageHWPoison(page))
>   		return true;
> -	return PageHuge(page) && PageHWPoison(compound_head(page));
> +	folio = page_folio(page);
> +	return folio_test_hugetlb(folio) && PageHWPoison(&folio->page);
>   }
>   
>   extern bool is_free_buddy_page(struct page *page);

Reviewed-by: David Hildenbrand <david@redhat.com>
Miaohe Lin March 15, 2024, 6:38 a.m. UTC | #2
On 2024/3/14 9:25, Matthew Wilcox (Oracle) wrote:
> We can call it only once instead of twice.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

Thanks.

> ---
>  include/linux/page-flags.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 6ebb573c7195..f1d65a72b378 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -1017,9 +1017,12 @@ static inline bool PageHuge(struct page *page)
>   */
>  static inline bool is_page_hwpoison(struct page *page)
>  {
> +	struct folio *folio;
> +
>  	if (PageHWPoison(page))
>  		return true;
> -	return PageHuge(page) && PageHWPoison(compound_head(page));
> +	folio = page_folio(page);
> +	return folio_test_hugetlb(folio) && PageHWPoison(&folio->page);
>  }
>  
>  extern bool is_free_buddy_page(struct page *page);
>
diff mbox series

Patch

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 6ebb573c7195..f1d65a72b378 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -1017,9 +1017,12 @@  static inline bool PageHuge(struct page *page)
  */
 static inline bool is_page_hwpoison(struct page *page)
 {
+	struct folio *folio;
+
 	if (PageHWPoison(page))
 		return true;
-	return PageHuge(page) && PageHWPoison(compound_head(page));
+	folio = page_folio(page);
+	return folio_test_hugetlb(folio) && PageHWPoison(&folio->page);
 }
 
 extern bool is_free_buddy_page(struct page *page);