diff mbox series

[v3,2/4] mm: don't account memmap on failure

Message ID 20240808154237.220029-3-pasha.tatashin@soleen.com
State Superseded
Headers show
Series Fixes for memmap accounting | expand

Commit Message

Pasha Tatashin Aug. 8, 2024, 3:42 p.m. UTC
When in alloc_vmemmap_page_list() memmap is failed to allocate, do
not account, the memory is going to be release at the function exit.

Fixes: 15995a352474 ("mm: report per-page metadata information")
Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
---
 mm/hugetlb_vmemmap.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Yosry Ahmed Aug. 8, 2024, 5:18 p.m. UTC | #1
On Thu, Aug 8, 2024 at 8:42 AM Pasha Tatashin <pasha.tatashin@soleen.com> wrote:
>
> When in alloc_vmemmap_page_list() memmap is failed to allocate, do
> not account, the memory is going to be release at the function exit.
>
> Fixes: 15995a352474 ("mm: report per-page metadata information")
> Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>

Reviewed-by: Yosry Ahmed <yosryahmed@google.com>

> ---
>  mm/hugetlb_vmemmap.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
> index fa83a7b38199..70027869d844 100644
> --- a/mm/hugetlb_vmemmap.c
> +++ b/mm/hugetlb_vmemmap.c
> @@ -392,13 +392,10 @@ static int alloc_vmemmap_page_list(unsigned long start, unsigned long end,
>
>         for (i = 0; i < nr_pages; i++) {
>                 page = alloc_pages_node(nid, gfp_mask, 0);
> -               if (!page) {
> -                       mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, i);
> +               if (!page)
>                         goto out;
> -               }
>                 list_add(&page->lru, list);
>         }
> -
>         mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, nr_pages);
>
>         return 0;
> --
> 2.46.0.76.ge559c4bf1a-goog
>
Fan Ni Aug. 8, 2024, 5:19 p.m. UTC | #2
On Thu, Aug 08, 2024 at 03:42:35PM +0000, Pasha Tatashin wrote:
> When in alloc_vmemmap_page_list() memmap is failed to allocate, do
> not account, the memory is going to be release at the function exit.
> 
> Fixes: 15995a352474 ("mm: report per-page metadata information")
> Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
> ---

Reviewed-by: Fan Ni <fan.ni@samsung.com>

>  mm/hugetlb_vmemmap.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
> index fa83a7b38199..70027869d844 100644
> --- a/mm/hugetlb_vmemmap.c
> +++ b/mm/hugetlb_vmemmap.c
> @@ -392,13 +392,10 @@ static int alloc_vmemmap_page_list(unsigned long start, unsigned long end,
>  
>  	for (i = 0; i < nr_pages; i++) {
>  		page = alloc_pages_node(nid, gfp_mask, 0);
> -		if (!page) {
> -			mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, i);
> +		if (!page)
>  			goto out;
> -		}
>  		list_add(&page->lru, list);
>  	}
> -
>  	mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, nr_pages);
>  
>  	return 0;
> -- 
> 2.46.0.76.ge559c4bf1a-goog
>
David Hildenbrand Aug. 8, 2024, 6:12 p.m. UTC | #3
On 08.08.24 17:42, Pasha Tatashin wrote:
> When in alloc_vmemmap_page_list() memmap is failed to allocate, do
> not account, the memory is going to be release at the function exit.

I would write it as

"When we fail to allocate the mmemmap in alloc_vmemmap_page_list(), do 
not account any already-allocated pages: we're going to free all them 
before we return from the function."

Acked-by: David Hildenbrand <david@redhat.com>

> 
> Fixes: 15995a352474 ("mm: report per-page metadata information")
> Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
> ---
>   mm/hugetlb_vmemmap.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
> index fa83a7b38199..70027869d844 100644
> --- a/mm/hugetlb_vmemmap.c
> +++ b/mm/hugetlb_vmemmap.c
> @@ -392,13 +392,10 @@ static int alloc_vmemmap_page_list(unsigned long start, unsigned long end,
>   
>   	for (i = 0; i < nr_pages; i++) {
>   		page = alloc_pages_node(nid, gfp_mask, 0);
> -		if (!page) {
> -			mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, i);
> +		if (!page)
>   			goto out;
> -		}
>   		list_add(&page->lru, list);
>   	}
> -
>   	mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, nr_pages);
>   
>   	return 0;
Pasha Tatashin Aug. 8, 2024, 6:54 p.m. UTC | #4
On Thu, Aug 8, 2024 at 2:12 PM David Hildenbrand <david@redhat.com> wrote:
>
> On 08.08.24 17:42, Pasha Tatashin wrote:
> > When in alloc_vmemmap_page_list() memmap is failed to allocate, do
> > not account, the memory is going to be release at the function exit.
>
> I would write it as
>
> "When we fail to allocate the mmemmap in alloc_vmemmap_page_list(), do
> not account any already-allocated pages: we're going to free all them
> before we return from the function."
>

Will change.

> Acked-by: David Hildenbrand <david@redhat.com>

Thank you,
Pasha

>
> >
> > Fixes: 15995a352474 ("mm: report per-page metadata information")
> > Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
> > ---
> >   mm/hugetlb_vmemmap.c | 5 +----
> >   1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
> > index fa83a7b38199..70027869d844 100644
> > --- a/mm/hugetlb_vmemmap.c
> > +++ b/mm/hugetlb_vmemmap.c
> > @@ -392,13 +392,10 @@ static int alloc_vmemmap_page_list(unsigned long start, unsigned long end,
> >
> >       for (i = 0; i < nr_pages; i++) {
> >               page = alloc_pages_node(nid, gfp_mask, 0);
> > -             if (!page) {
> > -                     mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, i);
> > +             if (!page)
> >                       goto out;
> > -             }
> >               list_add(&page->lru, list);
> >       }
> > -
> >       mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, nr_pages);
> >
> >       return 0;
>
> --
> Cheers,
>
> David / dhildenb
>
diff mbox series

Patch

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index fa83a7b38199..70027869d844 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -392,13 +392,10 @@  static int alloc_vmemmap_page_list(unsigned long start, unsigned long end,
 
 	for (i = 0; i < nr_pages; i++) {
 		page = alloc_pages_node(nid, gfp_mask, 0);
-		if (!page) {
-			mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, i);
+		if (!page)
 			goto out;
-		}
 		list_add(&page->lru, list);
 	}
-
 	mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, nr_pages);
 
 	return 0;