2021-10-27 11:41:51

by Mike Kravetz

[permalink] [raw]
Subject: [PATCH] hugetlb: remove unnecessary set_page_count in prep_compound_gigantic_page

In commit 7118fc2906e29 ("hugetlb: address ref count racing in
prep_compound_gigantic_page"), page_ref_freeze is used to atomically
zero the ref count of tail pages iff they are 1. The unconditional
call to set_page_count(0) was left in the code. This call is after
page_ref_freeze so it is really a noop.

Remove redundant and unnecessary set_page_count call.

Fixes: 7118fc2906e29 ("hugetlb: address ref count racing in prep_compound_gigantic_page")
Suggested-by: Pasha Tatashin <[email protected]>
Signed-off-by: Mike Kravetz <[email protected]>
---
mm/hugetlb.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 906fe8a3b93d..88047a367080 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1795,7 +1795,6 @@ static bool __prep_compound_gigantic_page(struct page *page, unsigned int order,
} else {
VM_BUG_ON_PAGE(page_count(p), p);
}
- set_page_count(p, 0);
set_compound_head(p, page);
}
atomic_set(compound_mapcount_ptr(page), -1);
--
2.31.1


2021-10-27 12:31:18

by Pasha Tatashin

[permalink] [raw]
Subject: Re: [PATCH] hugetlb: remove unnecessary set_page_count in prep_compound_gigantic_page

On Tue, Oct 26, 2021 at 6:06 PM Mike Kravetz <[email protected]> wrote:
>
> In commit 7118fc2906e29 ("hugetlb: address ref count racing in
> prep_compound_gigantic_page"), page_ref_freeze is used to atomically
> zero the ref count of tail pages iff they are 1. The unconditional
> call to set_page_count(0) was left in the code. This call is after
> page_ref_freeze so it is really a noop.
>
> Remove redundant and unnecessary set_page_count call.
>
> Fixes: 7118fc2906e29 ("hugetlb: address ref count racing in prep_compound_gigantic_page")
> Suggested-by: Pasha Tatashin <[email protected]>
> Signed-off-by: Mike Kravetz <[email protected]>

Reviewed-by: Pasha Tatashin <[email protected]>

Thanks,
Pasha

2021-10-27 13:27:25

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [PATCH] hugetlb: remove unnecessary set_page_count in prep_compound_gigantic_page

On Tue, Oct 26, 2021 at 03:06:35PM -0700, Mike Kravetz wrote:
> In commit 7118fc2906e29 ("hugetlb: address ref count racing in
> prep_compound_gigantic_page"), page_ref_freeze is used to atomically
> zero the ref count of tail pages iff they are 1. The unconditional
> call to set_page_count(0) was left in the code. This call is after
> page_ref_freeze so it is really a noop.
>
> Remove redundant and unnecessary set_page_count call.
>
> Fixes: 7118fc2906e29 ("hugetlb: address ref count racing in prep_compound_gigantic_page")
> Suggested-by: Pasha Tatashin <[email protected]>
> Signed-off-by: Mike Kravetz <[email protected]>

Reviewed-by: Matthew Wilcox (Oracle) <[email protected]>

2021-10-27 18:00:46

by Oscar Salvador

[permalink] [raw]
Subject: Re: [PATCH] hugetlb: remove unnecessary set_page_count in prep_compound_gigantic_page

On Tue, Oct 26, 2021 at 03:06:35PM -0700, Mike Kravetz wrote:
> In commit 7118fc2906e29 ("hugetlb: address ref count racing in
> prep_compound_gigantic_page"), page_ref_freeze is used to atomically
> zero the ref count of tail pages iff they are 1. The unconditional
> call to set_page_count(0) was left in the code. This call is after
> page_ref_freeze so it is really a noop.
>
> Remove redundant and unnecessary set_page_count call.
>
> Fixes: 7118fc2906e29 ("hugetlb: address ref count racing in prep_compound_gigantic_page")
> Suggested-by: Pasha Tatashin <[email protected]>
> Signed-off-by: Mike Kravetz <[email protected]>

Reviewed-by: Oscar Salvador <[email protected]>

> ---
> mm/hugetlb.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 906fe8a3b93d..88047a367080 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1795,7 +1795,6 @@ static bool __prep_compound_gigantic_page(struct page *page, unsigned int order,
> } else {
> VM_BUG_ON_PAGE(page_count(p), p);
> }
> - set_page_count(p, 0);
> set_compound_head(p, page);
> }
> atomic_set(compound_mapcount_ptr(page), -1);
> --
> 2.31.1
>
>

--
Oscar Salvador
SUSE Labs

2021-10-27 18:36:06

by Muchun Song

[permalink] [raw]
Subject: Re: [PATCH] hugetlb: remove unnecessary set_page_count in prep_compound_gigantic_page

On Wed, Oct 27, 2021 at 6:06 AM Mike Kravetz <[email protected]> wrote:
>
> In commit 7118fc2906e29 ("hugetlb: address ref count racing in
> prep_compound_gigantic_page"), page_ref_freeze is used to atomically
> zero the ref count of tail pages iff they are 1. The unconditional
> call to set_page_count(0) was left in the code. This call is after
> page_ref_freeze so it is really a noop.
>
> Remove redundant and unnecessary set_page_count call.
>
> Fixes: 7118fc2906e29 ("hugetlb: address ref count racing in prep_compound_gigantic_page")
> Suggested-by: Pasha Tatashin <[email protected]>
> Signed-off-by: Mike Kravetz <[email protected]>

Reviewed-by: Muchun Song <[email protected]>

Thanks.