2022-01-17 11:56:34

by Baolin Wang

[permalink] [raw]
Subject: [PATCH v2] mm/damon: Remove redundant page validation

It will never get a NULL page by pte_page() as discussed in thread [1],
thus remove the redundant page validation to fix below Smatch static
checker warning.

mm/damon/vaddr.c:405 damon_hugetlb_mkold()
warn: 'page' can't be NULL.

[1] https://lore.kernel.org/linux-mm/20220106091200.GA14564@kili/

Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Baolin Wang <[email protected]>
Reviewed-by: SeongJae Park <[email protected]>
---
Changes from v1:
- Improve the commit message suggested by SeongJae.
- Add reviewed-by tag from SeongJae.
---
mm/damon/vaddr.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index 89b6468d..8a52e00 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -402,9 +402,6 @@ static void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
pte_t entry = huge_ptep_get(pte);
struct page *page = pte_page(entry);

- if (!page)
- return;
-
get_page(page);

if (pte_young(entry)) {
@@ -564,9 +561,6 @@ static int damon_young_hugetlb_entry(pte_t *pte, unsigned long hmask,
goto out;

page = pte_page(entry);
- if (!page)
- goto out;
-
get_page(page);

if (pte_young(entry) || !page_is_idle(page) ||
--
1.8.3.1


2022-01-24 19:52:15

by David Rientjes

[permalink] [raw]
Subject: Re: [PATCH v2] mm/damon: Remove redundant page validation

On Mon, 17 Jan 2022, Baolin Wang wrote:

> It will never get a NULL page by pte_page() as discussed in thread [1],
> thus remove the redundant page validation to fix below Smatch static
> checker warning.
>
> mm/damon/vaddr.c:405 damon_hugetlb_mkold()
> warn: 'page' can't be NULL.
>
> [1] https://lore.kernel.org/linux-mm/20220106091200.GA14564@kili/
>
> Reported-by: Dan Carpenter <[email protected]>
> Signed-off-by: Baolin Wang <[email protected]>
> Reviewed-by: SeongJae Park <[email protected]>

Acked-by: David Rientjes <[email protected]>

2022-01-25 08:55:37

by Souptick Joarder

[permalink] [raw]
Subject: Re: [PATCH v2] mm/damon: Remove redundant page validation

On Mon, Jan 24, 2022 at 11:50 PM David Rientjes <[email protected]> wrote:
>
> On Mon, 17 Jan 2022, Baolin Wang wrote:
>
> > It will never get a NULL page by pte_page() as discussed in thread [1],
> > thus remove the redundant page validation to fix below Smatch static
> > checker warning.
> >
> > mm/damon/vaddr.c:405 damon_hugetlb_mkold()
> > warn: 'page' can't be NULL.
> >
> > [1] https://lore.kernel.org/linux-mm/20220106091200.GA14564@kili/
> >
> > Reported-by: Dan Carpenter <[email protected]>
> > Signed-off-by: Baolin Wang <[email protected]>
> > Reviewed-by: SeongJae Park <[email protected]>
>
> Acked-by: David Rientjes <[email protected]>

Acked-by: Souptick Joarder <[email protected]>

>

2022-01-25 09:12:48

by Miaohe Lin

[permalink] [raw]
Subject: Re: [PATCH v2] mm/damon: Remove redundant page validation

On 2022/1/17 10:34, Baolin Wang wrote:
> It will never get a NULL page by pte_page() as discussed in thread [1],
> thus remove the redundant page validation to fix below Smatch static
> checker warning.
>
> mm/damon/vaddr.c:405 damon_hugetlb_mkold()
> warn: 'page' can't be NULL.
>
> [1] https://lore.kernel.org/linux-mm/20220106091200.GA14564@kili/
>
> Reported-by: Dan Carpenter <[email protected]>
> Signed-off-by: Baolin Wang <[email protected]>
> Reviewed-by: SeongJae Park <[email protected]>

LGTM. Thanks.

Reviewed-by: Miaohe Lin <[email protected]>

> ---
> Changes from v1:
> - Improve the commit message suggested by SeongJae.
> - Add reviewed-by tag from SeongJae.
> ---
> mm/damon/vaddr.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index 89b6468d..8a52e00 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c
> @@ -402,9 +402,6 @@ static void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
> pte_t entry = huge_ptep_get(pte);
> struct page *page = pte_page(entry);
>
> - if (!page)
> - return;
> -
> get_page(page);
>
> if (pte_young(entry)) {
> @@ -564,9 +561,6 @@ static int damon_young_hugetlb_entry(pte_t *pte, unsigned long hmask,
> goto out;
>
> page = pte_page(entry);
> - if (!page)
> - goto out;
> -
> get_page(page);
>
> if (pte_young(entry) || !page_is_idle(page) ||
>