Re: [PATCH] generic debug pagealloc

From: Jiri Slaby
Date: Tue Mar 03 2009 - 11:12:53 EST


On 3.3.2009 17:01, Akinobu Mita wrote:
...
> +static void dump_broken_mem(unsigned char *mem)
> +{
> + int i;
> + int start = 0;
> + int end = PAGE_SIZE - 1;
> +
> + for (i = 0; i< PAGE_SIZE; i++) {
> + if (mem[i] != PAGE_POISON) {
> + start = i;
> + break;
> + }
> + }
> + for (i = PAGE_SIZE - 1; i>= start; i--) {
> + if (mem[i] != PAGE_POISON) {
> + end = i;
> + break;
> + }
> + }
> + printk(KERN_ERR "Page corruption: %p-%p\n", mem + start, mem + end);
> + print_hex_dump(KERN_ERR, "", DUMP_PREFIX_ADDRESS, 16, 1, mem + start,
> + end - start + 1, 1);
> +}
> +
> +static void unpoison_page(struct page *page)
> +{
> + unsigned char *mem;
> + int i;
> +
> + if (!page->poison)
> + return;
> +
> + mem = kmap_atomic(page, KM_USER0);
> + for (i = 0; i< PAGE_SIZE; i++) {
> + if (mem[i] != PAGE_POISON) {
> + dump_broken_mem(mem);

Just an optimisation: pass the i to the dump_broken_mem as a start index.

> + break;
> + }
> + }
> + kunmap_atomic(mem, KM_USER0);
> + page->poison = false;
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/