From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750809AbVHHKVA (ORCPT ); Mon, 8 Aug 2005 06:21:00 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750807AbVHHKVA (ORCPT ); Mon, 8 Aug 2005 06:21:00 -0400 Received: from cantor2.suse.de ([195.135.220.15]:60827 "EHLO mx2.suse.de") by vger.kernel.org with ESMTP id S1750806AbVHHKU7 (ORCPT ); Mon, 8 Aug 2005 06:20:59 -0400 Date: Mon, 08 Aug 2005 12:20:57 +0200 Message-ID: From: Takashi Iwai To: Pekka Enberg Cc: Paulo Marques , dtor_core@ameritech.net, akpm@osdl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 8/8] ALSA: convert kcalloc to kzalloc In-Reply-To: <1123331844.11074.6.camel@haji.ri.fi> References: <42F38F65.402@grupopie.com> <1123331844.11074.6.camel@haji.ri.fi> User-Agent: Wanderlust/2.12.0 (Your Wildest Dreams) SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (=?ISO-8859-4?Q?Sanj=F2?=) APEL/10.6 MULE XEmacs/21.5 (beta18) (chestnut) (+CVS-20041021) (i386-suse-linux) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org At Sat, 06 Aug 2005 15:37:24 +0300, Pekka Enberg wrote: > > Hi, > > Dmitry Torokhov wrote: > > > Have you seen the following in include/sound/core? > > > > > > ... > > > #define kmalloc(size, flags) snd_hidden_kmalloc(size, flags) > > > #define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags) > > > #define kfree(obj) snd_hidden_kfree(obj) > > On Fri, 2005-08-05 at 17:10 +0100, Paulo Marques wrote: > > Arghh... I've been bitten by this before, too. > > Me too. I understand. I would love to drop this feature if it's supported in the kernel generically. > On Fri, 2005-08-05 at 17:10 +0100, Paulo Marques wrote: > > I really hate this "#define kmalloc" hack. It makes the code really > > unreadble, because you expect a kmalloc to be just a kmalloc... > > > > Couldn't we turn this into a generic kernel debugging option, so that it > > could be used for every kmalloc instead of just the ones from the sound > > system? > > > > If I get this right, what this code does is to track kfree's on pointers > > that were not alloc'ed with kmalloc (using a magic number) and keep > > track of all the allocations to detect leaks. > > Yes, that's what it does. It also has a similar check for vmalloc(), but it's less important than kmalloc() (also for vmalloc, it doesn't nice since it breaks the size and the alignment). > On Fri, 2005-08-05 at 17:10 +0100, Paulo Marques wrote: > > We already have SLAB_DEBUG. We could add a list of allocations with a > > proc interface (or something) to give an histogram of kmalloc callers / > > number of allocations not yet freed. > > > > This way, if after stopping everything related to sound there were still > > callers like "snd_xxxx" (through kallsyms) you would know there is a > > leak there. > > > > What does CONFIG_SND_DEBUG_MEMORY provide that this more generic scheme > > does not? > > I would like to make it generic too. CONFIG_SND_DEBUG_MEMORY has the > advantage of snd_memory_done() which can detect memory leaks in their > modules automatically. Therefore, to replace the ALSA magic allocator, > we would need to track which module did the allocation and add hooks to > module_exit. Yep, this would be nice to have. The memory leak detection per module (or subsystem) helped us many times indeed. Takashi