Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756767AbbBEIhh (ORCPT ); Thu, 5 Feb 2015 03:37:37 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:54042 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756693AbbBEIhf (ORCPT ); Thu, 5 Feb 2015 03:37:35 -0500 X-Sasl-enc: /NOycUtdxt3+mzClxduwzM9pyhnZJqzpWT+3mZIjNhX+ 1423125454 Message-ID: <54D32BCC.1010608@iki.fi> Date: Thu, 05 Feb 2015 10:37:32 +0200 From: Pekka Enberg User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Daniel Sanders CC: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/5] slab: Correct size_index table before replacing the bootstrap kmem_cache_node. References: <1423084015-24010-1-git-send-email-daniel.sanders@imgtec.com> In-Reply-To: <1423084015-24010-1-git-send-email-daniel.sanders@imgtec.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2118 Lines: 45 On 02/04/2015 11:06 PM, Daniel Sanders wrote: > This patch moves the initialization of the size_index table slightly > earlier so that the first few kmem_cache_node's can be safely allocated > when KMALLOC_MIN_SIZE is large. > > There are currently two ways to generate indices into kmalloc_caches > (via kmalloc_index() and via the size_index table in slab_common.c) > and on some arches (possibly only MIPS) they potentially disagree with > each other until create_kmalloc_caches() has been called. It seems > that the intention is that the size_index table is a fast equivalent > to kmalloc_index() and that create_kmalloc_caches() patches the table > to return the correct value for the cases where kmalloc_index()'s > if-statements apply. > > The failing sequence was: > * 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 returns KMALLOC_SHIFT_LOW (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. > * If it had not already failed, it would have called > create_kmalloc_caches() at this point which would have changed > size_index[size_index_elem(size)] to 7. > > Signed-off-by: Daniel Sanders > Cc: Christoph Lameter > Cc: Pekka Enberg > Cc: David Rientjes > Cc: Joonsoo Kim > Cc: Andrew Morton > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org Acked-by: Pekka Enberg -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/