linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] slab debug vs. L1 alignement
@ 2003-08-15 14:00 Benjamin Herrenschmidt
  2003-08-15 18:51 ` Philippe Elie
  2003-08-15 21:16 ` Andrew Morton
  0 siblings, 2 replies; 18+ messages in thread
From: Benjamin Herrenschmidt @ 2003-08-15 14:00 UTC (permalink / raw)
  To: linux-kernel mailing list

Currently, when enabling slab debugging, we lose the property of
having the objects aligned on a cache line size.

This is, imho, an error, especially if GFP_DMA is passed. Such an
object _must_ be cache alined (and it's size rounded to a multiple
of the cache line size).

There is a simple performance reason on cache coherent archs, but
there's also the fact that it will just _not_ work properly on
non cache-coherent archs. Actually, I also have to deal with some
old machines who have a SCSI controller who has a problem accessing
buffers that aren't aligned on a cache line size boundary.

This is typically causing me trouble in various parts of SCSI which
abuses kmalloc(512, GFP_KERNEL | GFP_DMA) for buffers passed to some
SCSI commands, typically "utility" commands used to read a disk
capacity, read read/write protect flags, some sense buffers, etc...

While I know SCSI shall use the consistent alloc things, it has not
been fully fixed yet and kmalloc with GFP_DMA is still valid despite
not beeing efficient, so we should make sure in this case, the returned
buffer is really suitable for DMA, that is cache aligned.

Ben.


^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [BUG] slab debug vs. L1 alignement
@ 2003-08-15 21:50 Manfred Spraul
  2003-08-15 23:41 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 18+ messages in thread
From: Manfred Spraul @ 2003-08-15 21:50 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linux-kernel

Ben wrote:

>Currently, when enabling slab debugging, we lose the property of
>having the objects aligned on a cache line size.
>  
>
Correct. Cache line alignment is advisory. Slab debugging is not the 
only case that violates the alignment, for example 32-byte allocations 
are not padded to the 128 byte cache line size of the Pentium 4 cpus. I 
really doubt we want that.

Have you looked at pci_pool_{create,alloc,free,destroy}? The functions 
were specifically written to provide aligned buffers for DMA operations. 
Perhaps SCSI should use them?

--
    Manfred


^ permalink raw reply	[flat|nested] 18+ messages in thread
[parent not found: <kUMe.2pd.9@gated-at.bofh.it>]
* Re: [BUG] slab debug vs. L1 alignement
@ 2003-08-17 17:27 James Bottomley
  2003-08-18 20:29 ` Kai Makisara
  2003-09-30 18:40 ` Manfred Spraul
  0 siblings, 2 replies; 18+ messages in thread
From: James Bottomley @ 2003-08-17 17:27 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Kai Makisara, Manfred Spraul, Benjamin Herrenschmidt

Perhaps we should remind ourselves what the alignment rules actually are
for kmalloc:

1) No two kmalloc allocations may share cache lines (otherwise data
corruption will result).
2) kmalloc should be on a power of two alignment consistent with the
widest processor data access requirements.

Now note that 1) is optional (but an efficiency speed up) for a coherent
architecture.  It is an *absolute requirement* for a non-coherent
architecture.

2) is essentially what's causing Ben the problems.  His driver appears
to be insisting that DMA be a full PCI cache line width.  I can see
arguments for making this a driver problem.

However, as far as the redzoning issue goes, I think in order to avoid
cache line interference, the redzone should be sized to be a cache line
width, at least on non-coherent architectures.

In theory, the above should solve everyone's problems.

As far as I/O from user land goes (especially to tape), the users
usually can work out the alignment constraints and act accordingly.  I'm
agnostic as to whether we should fail (with an error indicating
alignment problems) or rebuffer causing inefficiency in throughput in
the misaligned case.

James




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

end of thread, other threads:[~2003-09-30 18:41 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-15 14:00 [BUG] slab debug vs. L1 alignement Benjamin Herrenschmidt
2003-08-15 18:51 ` Philippe Elie
2003-08-15 16:54   ` Benjamin Herrenschmidt
2003-08-15 21:16 ` Andrew Morton
2003-08-15 21:50 Manfred Spraul
2003-08-15 23:41 ` Benjamin Herrenschmidt
2003-08-16  1:47   ` Manfred Spraul
2003-08-16  9:37     ` Benjamin Herrenschmidt
2003-08-16 10:09       ` Manfred Spraul
2003-08-16 10:43         ` Benjamin Herrenschmidt
2003-08-16 11:21           ` Kai Makisara
2003-08-16 11:36             ` Benjamin Herrenschmidt
2003-08-16 14:39               ` Kai Makisara
     [not found] <kUMe.2pd.9@gated-at.bofh.it>
     [not found] ` <kWuz.41M.5@gated-at.bofh.it>
     [not found]   ` <kYwo.5Xr.1@gated-at.bofh.it>
     [not found]     ` <l5HD.4tl.21@gated-at.bofh.it>
     [not found]       ` <l6kd.53T.1@gated-at.bofh.it>
2003-08-16 12:00         ` Arnd Bergmann
2003-08-16 12:18           ` Manfred Spraul
2003-08-17 17:27 James Bottomley
2003-08-18 20:29 ` Kai Makisara
2003-09-30 18:40 ` Manfred Spraul

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).