From: Andrew Morton <akpm@linux-foundation.org>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
linux-mm@kvack.org, mingo@elte.hu, jirislaby@gmail.com,
rmk+lkml@arm.linux.org.uk
Subject: Re: [PATCH] generic debug pagealloc (-v2)
Date: Thu, 5 Mar 2009 14:31:50 -0800 [thread overview]
Message-ID: <20090305143150.136e2708.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090305145926.GA27015@localhost.localdomain>
On Thu, 5 Mar 2009 23:59:27 +0900
Akinobu Mita <akinobu.mita@gmail.com> wrote:
> CONFIG_DEBUG_PAGEALLOC is now supported by x86, powerpc, sparc (64bit),
> and s390. This patch implements it for the rest of the architectures
> by filling the pages with poison byte patterns after free_pages() and
> verifying the poison patterns before alloc_pages().
>
> This generic one cannot detect invalid read accesses and it can only
> detect invalid write accesses after a long delay. But it is a feasible way
> for nommu architectures.
>
> ...
>
> +#include <linux/kernel.h>
> +#include <linux/mm.h>
> +
> +static void poison_page(struct page *page)
> +{
> + void *addr;
> +
> + if (PageHighMem(page))
> + return; /* i goofed */
heh. A more complete comment would be needed here.
Also, as this is a kernel bug, perhaps some sort of runtime warning?
> + page->poison = true;
> + addr = page_address(page);
> + memset(addr, PAGE_POISON, PAGE_SIZE);
> +}
> +
> +static void poison_pages(struct page *page, int n)
> +{
> + int i;
> +
> + for (i = 0; i < n; i++)
> + poison_page(page + i);
> +}
> +
> +static void check_poison_mem(unsigned char *mem, size_t bytes)
> +{
> + unsigned char *start;
> + unsigned char *end;
> +
> + for (start = mem; start < mem + bytes; start++) {
> + if (*start != PAGE_POISON)
> + break;
> + }
> + if (start == mem + bytes)
> + return;
> +
> + for (end = mem + bytes - 1; end > start; end--) {
> + if (*end != PAGE_POISON)
> + break;
> + }
> + printk(KERN_ERR "Page corruption: %p-%p\n", start, end);
> + print_hex_dump(KERN_ERR, "", DUMP_PREFIX_ADDRESS, 16, 1, start,
> + end - start + 1, 1);
> +}
> +
> +static void unpoison_page(struct page *page)
> +{
> + void *addr;
> +
Shouldn't we check PageHighmem() here also?
> + if (!page->poison)
> + return;
> +
> + addr = page_address(page);
> + check_poison_mem(addr, PAGE_SIZE);
> + page->poison = false;
> +}
> +
--
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>
next prev parent reply other threads:[~2009-03-05 22:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-05 14:59 Akinobu Mita
2009-03-05 22:31 ` Andrew Morton [this message]
2009-03-06 3:28 ` Akinobu Mita
2009-03-06 15:39 ` [PATCH] generic debug pagealloc (-v3) Akinobu Mita
2009-03-06 20:45 ` Andrew Morton
2009-03-07 16:29 ` [PATCH] generic debug pagealloc (-v4) Akinobu Mita
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=20090305143150.136e2708.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=akinobu.mita@gmail.com \
--cc=jirislaby@gmail.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@elte.hu \
--cc=rmk+lkml@arm.linux.org.uk \
/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