From: Paulo Marques <pmarques@grupopie.com>
To: dtor_core@ameritech.net
Cc: Pekka Enberg <penberg@cs.helsinki.fi>,
akpm@osdl.org, linux-kernel@vger.kernel.org,
Takashi Iwai <tiwai@suse.de>
Subject: Re: [PATCH 8/8] ALSA: convert kcalloc to kzalloc
Date: Fri, 05 Aug 2005 17:10:13 +0100 [thread overview]
Message-ID: <42F38F65.402@grupopie.com> (raw)
In-Reply-To: <d120d5000508050822f18c9ac@mail.gmail.com>
Dmitry Torokhov wrote:
> On 8/5/05, Pekka Enberg <penberg@cs.helsinki.fi> wrote:
>
>>This patch converts kcalloc(1, ...) calls to use the new kzalloc() function.
>>
>
>
> Hi,
>
> 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)
Arghh... I've been bitten by this before, too.
Pekka, the sound subsystem uses its own allocation functions that are
just defined to the standard kernel counterparts when
CONFIG_SND_DEBUG_MEMORY is not defined, but that map to their own
functions that add aditional debug information when that config is set.
To play well with the current structure you have to define you own
snd_hidden_kzalloc(size, flags) and use the same scheme.
For my previous encounter with this problem search a thread named
"replace snd_kmalloc_strdup by kstrdup". The patch there might useful to
you.
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.
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?
--
Paulo Marques
Software Development Department - Grupo PIE, S.A.
Phone: +351 252 290600, Fax: +351 252 290601
Web: www.grupopie.com
It is a mistake to think you can solve any major problems
just with potatoes.
Douglas Adams
next prev parent reply other threads:[~2005-08-05 16:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-05 14:50 [PATCH 0/8] convert kcalloc to kzalloc Pekka Enberg
2005-08-05 14:50 ` [PATCH 1/8] IA64: " Pekka Enberg
2005-08-05 14:50 ` [PATCH 2/8] PPC64: " Pekka Enberg
2005-08-05 14:51 ` [PATCH 3/8] input: " Pekka Enberg
2005-08-05 14:51 ` [PATCH 4/8] USB: " Pekka Enberg
2005-08-05 14:51 ` [PATCH 5/8] PCI: " Pekka Enberg
2005-08-05 14:51 ` [PATCH 6/8] drivers: " Pekka Enberg
2005-08-05 14:51 ` [PATCH 7/8] fs: " Pekka Enberg
2005-08-05 14:52 ` [PATCH 8/8] ALSA: " Pekka Enberg
2005-08-05 15:22 ` Dmitry Torokhov
2005-08-05 16:10 ` Paulo Marques [this message]
2005-08-06 12:37 ` Pekka Enberg
2005-08-08 10:20 ` Takashi Iwai
2005-08-06 12:52 ` Pekka Enberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42F38F65.402@grupopie.com \
--to=pmarques@grupopie.com \
--cc=akpm@osdl.org \
--cc=dtor_core@ameritech.net \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox