Re: [PATCH 8/8] ALSA: convert kcalloc to kzalloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

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.

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.

		Pekka

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux