* [PATCH] mm/hugetlb: fix hugetlbfs_pagecache_present()
@ 2023-06-23 6:26 Dan Carpenter
2023-06-23 6:37 ` Sidhartha Kumar
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-06-23 6:26 UTC (permalink / raw)
To: Mike Kravetz
Cc: Muchun Song, Andrew Morton, Sidhartha Kumar, linux-mm,
kernel-janitors
The filemap_get_folio() function doesn't returns NULL, it returns error
pointers. So the "return folio != NULL;" statement means
hugetlbfs_pagecache_present() always returns true.
Fixes: 267d6792f43b ("hugetlb: revert use of page_cache_next_miss()")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
mm/hugetlb.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index cb9077b96b43..bce28cca73a1 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5731,9 +5731,10 @@ static bool hugetlbfs_pagecache_present(struct hstate *h,
struct folio *folio;
folio = filemap_get_folio(mapping, idx);
- if (!IS_ERR(folio))
- folio_put(folio);
- return folio != NULL;
+ if (IS_ERR(folio))
+ return false;
+ folio_put(folio);
+ return true;
}
int hugetlb_add_to_page_cache(struct folio *folio, struct address_space *mapping,
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/hugetlb: fix hugetlbfs_pagecache_present()
2023-06-23 6:26 [PATCH] mm/hugetlb: fix hugetlbfs_pagecache_present() Dan Carpenter
@ 2023-06-23 6:37 ` Sidhartha Kumar
2023-06-27 9:48 ` David Hildenbrand
2023-07-03 18:58 ` Mike Kravetz
2 siblings, 0 replies; 4+ messages in thread
From: Sidhartha Kumar @ 2023-06-23 6:37 UTC (permalink / raw)
To: Dan Carpenter, Mike Kravetz
Cc: Muchun Song, Andrew Morton, linux-mm, kernel-janitors
On 6/22/23 11:26 PM, Dan Carpenter wrote:
> The filemap_get_folio() function doesn't returns NULL, it returns error
> pointers. So the "return folio != NULL;" statement means
> hugetlbfs_pagecache_present() always returns true.
>
> Fixes: 267d6792f43b ("hugetlb: revert use of page_cache_next_miss()")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> mm/hugetlb.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index cb9077b96b43..bce28cca73a1 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5731,9 +5731,10 @@ static bool hugetlbfs_pagecache_present(struct hstate *h,
> struct folio *folio;
>
> folio = filemap_get_folio(mapping, idx);
> - if (!IS_ERR(folio))
> - folio_put(folio);
> - return folio != NULL;
> + if (IS_ERR(folio))
> + return false;
> + folio_put(folio);
> + return true;
> }
>
> int hugetlb_add_to_page_cache(struct folio *folio, struct address_space *mapping,
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/hugetlb: fix hugetlbfs_pagecache_present()
2023-06-23 6:26 [PATCH] mm/hugetlb: fix hugetlbfs_pagecache_present() Dan Carpenter
2023-06-23 6:37 ` Sidhartha Kumar
@ 2023-06-27 9:48 ` David Hildenbrand
2023-07-03 18:58 ` Mike Kravetz
2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2023-06-27 9:48 UTC (permalink / raw)
To: Dan Carpenter, Mike Kravetz
Cc: Muchun Song, Andrew Morton, Sidhartha Kumar, linux-mm,
kernel-janitors
On 23.06.23 08:26, Dan Carpenter wrote:
> The filemap_get_folio() function doesn't returns NULL, it returns error
> pointers. So the "return folio != NULL;" statement means
> hugetlbfs_pagecache_present() always returns true.
>
> Fixes: 267d6792f43b ("hugetlb: revert use of page_cache_next_miss()")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> mm/hugetlb.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index cb9077b96b43..bce28cca73a1 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5731,9 +5731,10 @@ static bool hugetlbfs_pagecache_present(struct hstate *h,
> struct folio *folio;
>
> folio = filemap_get_folio(mapping, idx);
> - if (!IS_ERR(folio))
> - folio_put(folio);
> - return folio != NULL;
> + if (IS_ERR(folio))
> + return false;
> + folio_put(folio);
> + return true;
> }
>
> int hugetlb_add_to_page_cache(struct folio *folio, struct address_space *mapping,
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/hugetlb: fix hugetlbfs_pagecache_present()
2023-06-23 6:26 [PATCH] mm/hugetlb: fix hugetlbfs_pagecache_present() Dan Carpenter
2023-06-23 6:37 ` Sidhartha Kumar
2023-06-27 9:48 ` David Hildenbrand
@ 2023-07-03 18:58 ` Mike Kravetz
2 siblings, 0 replies; 4+ messages in thread
From: Mike Kravetz @ 2023-07-03 18:58 UTC (permalink / raw)
To: Dan Carpenter
Cc: Muchun Song, Andrew Morton, Sidhartha Kumar, linux-mm,
kernel-janitors
On 06/23/23 09:26, Dan Carpenter wrote:
> The filemap_get_folio() function doesn't returns NULL, it returns error
> pointers. So the "return folio != NULL;" statement means
> hugetlbfs_pagecache_present() always returns true.
>
> Fixes: 267d6792f43b ("hugetlb: revert use of page_cache_next_miss()")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> mm/hugetlb.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index cb9077b96b43..bce28cca73a1 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5731,9 +5731,10 @@ static bool hugetlbfs_pagecache_present(struct hstate *h,
> struct folio *folio;
>
> folio = filemap_get_folio(mapping, idx);
> - if (!IS_ERR(folio))
> - folio_put(folio);
> - return folio != NULL;
> + if (IS_ERR(folio))
> + return false;
> + folio_put(folio);
> + return true;
> }
Thank you Dan!
I noted the changed behavior of filemap_get_folio in the commit message
and still missed that comparison to NULL. :(
--
Mike Kravetz
>
> int hugetlb_add_to_page_cache(struct folio *folio, struct address_space *mapping,
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-03 18:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-23 6:26 [PATCH] mm/hugetlb: fix hugetlbfs_pagecache_present() Dan Carpenter
2023-06-23 6:37 ` Sidhartha Kumar
2023-06-27 9:48 ` David Hildenbrand
2023-07-03 18:58 ` Mike Kravetz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).