linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* clear_page, copy_page address align question?
@ 2017-04-11  3:08 Minchan Kim
  2017-04-11  3:12 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 3+ messages in thread
From: Minchan Kim @ 2017-04-11  3:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Paul Mackerras, Michael Ellerman, linuxppc-dev, linux-kernel

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: clear_page, copy_page address align question?
  2017-04-11  3:08 clear_page, copy_page address align question? Minchan Kim
@ 2017-04-11  3:12 ` Benjamin Herrenschmidt
  2017-04-11  3:21   ` Minchan Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-11  3:12 UTC (permalink / raw)
  To: Minchan Kim; +Cc: Paul Mackerras, Michael Ellerman, linuxppc-dev, linux-kernel

On Tue, 2017-04-11 at 12:08 +0900, Minchan Kim wrote:
> 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.

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: clear_page, copy_page address align question?
  2017-04-11  3:12 ` Benjamin Herrenschmidt
@ 2017-04-11  3:21   ` Minchan Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Minchan Kim @ 2017-04-11  3:21 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Paul Mackerras, Michael Ellerman, linuxppc-dev, linux-kernel

On Tue, Apr 11, 2017 at 01:12:24PM +1000, Benjamin Herrenschmidt wrote:
> On Tue, 2017-04-11 at 12:08 +0900, Minchan Kim wrote:
> > 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.
> 
> 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.


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!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-11  3:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11  3:08 clear_page, copy_page address align question? Minchan Kim
2017-04-11  3:12 ` Benjamin Herrenschmidt
2017-04-11  3:21   ` Minchan Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).