Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935880AbXLQVzc (ORCPT ); Mon, 17 Dec 2007 16:55:32 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760215AbXLQVzW (ORCPT ); Mon, 17 Dec 2007 16:55:22 -0500 Received: from courier.cs.helsinki.fi ([128.214.9.1]:58413 "EHLO mail.cs.helsinki.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755399AbXLQVzU (ORCPT ); Mon, 17 Dec 2007 16:55:20 -0500 Date: Mon, 17 Dec 2007 23:55:17 +0200 (EET) From: Pekka J Enberg To: John Reiser cc: linux-kernel@vger.kernel.org Subject: Re: slab quirks in DEBUG, ctor, and initialization In-Reply-To: <4766E7D7.6050003@BitWagon.com> Message-ID: References: <47669A16.3010604@BitWagon.com> <84144f020712171151j5e2a2934qc8bf2fbc9020a545@mail.gmail.com> <4766E7D7.6050003@BitWagon.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1009 Lines: 22 Hi John, On Mon, 17 Dec 2007, John Reiser wrote: > idr_pre_get calls kmem_cache_alloc, which constructs 'struct idr_layer' > via the cachep->ctor() call from cache_alloc_debugcheck_after to > idr_cache_ctor, and not via cache_init_objs. So if DEBUG is off, > then idr_cache_ctor does not get its chance to call memset, > which could leave the struct idr_layer potentially undefined. No, init_cache_objs() will call the constructor, if the cache has one when DEBUG is not set so the struct idr_layer can never be undefined. However, struct idr_layer can contain non-zero elements if someone does a kmem_cache_free() on an object that hasn't been zeroed. If that matters here, idr_pre_get should call kmem_cache_zalloc() and drop the constructor. Pekka -- 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/