clear_page, copy_page address align question?
Hello,
When I tested zram in ppc64, I got random corruption. With investigation, it seems clear_page corrupted the memory. I passed 64K kmalloced(kmalloc(PAGE_SIZE)) address to clear_page and turned on slub debug so address is not aligned with PAGE_SIZE. Is it a valid usecase that non-PAGE_SIZE aligned address is used for clear_page in ppc64?
As well, copy_page have same rule, too?
Anyway, when I changed clear_page to memset, it seems the problem is gone.
Thanks.
Quoted 9 lines · Minchan Kim
Hello,
When I tested zram in ppc64, I got random corruption. With investigation, it seems
clear_pagecorrupted the memory. I passed 64K kmalloced(kmalloc(PAGE_SIZE)) address toclear_pageand turned on slub debug so address is not aligned withPAGE_SIZE. Is it a valid usecase that non-PAGE_SIZE aligned address is used forclear_pagein ppc64?
Quoted 4 lines
As well,
copy_pagehave same rule, too?Anyway, when I changed
clear_pageto memset, it seems the problem is gone.
Yes, both clear_page and copy_page assume a PAGE_SHIFT alignment and are highly optimize according to this.
I wouldn't be surprised of other architectures implementations are the same.
I don't think it's ever legit to call these functions for something that isn't a naturally aligned page.
Cheers,
Ben.
Quoted 15 lines · Benjamin Herrenschmidt
Quoted 9 lines · Minchan Kim
Hello,
When I tested zram in ppc64, I got random corruption. With investigation, it seems
clear_pagecorrupted the memory. I passed 64K kmalloced(kmalloc(PAGE_SIZE)) address toclear_pageand turned on slub debug so address is not aligned withPAGE_SIZE. Is it a valid usecase that non-PAGE_SIZE aligned address is used forclear_pagein ppc64?Quoted 4 lines
As well,
copy_pagehave same rule, too?Anyway, when I changed
clear_pageto memset, it seems the problem is gone.
Quoted 8 lines
Yes, both
clear_pageandcopy_pageassume aPAGE_SHIFTalignment and are highly optimize according to this.I wouldn't be surprised of other architectures implementations are the same.
I don't think it's ever legit to call these functions for something that isn't a naturally aligned page.
If it's the common for every architecture, it would have better to have description about that in somewhere or WARN_ON. :(
Thanks for the confirm!