lkml.org 
[lkml]   [2009]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] generic debug pagealloc
    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;
    > +}


    \
     
     \ /
      Last update: 2009-03-03 17:15    [W:0.025 / U:1.976 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site