All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: linux-mips@linux-mips.org
Subject: Re: kmalloc alignment
Date: Tue, 19 Oct 2004 18:59:01 +0200	[thread overview]
Message-ID: <20041019165901.GA18385@linux-mips.org> (raw)
In-Reply-To: <20041019.235129.25480859.anemo@mba.ocn.ne.jp>

On Tue, Oct 19, 2004 at 11:51:29PM +0900, Atsushi Nemoto wrote:

> In include/asm-mips/cache.h:
> 
> #define ARCH_KMALLOC_MINALIGN	8
> 
> Is this line really needed?
> 
> If it was not defined (and ARCH_KMALLOC_FLAGS was also not defined),
> default alignment (cache_line_size()) will be used for kmalloc.  It is
> enough, isn't it?

The alignment needs to be large enough to store an arbitrary fundamental
data type including the 64-bit types such as long long or double.

cache_line_size() is only used if a slab has SLAB_HWCACHE_ALIGN set.

The effect of not guaranteeing 8 byte alignment are subtle at times because
the kernel unaligned handling is going to hide the problem.  So just
performance will suffer.  It used to show up clearly only in the
floating point context switch because we don't support software emulation
of missaligned floating point loads and stores.

> Also, with current 8 byte alignment, many PCI drivers which are using
> kmalloc and dma_map_single are broken on non-coherent system.  I was
> told that those drivers should use dma_get_cache_alignment() API, but
> currently nobody do it anyway.  Removing ARCH_KMALLOC_MINALIGN will
> help those (broken?) drivers.

The alignment requirements are documented in Documentation/DMA-API.txt
and they are specified the way they are for good reason.

  Ralf

  reply	other threads:[~2004-10-19 16:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-19 14:51 kmalloc alignment Atsushi Nemoto
2004-10-19 16:59 ` Ralf Baechle [this message]
2004-10-20  5:56   ` Atsushi Nemoto
  -- strict thread matches above, loose matches on Subject: below --
2003-05-05 22:03 Thomas Heinz
2001-03-04 22:41 kmalloc() alignment Manfred Spraul
2001-03-06  0:06 ` Kenn Humborg
2001-03-06  0:15   ` H. Peter Anvin
2001-03-06  0:29     ` Kenn Humborg
2001-03-06  2:14       ` Alan Cox
2001-03-06  5:05         ` H. Peter Anvin
2001-03-06  8:31     ` Rogier Wolff
2001-03-06 12:10       ` Xavier Bestel
2001-03-04 22:17 Kenn Humborg
2001-03-04 22:34 ` Alan Cox
2001-03-05  9:40   ` Rogier Wolff
2001-03-05 13:24     ` Alan Cox
2001-03-05 13:22       ` Rogier Wolff
2001-03-06  8:59   ` Philipp Rumpf
2001-03-06 12:14     ` Alan Cox

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=20041019165901.GA18385@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=anemo@mba.ocn.ne.jp \
    --cc=linux-mips@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.