Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-20 Thread Minchan Kim
On Thu, Apr 20, 2017 at 10:45:42AM +0900, Sergey Senozhatsky wrote: > On (04/19/17 04:51), Matthew Wilcox wrote: > [..] > > > > > Another approach is the API does normal thing for non-aligned prefix > > > > > and > > > > > tail space and fast thing for aligned space. > > > > > Otherwise, it would

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-20 Thread Minchan Kim
On Thu, Apr 20, 2017 at 10:45:42AM +0900, Sergey Senozhatsky wrote: > On (04/19/17 04:51), Matthew Wilcox wrote: > [..] > > > > > Another approach is the API does normal thing for non-aligned prefix > > > > > and > > > > > tail space and fast thing for aligned space. > > > > > Otherwise, it would

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-19 Thread Sergey Senozhatsky
On (04/19/17 04:51), Matthew Wilcox wrote: [..] > > > > Another approach is the API does normal thing for non-aligned prefix and > > > > tail space and fast thing for aligned space. > > > > Otherwise, it would be happy if the API has WARN_ON non-page SIZE > > > > aligned > > > > address. > > Why

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-19 Thread Sergey Senozhatsky
On (04/19/17 04:51), Matthew Wilcox wrote: [..] > > > > Another approach is the API does normal thing for non-aligned prefix and > > > > tail space and fast thing for aligned space. > > > > Otherwise, it would be happy if the API has WARN_ON non-page SIZE > > > > aligned > > > > address. > > Why

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-19 Thread Matthew Wilcox
On Wed, Apr 19, 2017 at 03:02:37PM +0900, Minchan Kim wrote: > On Tue, Apr 18, 2017 at 09:33:07AM +0200, Michal Hocko wrote: > > I do not follow. Why would you need kmap for something that is already > > in the kernel space? > > Because it can work with highmem pages. That's

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-19 Thread Matthew Wilcox
On Wed, Apr 19, 2017 at 03:02:37PM +0900, Minchan Kim wrote: > On Tue, Apr 18, 2017 at 09:33:07AM +0200, Michal Hocko wrote: > > I do not follow. Why would you need kmap for something that is already > > in the kernel space? > > Because it can work with highmem pages. That's

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-19 Thread Sergey Senozhatsky
On (04/18/17 13:06), Michal Hocko wrote: [..] > > > copy_page is a performance sensitive function and I believe that we do > > > those tricks exactly for this purpose. > > > > a wild thought, > > > > use > > #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE) > > > > when

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-19 Thread Sergey Senozhatsky
On (04/18/17 13:06), Michal Hocko wrote: [..] > > > copy_page is a performance sensitive function and I believe that we do > > > those tricks exactly for this purpose. > > > > a wild thought, > > > > use > > #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE) > > > > when

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-19 Thread Minchan Kim
Hello Michal, On Tue, Apr 18, 2017 at 09:33:07AM +0200, Michal Hocko wrote: > On Tue 18-04-17 09:03:19, Minchan Kim wrote: > > On Mon, Apr 17, 2017 at 10:20:42AM -0500, Christoph Lameter wrote: > > > On Mon, 17 Apr 2017, Sergey Senozhatsky wrote: > > > > > > > Minchan reported that doing

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-19 Thread Minchan Kim
Hello Michal, On Tue, Apr 18, 2017 at 09:33:07AM +0200, Michal Hocko wrote: > On Tue 18-04-17 09:03:19, Minchan Kim wrote: > > On Mon, Apr 17, 2017 at 10:20:42AM -0500, Christoph Lameter wrote: > > > On Mon, 17 Apr 2017, Sergey Senozhatsky wrote: > > > > > > > Minchan reported that doing

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-18 Thread Christoph Lameter
On Tue, 18 Apr 2017, Sergey Senozhatsky wrote: > > Simple solution is to not allocate pages via the slab allocator but use > > the page allocator for this. The page allocator provides proper alignment. > > sure, but at the same time it's not completely uncommon and unseen thing > > ~/_next$ git

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-18 Thread Christoph Lameter
On Tue, 18 Apr 2017, Sergey Senozhatsky wrote: > > Simple solution is to not allocate pages via the slab allocator but use > > the page allocator for this. The page allocator provides proper alignment. > > sure, but at the same time it's not completely uncommon and unseen thing > > ~/_next$ git

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-18 Thread Matthew Wilcox
On Mon, Apr 17, 2017 at 10:20:42AM -0500, Christoph Lameter wrote: > Simple solution is to not allocate pages via the slab allocator but use > the page allocator for this. The page allocator provides proper alignment. > > There is a reason it is called the page allocator because if you want a >

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-18 Thread Matthew Wilcox
On Mon, Apr 17, 2017 at 10:20:42AM -0500, Christoph Lameter wrote: > Simple solution is to not allocate pages via the slab allocator but use > the page allocator for this. The page allocator provides proper alignment. > > There is a reason it is called the page allocator because if you want a >

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-18 Thread Michal Hocko
On Tue 18-04-17 19:56:41, Sergey Senozhatsky wrote: > On (04/18/17 09:33), Michal Hocko wrote: > [..] > > > Another approach is the API does normal thing for non-aligned prefix and > > > tail space and fast thing for aligned space. > > > Otherwise, it would be happy if the API has WARN_ON non-page

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-18 Thread Michal Hocko
On Tue 18-04-17 19:56:41, Sergey Senozhatsky wrote: > On (04/18/17 09:33), Michal Hocko wrote: > [..] > > > Another approach is the API does normal thing for non-aligned prefix and > > > tail space and fast thing for aligned space. > > > Otherwise, it would be happy if the API has WARN_ON non-page

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-18 Thread Sergey Senozhatsky
On (04/18/17 09:33), Michal Hocko wrote: [..] > > Another approach is the API does normal thing for non-aligned prefix and > > tail space and fast thing for aligned space. > > Otherwise, it would be happy if the API has WARN_ON non-page SIZE aligned > > address. > > copy_page is a performance

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-18 Thread Sergey Senozhatsky
On (04/18/17 09:33), Michal Hocko wrote: [..] > > Another approach is the API does normal thing for non-aligned prefix and > > tail space and fast thing for aligned space. > > Otherwise, it would be happy if the API has WARN_ON non-page SIZE aligned > > address. > > copy_page is a performance

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-18 Thread Sergey Senozhatsky
On (04/17/17 10:20), Christoph Lameter wrote: > On Mon, 17 Apr 2017, Sergey Senozhatsky wrote: > > Minchan reported that doing copy_page() on a kmalloc(PAGE_SIZE) page > > with DEBUG_SLAB enabled can cause a memory corruption (See below or > >

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-18 Thread Sergey Senozhatsky
On (04/17/17 10:20), Christoph Lameter wrote: > On Mon, 17 Apr 2017, Sergey Senozhatsky wrote: > > Minchan reported that doing copy_page() on a kmalloc(PAGE_SIZE) page > > with DEBUG_SLAB enabled can cause a memory corruption (See below or > >

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-18 Thread Michal Hocko
On Tue 18-04-17 09:03:19, Minchan Kim wrote: > On Mon, Apr 17, 2017 at 10:20:42AM -0500, Christoph Lameter wrote: > > On Mon, 17 Apr 2017, Sergey Senozhatsky wrote: > > > > > Minchan reported that doing copy_page() on a kmalloc(PAGE_SIZE) page > > > with DEBUG_SLAB enabled can cause a memory

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-18 Thread Michal Hocko
On Tue 18-04-17 09:03:19, Minchan Kim wrote: > On Mon, Apr 17, 2017 at 10:20:42AM -0500, Christoph Lameter wrote: > > On Mon, 17 Apr 2017, Sergey Senozhatsky wrote: > > > > > Minchan reported that doing copy_page() on a kmalloc(PAGE_SIZE) page > > > with DEBUG_SLAB enabled can cause a memory

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-17 Thread Minchan Kim
On Mon, Apr 17, 2017 at 10:20:42AM -0500, Christoph Lameter wrote: > On Mon, 17 Apr 2017, Sergey Senozhatsky wrote: > > > Minchan reported that doing copy_page() on a kmalloc(PAGE_SIZE) page > > with DEBUG_SLAB enabled can cause a memory corruption (See below or > >

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-17 Thread Minchan Kim
On Mon, Apr 17, 2017 at 10:20:42AM -0500, Christoph Lameter wrote: > On Mon, 17 Apr 2017, Sergey Senozhatsky wrote: > > > Minchan reported that doing copy_page() on a kmalloc(PAGE_SIZE) page > > with DEBUG_SLAB enabled can cause a memory corruption (See below or > >

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-17 Thread Christoph Lameter
On Mon, 17 Apr 2017, Sergey Senozhatsky wrote: > Minchan reported that doing copy_page() on a kmalloc(PAGE_SIZE) page > with DEBUG_SLAB enabled can cause a memory corruption (See below or > lkml.kernel.org/r/1492042622-12074-2-git-send-email-minc...@kernel.org ) Yes the alignment guarantees do

Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-17 Thread Christoph Lameter
On Mon, 17 Apr 2017, Sergey Senozhatsky wrote: > Minchan reported that doing copy_page() on a kmalloc(PAGE_SIZE) page > with DEBUG_SLAB enabled can cause a memory corruption (See below or > lkml.kernel.org/r/1492042622-12074-2-git-send-email-minc...@kernel.org ) Yes the alignment guarantees do

copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-16 Thread Sergey Senozhatsky
Hello, I'll fork it into a separate thread and Cc more MM people. sorry for top-posting. Minchan reported that doing copy_page() on a kmalloc(PAGE_SIZE) page with DEBUG_SLAB enabled can cause a memory corruption (See below or lkml.kernel.org/r/1492042622-12074-2-git-send-email-minc...@kernel.org

copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address")

2017-04-16 Thread Sergey Senozhatsky
Hello, I'll fork it into a separate thread and Cc more MM people. sorry for top-posting. Minchan reported that doing copy_page() on a kmalloc(PAGE_SIZE) page with DEBUG_SLAB enabled can cause a memory corruption (See below or lkml.kernel.org/r/1492042622-12074-2-git-send-email-minc...@kernel.org