* [RFC] Free the reserved memblock when free cma pages
@ 2014-09-09 6:13 Wang, Yalin
2014-09-10 8:18 ` Michal Hocko
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Wang, Yalin @ 2014-09-09 6:13 UTC (permalink / raw)
To: 'mhocko@suse.cz', 'linux-mm@kvack.org',
'akpm@linux-foundation.org',
mm-commits, hughd, b.zolnierkie
This patch add memblock_free to also free the reserved memblock,
so that the cma pages are not marked as reserved memory in
/sys/kernel/debug/memblock/reserved debug file
Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
---
mm/cma.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/cma.c b/mm/cma.c
index c17751c..f3ec756 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -114,6 +114,8 @@ static int __init cma_activate_area(struct cma *cma)
goto err;
}
init_cma_reserved_pageblock(pfn_to_page(base_pfn));
+ memblock_free(__pfn_to_phys(base_pfn),
+ pageblock_nr_pages * PAGE_SIZE);
} while (--i);
mutex_init(&cma->lock);
--
2.1.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [RFC] Free the reserved memblock when free cma pages
2014-09-09 6:13 [RFC] Free the reserved memblock when free cma pages Wang, Yalin
@ 2014-09-10 8:18 ` Michal Hocko
2014-09-10 9:02 ` Wang, Yalin
2014-09-12 9:35 ` Marek Szyprowski
2014-09-15 5:21 ` Minchan Kim
2 siblings, 1 reply; 12+ messages in thread
From: Michal Hocko @ 2014-09-10 8:18 UTC (permalink / raw)
To: Wang, Yalin
Cc: 'linux-mm@kvack.org', 'akpm@linux-foundation.org',
mm-commits, hughd, b.zolnierkie
On Tue 09-09-14 14:13:58, Wang, Yalin wrote:
> This patch add memblock_free to also free the reserved memblock,
> so that the cma pages are not marked as reserved memory in
> /sys/kernel/debug/memblock/reserved debug file
Why and is this even correct? init_cma_reserved_pageblock seems to be
doing __ClearPageReserved on each page in the page block.
> Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
> ---
> mm/cma.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/cma.c b/mm/cma.c
> index c17751c..f3ec756 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -114,6 +114,8 @@ static int __init cma_activate_area(struct cma *cma)
> goto err;
> }
> init_cma_reserved_pageblock(pfn_to_page(base_pfn));
> + memblock_free(__pfn_to_phys(base_pfn),
> + pageblock_nr_pages * PAGE_SIZE);
> } while (--i);
>
> mutex_init(&cma->lock);
> --
> 2.1.0
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [RFC] Free the reserved memblock when free cma pages
2014-09-10 8:18 ` Michal Hocko
@ 2014-09-10 9:02 ` Wang, Yalin
0 siblings, 0 replies; 12+ messages in thread
From: Wang, Yalin @ 2014-09-10 9:02 UTC (permalink / raw)
To: 'Michal Hocko'
Cc: 'linux-mm@kvack.org', 'akpm@linux-foundation.org',
mm-commits, hughd, b.zolnierkie
Hi
Yeah, the __ClearPageReserved flag is cleared for each page,
But the memblock still mark these physical address as marked,
Then if you cat /sys/kernel/debug/memblock/reserved
You can still see these physical address are marked as reserved,
This is not correct,
This is because cma_activate_area function release the pages after
Boot_mem free, so we have to free the memblock by ourselves,
The same problem also reside for initrd reserved memory.
-----Original Message-----
From: Michal Hocko [mailto:mstsxfx@gmail.com] On Behalf Of Michal Hocko
Sent: Wednesday, September 10, 2014 4:18 PM
To: Wang, Yalin
Cc: 'linux-mm@kvack.org'; 'akpm@linux-foundation.org'; mm-commits@vger.kernel.org; hughd@google.com; b.zolnierkie@samsung.com
Subject: Re: [RFC] Free the reserved memblock when free cma pages
On Tue 09-09-14 14:13:58, Wang, Yalin wrote:
> This patch add memblock_free to also free the reserved memblock, so
> that the cma pages are not marked as reserved memory in
> /sys/kernel/debug/memblock/reserved debug file
Why and is this even correct? init_cma_reserved_pageblock seems to be doing __ClearPageReserved on each page in the page block.
> Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
> ---
> mm/cma.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/cma.c b/mm/cma.c
> index c17751c..f3ec756 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -114,6 +114,8 @@ static int __init cma_activate_area(struct cma *cma)
> goto err;
> }
> init_cma_reserved_pageblock(pfn_to_page(base_pfn));
> + memblock_free(__pfn_to_phys(base_pfn),
> + pageblock_nr_pages * PAGE_SIZE);
> } while (--i);
>
> mutex_init(&cma->lock);
> --
> 2.1.0
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Free the reserved memblock when free cma pages
2014-09-09 6:13 [RFC] Free the reserved memblock when free cma pages Wang, Yalin
2014-09-10 8:18 ` Michal Hocko
@ 2014-09-12 9:35 ` Marek Szyprowski
2014-09-15 3:06 ` Joonsoo Kim
2014-09-15 5:21 ` Minchan Kim
2 siblings, 1 reply; 12+ messages in thread
From: Marek Szyprowski @ 2014-09-12 9:35 UTC (permalink / raw)
To: Wang, Yalin, 'mhocko@suse.cz',
'linux-mm@kvack.org', 'akpm@linux-foundation.org',
mm-commits, hughd, b.zolnierkie
Hello,
On 2014-09-09 08:13, Wang, Yalin wrote:
> This patch add memblock_free to also free the reserved memblock,
> so that the cma pages are not marked as reserved memory in
> /sys/kernel/debug/memblock/reserved debug file
>
> Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> mm/cma.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/cma.c b/mm/cma.c
> index c17751c..f3ec756 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -114,6 +114,8 @@ static int __init cma_activate_area(struct cma *cma)
> goto err;
> }
> init_cma_reserved_pageblock(pfn_to_page(base_pfn));
> + memblock_free(__pfn_to_phys(base_pfn),
> + pageblock_nr_pages * PAGE_SIZE);
> } while (--i);
>
> mutex_init(&cma->lock);
Right. Thanks for fixing this issue. When cma_activate_area() is called
noone
should use memblock to allocate memory, but it is ok to call memblock_free()
to update memblock statistics, so users won't be confused by cma entries in
/sys/kernel/debug/memblock/reserved file.
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Free the reserved memblock when free cma pages
2014-09-12 9:35 ` Marek Szyprowski
@ 2014-09-15 3:06 ` Joonsoo Kim
0 siblings, 0 replies; 12+ messages in thread
From: Joonsoo Kim @ 2014-09-15 3:06 UTC (permalink / raw)
To: Marek Szyprowski
Cc: Wang, Yalin, 'mhocko@suse.cz',
'linux-mm@kvack.org', 'akpm@linux-foundation.org',
mm-commits, hughd, b.zolnierkie
On Fri, Sep 12, 2014 at 11:35:49AM +0200, Marek Szyprowski wrote:
> Hello,
>
> On 2014-09-09 08:13, Wang, Yalin wrote:
> >This patch add memblock_free to also free the reserved memblock,
> >so that the cma pages are not marked as reserved memory in
> >/sys/kernel/debug/memblock/reserved debug file
> >
> >Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
>
> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
>
> >---
> > mm/cma.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> >diff --git a/mm/cma.c b/mm/cma.c
> >index c17751c..f3ec756 100644
> >--- a/mm/cma.c
> >+++ b/mm/cma.c
> >@@ -114,6 +114,8 @@ static int __init cma_activate_area(struct cma *cma)
> > goto err;
> > }
> > init_cma_reserved_pageblock(pfn_to_page(base_pfn));
> >+ memblock_free(__pfn_to_phys(base_pfn),
> >+ pageblock_nr_pages * PAGE_SIZE);
> > } while (--i);
> > mutex_init(&cma->lock);
>
> Right. Thanks for fixing this issue. When cma_activate_area() is
> called noone
> should use memblock to allocate memory, but it is ok to call memblock_free()
> to update memblock statistics, so users won't be confused by cma entries in
> /sys/kernel/debug/memblock/reserved file.
Maybe some comment on code would be very helpful.
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Free the reserved memblock when free cma pages
2014-09-09 6:13 [RFC] Free the reserved memblock when free cma pages Wang, Yalin
2014-09-10 8:18 ` Michal Hocko
2014-09-12 9:35 ` Marek Szyprowski
@ 2014-09-15 5:21 ` Minchan Kim
2014-09-15 5:36 ` Wang, Yalin
2 siblings, 1 reply; 12+ messages in thread
From: Minchan Kim @ 2014-09-15 5:21 UTC (permalink / raw)
To: Wang, Yalin
Cc: 'mhocko@suse.cz', 'linux-mm@kvack.org',
'akpm@linux-foundation.org',
mm-commits, hughd, b.zolnierkie
Hello,
On Tue, Sep 09, 2014 at 02:13:58PM +0800, Wang, Yalin wrote:
> This patch add memblock_free to also free the reserved memblock,
> so that the cma pages are not marked as reserved memory in
> /sys/kernel/debug/memblock/reserved debug file
>
> Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
> ---
> mm/cma.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/cma.c b/mm/cma.c
> index c17751c..f3ec756 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -114,6 +114,8 @@ static int __init cma_activate_area(struct cma *cma)
> goto err;
> }
> init_cma_reserved_pageblock(pfn_to_page(base_pfn));
> + memblock_free(__pfn_to_phys(base_pfn),
> + pageblock_nr_pages * PAGE_SIZE);
Nitpick:
Couldn't we add memblock_free into init_cma_reserved_pageblock?
Because it should be pair with ClearPageReserved, I think.
In addition, please add description on memory reserve part
in cma_declare_contiguous.
> } while (--i);
>
> mutex_init(&cma->lock);
> --
> 2.1.0
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Kind regards,
Minchan Kim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [RFC] Free the reserved memblock when free cma pages
2014-09-15 5:21 ` Minchan Kim
@ 2014-09-15 5:36 ` Wang, Yalin
2014-09-15 5:42 ` Minchan Kim
0 siblings, 1 reply; 12+ messages in thread
From: Wang, Yalin @ 2014-09-15 5:36 UTC (permalink / raw)
To: 'Minchan Kim'
Cc: 'mhocko@suse.cz', 'linux-mm@kvack.org',
'akpm@linux-foundation.org',
mm-commits, hughd, b.zolnierkie
Hi Kim,
I think move memblock_free into init_cma_reserved_pageblock
Is not a good idea,
Because this will need call memblock_free for
Every page release,
Think that for a 4MB memory, need call memblock_free
1024 times , instead, we just call memblock_free one
Time for every pageblock_nr_pages pages .
I will add some descriptions in cma_declare_contiguous
For patch version 2 .
Thanks
-----Original Message-----
Hello,
On Tue, Sep 09, 2014 at 02:13:58PM +0800, Wang, Yalin wrote:
> This patch add memblock_free to also free the reserved memblock, so
> that the cma pages are not marked as reserved memory in
> /sys/kernel/debug/memblock/reserved debug file
>
> Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
> ---
> mm/cma.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/cma.c b/mm/cma.c
> index c17751c..f3ec756 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -114,6 +114,8 @@ static int __init cma_activate_area(struct cma *cma)
> goto err;
> }
> init_cma_reserved_pageblock(pfn_to_page(base_pfn));
> + memblock_free(__pfn_to_phys(base_pfn),
> + pageblock_nr_pages * PAGE_SIZE);
Nitpick:
Couldn't we add memblock_free into init_cma_reserved_pageblock?
Because it should be pair with ClearPageReserved, I think.
In addition, please add description on memory reserve part in cma_declare_contiguous.
> } while (--i);
>
> mutex_init(&cma->lock);
> --
> 2.1.0
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in the body
> to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Kind regards,
Minchan Kim
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Free the reserved memblock when free cma pages
2014-09-15 5:36 ` Wang, Yalin
@ 2014-09-15 5:42 ` Minchan Kim
2014-09-15 5:46 ` Wang, Yalin
2014-09-15 6:10 ` [RFC V2] " Wang, Yalin
0 siblings, 2 replies; 12+ messages in thread
From: Minchan Kim @ 2014-09-15 5:42 UTC (permalink / raw)
To: Wang, Yalin
Cc: 'mhocko@suse.cz', 'linux-mm@kvack.org',
'akpm@linux-foundation.org',
mm-commits, hughd, b.zolnierkie
On Mon, Sep 15, 2014 at 01:36:13PM +0800, Wang, Yalin wrote:
> Hi Kim,
>
> I think move memblock_free into init_cma_reserved_pageblock
> Is not a good idea,
> Because this will need call memblock_free for
> Every page release,
> Think that for a 4MB memory, need call memblock_free
> 1024 times , instead, we just call memblock_free one
> Time for every pageblock_nr_pages pages .
Why?
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1953a243836b..876b789378af 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -848,6 +848,9 @@ void __init init_cma_reserved_pageblock(struct page *page)
}
adjust_managed_page_count(page, pageblock_nr_pages);
+ memblock_free(page_to_phys(page),
+ pageblock_nr_pages * PAGE_SIZE);
+
}
#endif
>
> I will add some descriptions in cma_declare_contiguous
> For patch version 2 .
>
> Thanks
>
> -----Original Message-----
> Hello,
>
> On Tue, Sep 09, 2014 at 02:13:58PM +0800, Wang, Yalin wrote:
> > This patch add memblock_free to also free the reserved memblock, so
> > that the cma pages are not marked as reserved memory in
> > /sys/kernel/debug/memblock/reserved debug file
> >
> > Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
> > ---
> > mm/cma.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/mm/cma.c b/mm/cma.c
> > index c17751c..f3ec756 100644
> > --- a/mm/cma.c
> > +++ b/mm/cma.c
> > @@ -114,6 +114,8 @@ static int __init cma_activate_area(struct cma *cma)
> > goto err;
> > }
> > init_cma_reserved_pageblock(pfn_to_page(base_pfn));
> > + memblock_free(__pfn_to_phys(base_pfn),
> > + pageblock_nr_pages * PAGE_SIZE);
>
> Nitpick:
>
> Couldn't we add memblock_free into init_cma_reserved_pageblock?
> Because it should be pair with ClearPageReserved, I think.
>
> In addition, please add description on memory reserve part in cma_declare_contiguous.
>
> > } while (--i);
> >
> > mutex_init(&cma->lock);
> > --
> > 2.1.0
> >
> > --
> > To unsubscribe, send a message with 'unsubscribe linux-mm' in the body
> > to majordomo@kvack.org. For more info on Linux MM,
> > see: http://www.linux-mm.org/ .
> > Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
> --
> Kind regards,
> Minchan Kim
--
Kind regards,
Minchan Kim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 12+ messages in thread
* RE: [RFC] Free the reserved memblock when free cma pages
2014-09-15 5:42 ` Minchan Kim
@ 2014-09-15 5:46 ` Wang, Yalin
2014-09-15 6:10 ` [RFC V2] " Wang, Yalin
1 sibling, 0 replies; 12+ messages in thread
From: Wang, Yalin @ 2014-09-15 5:46 UTC (permalink / raw)
To: 'Minchan Kim'
Cc: 'mhocko@suse.cz', 'linux-mm@kvack.org',
'akpm@linux-foundation.org',
mm-commits, hughd, b.zolnierkie
Hi Kim,
Oh, my mistake,
I see your meaning,
I will resend a new patch.
Thanks for your advice.
-----Original Message-----
On Mon, Sep 15, 2014 at 01:36:13PM +0800, Wang, Yalin wrote:
> Hi Kim,
>
> I think move memblock_free into init_cma_reserved_pageblock Is not a
> good idea, Because this will need call memblock_free for Every page
> release, Think that for a 4MB memory, need call memblock_free
> 1024 times , instead, we just call memblock_free one Time for every
> pageblock_nr_pages pages .
Why?
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1953a243836b..876b789378af 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -848,6 +848,9 @@ void __init init_cma_reserved_pageblock(struct page *page)
}
adjust_managed_page_count(page, pageblock_nr_pages);
+ memblock_free(page_to_phys(page),
+ pageblock_nr_pages * PAGE_SIZE);
+
}
#endif
>
> I will add some descriptions in cma_declare_contiguous For patch
> version 2 .
>
> Thanks
>
> -----Original Message-----
> Hello,
>
> On Tue, Sep 09, 2014 at 02:13:58PM +0800, Wang, Yalin wrote:
> > This patch add memblock_free to also free the reserved memblock, so
> > that the cma pages are not marked as reserved memory in
> > /sys/kernel/debug/memblock/reserved debug file
> >
> > Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
> > ---
> > mm/cma.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/mm/cma.c b/mm/cma.c
> > index c17751c..f3ec756 100644
> > --- a/mm/cma.c
> > +++ b/mm/cma.c
> > @@ -114,6 +114,8 @@ static int __init cma_activate_area(struct cma *cma)
> > goto err;
> > }
> > init_cma_reserved_pageblock(pfn_to_page(base_pfn));
> > + memblock_free(__pfn_to_phys(base_pfn),
> > + pageblock_nr_pages * PAGE_SIZE);
>
> Nitpick:
>
> Couldn't we add memblock_free into init_cma_reserved_pageblock?
> Because it should be pair with ClearPageReserved, I think.
>
> In addition, please add description on memory reserve part in cma_declare_contiguous.
>
> > } while (--i);
> >
> > mutex_init(&cma->lock);
> > --
> > 2.1.0
> >
> > --
> > To unsubscribe, send a message with 'unsubscribe linux-mm' in the
> > body to majordomo@kvack.org. For more info on Linux MM,
> > see: http://www.linux-mm.org/ .
> > Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
> --
> Kind regards,
> Minchan Kim
--
Kind regards,
Minchan Kim
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [RFC V2] Free the reserved memblock when free cma pages
2014-09-15 5:42 ` Minchan Kim
2014-09-15 5:46 ` Wang, Yalin
@ 2014-09-15 6:10 ` Wang, Yalin
2014-09-15 6:57 ` Minchan Kim
2014-09-15 7:54 ` [PATCH Resend] " Wang, Yalin
1 sibling, 2 replies; 12+ messages in thread
From: Wang, Yalin @ 2014-09-15 6:10 UTC (permalink / raw)
To: 'Minchan Kim'
Cc: 'mhocko@suse.cz', 'linux-mm@kvack.org',
'akpm@linux-foundation.org',
mm-commits, hughd, b.zolnierkie
This patch add memblock_free to also free the reserved memblock,
so that the cma pages are not marked as reserved memory in
/sys/kernel/debug/memblock/reserved debug file
Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
---
mm/cma.c | 6 +++++-
mm/page_alloc.c | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/mm/cma.c b/mm/cma.c
index c17751c..ec69c69 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -196,7 +196,11 @@ int __init cma_declare_contiguous(phys_addr_t base,
if (!IS_ALIGNED(size >> PAGE_SHIFT, 1 << order_per_bit))
return -EINVAL;
- /* Reserve memory */
+ /*
+ * Reserve memory, and the reserved memory are marked as reserved by
+ * memblock driver, remember to clear the reserved status when free
+ * these cma pages, see init_cma_reserved_pageblock()
+ */
if (base && fixed) {
if (memblock_is_region_reserved(base, size) ||
memblock_reserve(base, size) < 0) {
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 18cee0d..fffbb84 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -836,8 +836,8 @@ void __init init_cma_reserved_pageblock(struct page *page)
set_page_refcounted(page);
__free_pages(page, pageblock_order);
}
-
adjust_managed_page_count(page, pageblock_nr_pages);
+ memblock_free(page_to_phys(page), pageblock_nr_pages << PAGE_SHIFT);
}
#endif
--
2.1.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [RFC V2] Free the reserved memblock when free cma pages
2014-09-15 6:10 ` [RFC V2] " Wang, Yalin
@ 2014-09-15 6:57 ` Minchan Kim
2014-09-15 7:54 ` [PATCH Resend] " Wang, Yalin
1 sibling, 0 replies; 12+ messages in thread
From: Minchan Kim @ 2014-09-15 6:57 UTC (permalink / raw)
To: Wang, Yalin
Cc: 'mhocko@suse.cz', 'linux-mm@kvack.org',
'akpm@linux-foundation.org',
mm-commits, hughd, b.zolnierkie
On Mon, Sep 15, 2014 at 02:10:19PM +0800, Wang, Yalin wrote:
> This patch add memblock_free to also free the reserved memblock,
> so that the cma pages are not marked as reserved memory in
> /sys/kernel/debug/memblock/reserved debug file
If you received some comments and judges the direction is right,
you could remove RFC tag from the patch title.
>
> Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
Anyway,
Acked-by: Minchan Kim <minchan@kernel.org>
>
> ---
> mm/cma.c | 6 +++++-
> mm/page_alloc.c | 2 +-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/mm/cma.c b/mm/cma.c
> index c17751c..ec69c69 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -196,7 +196,11 @@ int __init cma_declare_contiguous(phys_addr_t base,
> if (!IS_ALIGNED(size >> PAGE_SHIFT, 1 << order_per_bit))
> return -EINVAL;
>
> - /* Reserve memory */
> + /*
> + * Reserve memory, and the reserved memory are marked as reserved by
> + * memblock driver, remember to clear the reserved status when free
> + * these cma pages, see init_cma_reserved_pageblock()
> + */
> if (base && fixed) {
> if (memblock_is_region_reserved(base, size) ||
> memblock_reserve(base, size) < 0) {
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 18cee0d..fffbb84 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -836,8 +836,8 @@ void __init init_cma_reserved_pageblock(struct page *page)
> set_page_refcounted(page);
> __free_pages(page, pageblock_order);
> }
> -
> adjust_managed_page_count(page, pageblock_nr_pages);
> + memblock_free(page_to_phys(page), pageblock_nr_pages << PAGE_SHIFT);
> }
> #endif
>
> --
> 2.1.0
>
--
Kind regards,
Minchan Kim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH Resend] Free the reserved memblock when free cma pages
2014-09-15 6:10 ` [RFC V2] " Wang, Yalin
2014-09-15 6:57 ` Minchan Kim
@ 2014-09-15 7:54 ` Wang, Yalin
1 sibling, 0 replies; 12+ messages in thread
From: Wang, Yalin @ 2014-09-15 7:54 UTC (permalink / raw)
To: 'Minchan Kim'
Cc: 'mhocko@suse.cz', 'linux-mm@kvack.org',
'akpm@linux-foundation.org',
'mm-commits@vger.kernel.org', 'hughd@google.com',
'b.zolnierkie@samsung.com'
This patch add memblock_free to also free the reserved memblock,
so that the cma pages are not marked as reserved memory in
/sys/kernel/debug/memblock/reserved debug file
Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
---
mm/cma.c | 6 +++++-
mm/page_alloc.c | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/mm/cma.c b/mm/cma.c
index c17751c..ec69c69 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -196,7 +196,11 @@ int __init cma_declare_contiguous(phys_addr_t base,
if (!IS_ALIGNED(size >> PAGE_SHIFT, 1 << order_per_bit))
return -EINVAL;
- /* Reserve memory */
+ /*
+ * Reserve memory, and the reserved memory are marked as reserved by
+ * memblock driver, remember to clear the reserved status when free
+ * these cma pages, see init_cma_reserved_pageblock()
+ */
if (base && fixed) {
if (memblock_is_region_reserved(base, size) ||
memblock_reserve(base, size) < 0) {
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 18cee0d..fffbb84 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -836,8 +836,8 @@ void __init init_cma_reserved_pageblock(struct page *page)
set_page_refcounted(page);
__free_pages(page, pageblock_order);
}
-
adjust_managed_page_count(page, pageblock_nr_pages);
+ memblock_free(page_to_phys(page), pageblock_nr_pages << PAGE_SHIFT);
}
#endif
--
2.1.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-09-15 7:54 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-09 6:13 [RFC] Free the reserved memblock when free cma pages Wang, Yalin
2014-09-10 8:18 ` Michal Hocko
2014-09-10 9:02 ` Wang, Yalin
2014-09-12 9:35 ` Marek Szyprowski
2014-09-15 3:06 ` Joonsoo Kim
2014-09-15 5:21 ` Minchan Kim
2014-09-15 5:36 ` Wang, Yalin
2014-09-15 5:42 ` Minchan Kim
2014-09-15 5:46 ` Wang, Yalin
2014-09-15 6:10 ` [RFC V2] " Wang, Yalin
2014-09-15 6:57 ` Minchan Kim
2014-09-15 7:54 ` [PATCH Resend] " Wang, Yalin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.