* [PATCH] mm: cma: WARN if freed memory is still in use
@ 2012-11-12 11:07 Marek Szyprowski
2012-11-12 16:42 ` Michal Nazarewicz
0 siblings, 1 reply; 4+ messages in thread
From: Marek Szyprowski @ 2012-11-12 11:07 UTC (permalink / raw)
To: linux-mm, linaro-mm-sig, linux-kernel
Cc: Marek Szyprowski, Kyungmin Park, Andrew Morton, Mel Gorman,
Michal Nazarewicz, Minchan Kim, Bartlomiej Zolnierkiewicz
Memory return to free_contig_range() must have no other references. Let
kernel to complain loudly if page reference count is not equal to 1.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Michal Nazarewicz <mina86@mina86.com>
---
mm/page_alloc.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 022e4ed..290c2eb 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5888,8 +5888,13 @@ done:
void free_contig_range(unsigned long pfn, unsigned nr_pages)
{
- for (; nr_pages--; ++pfn)
- __free_page(pfn_to_page(pfn));
+ struct page *page = pfn_to_page(pfn);
+ int refcount = nr_pages;
+ for (; nr_pages--; page++) {
+ refcount -= page_count(page) == 1;
+ __free_page(page);
+ }
+ WARN(refcount != 0, "some pages are still in use!\n");
}
#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: cma: WARN if freed memory is still in use
2012-11-12 11:07 [PATCH] mm: cma: WARN if freed memory is still in use Marek Szyprowski
@ 2012-11-12 16:42 ` Michal Nazarewicz
2012-11-13 6:47 ` [PATCH v2] " Marek Szyprowski
0 siblings, 1 reply; 4+ messages in thread
From: Michal Nazarewicz @ 2012-11-12 16:42 UTC (permalink / raw)
To: Marek Szyprowski, linux-mm, linaro-mm-sig, linux-kernel
Cc: Marek Szyprowski, Kyungmin Park, Andrew Morton, Mel Gorman,
Minchan Kim, Bartlomiej Zolnierkiewicz
[-- Attachment #1: Type: text/plain, Size: 1312 bytes --]
On Mon, Nov 12 2012, Marek Szyprowski wrote:
> Memory return to free_contig_range() must have no other references. Let
> kernel to complain loudly if page reference count is not equal to 1.
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 022e4ed..290c2eb 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5888,8 +5888,13 @@ done:
>
> void free_contig_range(unsigned long pfn, unsigned nr_pages)
> {
> - for (; nr_pages--; ++pfn)
> - __free_page(pfn_to_page(pfn));
> + struct page *page = pfn_to_page(pfn);
> + int refcount = nr_pages;
> + for (; nr_pages--; page++) {
> + refcount -= page_count(page) == 1;
> + __free_page(page);
> + }
> + WARN(refcount != 0, "some pages are still in use!\n");
This decrementing logic seem backward to me. Why not:
struct page *page = pfn_to_page(pfn);
unsigned int refcount = 0;
for (; nr_pages--; page++) {
refcount += page_count(page) != 1;
__free_page(page);
}
WARN(refcount != 0, "some pages are still in use!\n");
> }
> #endif
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--
[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2.2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] mm: cma: WARN if freed memory is still in use
2012-11-12 16:42 ` Michal Nazarewicz
@ 2012-11-13 6:47 ` Marek Szyprowski
2012-11-13 10:16 ` Michal Nazarewicz
0 siblings, 1 reply; 4+ messages in thread
From: Marek Szyprowski @ 2012-11-13 6:47 UTC (permalink / raw)
To: linux-mm, linaro-mm-sig, linux-kernel
Cc: Marek Szyprowski, Kyungmin Park, Andrew Morton, Mel Gorman,
Michal Nazarewicz, Minchan Kim, Bartlomiej Zolnierkiewicz
Memory returned to free_contig_range() must have no other references. Let
kernel to complain loudly if page reference count is not equal to 1.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Michal Nazarewicz <mina86@mina86.com>
---
mm/page_alloc.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 022e4ed..290c2eb 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5888,8 +5888,13 @@ done:
void free_contig_range(unsigned long pfn, unsigned nr_pages)
{
- for (; nr_pages--; ++pfn)
- __free_page(pfn_to_page(pfn));
+ struct page *page = pfn_to_page(pfn);
+ int count = 0;
+ for (; nr_pages--; page++) {
+ count += page_count(page) != 1;
+ __free_page(page);
+ }
+ WARN(count != 0, "%d pages are still in use!\n", count);
}
#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] mm: cma: WARN if freed memory is still in use
2012-11-13 6:47 ` [PATCH v2] " Marek Szyprowski
@ 2012-11-13 10:16 ` Michal Nazarewicz
0 siblings, 0 replies; 4+ messages in thread
From: Michal Nazarewicz @ 2012-11-13 10:16 UTC (permalink / raw)
To: Marek Szyprowski, linux-mm, linaro-mm-sig, linux-kernel
Cc: Marek Szyprowski, Kyungmin Park, Andrew Morton, Mel Gorman,
Minchan Kim, Bartlomiej Zolnierkiewicz
[-- Attachment #1: Type: text/plain, Size: 1266 bytes --]
On Tue, Nov 13 2012, Marek Szyprowski <m.szyprowski@samsung.com> wrote:
> Memory returned to free_contig_range() must have no other references. Let
> kernel to complain loudly if page reference count is not equal to 1.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com>
> CC: Michal Nazarewicz <mina86@mina86.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 022e4ed..290c2eb 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5888,8 +5888,13 @@ done:
>
> void free_contig_range(unsigned long pfn, unsigned nr_pages)
> {
> - for (; nr_pages--; ++pfn)
> - __free_page(pfn_to_page(pfn));
> + struct page *page = pfn_to_page(pfn);
> + int count = 0;
> + for (; nr_pages--; page++) {
> + count += page_count(page) != 1;
> + __free_page(page);
> + }
> + WARN(count != 0, "%d pages are still in use!\n", count);
> }
> #endif
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--
[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2.2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-13 10:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-12 11:07 [PATCH] mm: cma: WARN if freed memory is still in use Marek Szyprowski
2012-11-12 16:42 ` Michal Nazarewicz
2012-11-13 6:47 ` [PATCH v2] " Marek Szyprowski
2012-11-13 10:16 ` Michal Nazarewicz
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).