From: Michal Nazarewicz <mina86@mina86.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>,
linux-mm@kvack.org, linaro-mm-sig@lists.linaro.org,
linux-kernel@vger.kernel.org
Cc: Kyungmin Park <kyungmin.park@samsung.com>,
Andrew Morton <akpm@linux-foundation.org>,
Mel Gorman <mel@csn.ul.ie>, Minchan Kim <minchan@kernel.org>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: Re: [PATCH] mm: cma: WARN if freed memory is still in use
Date: Mon, 12 Nov 2012 17:42:50 +0100 [thread overview]
Message-ID: <xa1t8va6zsad.fsf@mina86.com> (raw)
In-Reply-To: <1352718446-32313-1-git-send-email-m.szyprowski@samsung.com>
[-- 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 --]
next prev parent reply other threads:[~2012-11-12 16:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-12 11:07 Marek Szyprowski
2012-11-12 16:42 ` Michal Nazarewicz [this message]
2012-11-13 6:47 ` [PATCH v2] " Marek Szyprowski
2012-11-13 10:16 ` Michal Nazarewicz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xa1t8va6zsad.fsf@mina86.com \
--to=mina86@mina86.com \
--cc=akpm@linux-foundation.org \
--cc=b.zolnierkie@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=m.szyprowski@samsung.com \
--cc=mel@csn.ul.ie \
--cc=minchan@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox