[llvmlinux] [PATCH 1/2] [WIP] Fix slab allocator bootstrap.

Daniel Sanders Daniel.Sanders at imgtec.com
Fri Dec 19 14:04:02 UTC 2014


There are currently two functions that generate indices into kmalloc_caches and
they disagree with each other.  This patch fixes the bug to the point that the
LLVM-compiled kernel successfully boots for Mips but it will need further work
before upstreaming.

The failing sequence is:
* kmalloc_caches contains NULL elements
* kmem_cache_init initialises the element that 'struct kmem_cache_node' will be
  allocated to. For 32-bit Mips, this is a 56-byte struct and kmalloc_index
  selects element 7.
* init_list is called which calls kmalloc_node to allocate a 'struct
  kmem_cache_node'.
* kmalloc_slab selects the kmem_caches element using
  size_index[size_index_elem(size)]. For Mips, size is 56, and the expression
  returns 6.
* This element of kmalloc_caches is NULL and allocation fails.

GCC does not normally encounter this bug. I believe this is because it manages
to optimise the problematic allocation away. This theory is supported by GCC
encountering this bug when I disable inlining by changing the definitions of
inline, __inline, __inline__, and __always_inline in
include/linux/compiler-gcc.h.

Signed-off-by: Daniel Sanders daniel.sanders at imgtec.com<mailto:daniel.sanders at imgtec.com>
--

This is the first of two patches that fix the boot for Mips.

Daniel Sanders
Leading Software Design Engineer, MIPS Processor IP
Imagination Technologies Limited
www.imgtec.com<http://www.imgtec.com/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/llvmlinux/attachments/20141219/3c5fdd3d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-WIP-Fix-slab-allocator-bootstrap.patch
Type: application/octet-stream
Size: 4011 bytes
Desc: 0001-WIP-Fix-slab-allocator-bootstrap.patch
URL: <http://lists.linuxfoundation.org/pipermail/llvmlinux/attachments/20141219/3c5fdd3d/attachment.obj>


More information about the LLVMLinux mailing list