From: "Håvard Skinnemoen" <hskinnemoen@gmail.com>
To: "Christoph Lameter" <clameter@sgi.com>
Cc: "Haavard Skinnemoen" <hskinnemoen@atmel.com>,
"Linux Kernel" <linux-kernel@vger.kernel.org>,
"David Brownell" <david-b@pacbell.net>
Subject: Re: kernel BUG at mm/slub.c:3689!
Date: Mon, 11 Jun 2007 21:04:32 +0200 [thread overview]
Message-ID: <1defaf580706111204v35b4dcc9j5dc68e722bd384b1@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0706111129270.18327@schroedinger.engr.sgi.com>
On 6/11/07, Christoph Lameter <clameter@sgi.com> wrote:
> On Mon, 11 Jun 2007, Håvard Skinnemoen wrote:
>
> > > Note that I do not get why you would be aligning the objects to 32 bytes.
> > > Increasing the smallest cache size wastes a lot of memory. And it is
> > > usually advantageous if multiple related objects are in the same cacheline
> > > unless you have heavy SMP contention.
> >
> > It's not about performance at all, it's about DMA buffers allocated
> > using kmalloc() getting corrupted. Imagine this:
>
> Uhhh... How about using a separate slab for the DMA buffers?
If there were just a few, known drivers that did this, sure. But as
long as Documentation/DMA-mapping.txt includes this paragraph:
If you acquired your memory via the page allocator
(i.e. __get_free_page*()) or the generic memory allocators
(i.e. kmalloc() or kmem_cache_alloc()) then you may DMA to/from
that memory using the addresses returned from those routines.
I think it's best to ensure that memory returned by kmalloc() actually
can be used for DMA. I used to work around this problem in the SPI
controller driver by using a temporary DMA buffer when possible
misalignment was detected, but David Brownell said it was the wrong
way to do it and pointed at the above paragraph.
But, as I mentioned, perhaps ARCH_KMALLOC_MINALIGN isn't the best way
to solve the problem. I'll look into the flush-caches-from-dma_unmap
approach. However, it looks like other arches set
ARCH_KMALLOC_MINALIGN to various values -- I suspect some of them
might run into the same problem as well?
hskinnemoen@dhcp-255-175:~/git/linux$ grep -r ARCH_KMALLOC_MINALIGN
include/asm-*
include/asm-mips/mach-generic/kmalloc.h:#define ARCH_KMALLOC_MINALIGN 128
include/asm-mips/mach-ip27/kmalloc.h: * All happy, no need to define
ARCH_KMALLOC_MINALIGN
include/asm-mips/mach-ip32/kmalloc.h:#define ARCH_KMALLOC_MINALIGN 32
include/asm-mips/mach-ip32/kmalloc.h:#define ARCH_KMALLOC_MINALIGN 128
include/asm-s390/cache.h:#define ARCH_KMALLOC_MINALIGN 8
include/asm-sh64/uaccess.h:#define ARCH_KMALLOC_MINALIGN 8
> > Maybe there are other solutions to this problem, but the old SLAB
> > allocator did guarantee 32-byte alignment as long as SLAB debugging
> > was turned off, so setting ARCH_KMALLOC_MINALIGN seemed like the
> > easiest way to get back to the old, known-working behaviour.
>
> SLABs mininum object size is 32 thus you had no problems. I see. SLAB
> does not guarantee 32 byte alignment. It just happened to work. If you
> switch on CONFIG_SLAB_DEBUG you will likely get into trouble.
Yeah, that's true. CONFIG_SLAB_DEBUG does indeed cause DMA buffer
corruption on avr32, and so does CONFIG_SLOB. I've been wanting to fix
it, but I never understood how. Now that SLUB seems to offer a
solution that doesn't effectively turn off debugging, I thought I'd
finally found it...
Haavard
next prev parent reply other threads:[~2007-06-11 19:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-11 14:19 Haavard Skinnemoen
2007-06-11 15:38 ` Paul Mundt
2007-06-11 15:58 ` Håvard Skinnemoen
2007-06-11 16:19 ` Christoph Lameter
2007-06-11 16:43 ` Håvard Skinnemoen
2007-06-11 16:49 ` Christoph Lameter
2007-06-11 17:11 ` Håvard Skinnemoen
2007-06-11 17:52 ` Christoph Lameter
2007-06-11 18:22 ` Håvard Skinnemoen
2007-06-11 18:32 ` Christoph Lameter
2007-06-11 19:04 ` Håvard Skinnemoen [this message]
2007-06-11 19:11 ` Christoph Lameter
2007-06-11 19:35 ` Håvard Skinnemoen
2007-06-11 19:40 ` Christoph Lameter
2007-06-11 19:53 ` Håvard Skinnemoen
2007-06-12 3:16 ` Christoph Lameter
2007-06-12 8:55 ` Haavard Skinnemoen
2007-06-12 10:16 ` Haavard Skinnemoen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1defaf580706111204v35b4dcc9j5dc68e722bd384b1@mail.gmail.com \
--to=hskinnemoen@gmail.com \
--cc=clameter@sgi.com \
--cc=david-b@pacbell.net \
--cc=hskinnemoen@atmel.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®