isdn: reduce stack size of mISDN_dsp
PATCH 1/1 isdn: reduce stack size of mISDN_dsp
From: Frank Seidel <[email protected]>
Reduce stack size memory footprint of mISDN_dsp.
(From 1468 bytes for dsp_cmx_send on i386 down
to 44).
--- drivers/isdn/mISDN/dsp_cmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/isdn/mISDN/dsp_cmx.c +2 -1
@@ -1592,7 +1592,8 @@ dsp_cmx_send(void *arg)struct dsp_conf_member *member;struct dsp *dsp;int mustmix, members; -s32 mixbuffer[MAX_POLL +100 ], *c; +static s32 mixbuffer[MAX_POLL +100 ]; +s32 *c;u8 *p, *q;int r, rr;int jittercheck =0 , delay, i;
Quoted 6 lines · Frank Seidel
From: Frank Seidel <[email protected]>
Reduce stack size memory footprint of
mISDN_dsp.
(From 1468 bytes fordsp_cmx_sendon i386 down
to 44).
I do not think we can use a static buffer here,
we may have multiple instances.
Quoted 17 lines
Signed-off-by Frank Seidel <[email protected]>--- drivers/isdn/mISDN/dsp_cmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/isdn/mISDN/dsp_cmx.c +2
-1@@ -1592,7 +1592,8 @@ dsp_cmx_send(void *arg)struct dsp_conf_member *member;struct dsp *dsp;int mustmix, members; -s32 mixbuffer[MAX_POLL +100 ], *c; +static s32 mixbuffer[MAX_POLL +100 ]; +s32 *c;u8 *p, *q;int r, rr;int jittercheck =0 , delay, i;
Signature · 4 lines
Karsten Keil SuSE Labs ISDN and VOIP development SUSE LINUX Products GmbH, Maxfeldstr.5 90409 Nuernberg, GF: Markus Rex, HRB 16746 (AG Nuernberg)
Quoted 2 lines · Karsten Keil
I do not think we can use a static buffer here,
we may have multiple instances.
Oh, i see. So i'll redo the patch with
kmalloc/kfree.
Thanks,
Frank
PATCH v2 1/1 isdn: reduce stack size of mISDN_dsp
In reply to Frank SeidelFrom: Frank Seidel <[email protected]>
Reduce stack size memory footprint of mISDN_dsp.
(From 1468 bytes for dsp_cmx_send on i386 down
to 44).
--- drivers/isdn/mISDN/dsp_cmx.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/isdn/mISDN/dsp_cmx.c +11 -1
@@ -1592,13 +1592,21 @@ dsp_cmx_send(void *arg)struct dsp_conf_member *member;struct dsp *dsp;int mustmix, members; -s32 mixbuffer[MAX_POLL +100 ], *c; +s32 *mixbuffer; +s32 *c;u8 *p, *q;int r, rr;int jittercheck =0 , delay, i;u_long flags;u16 length, count; + mixbuffer =kmalloc (sizeof (*mixbuffer) * (MAX_POLL +100 ),GFP_KERNEL ); +if (!mixbuffer) { +printk (KERN_ERR "mISDN_dsp: cannot allocate buffer(%s)\n" , + __func__); +return ; + } +/* lock */ spin_lock_irqsave (&dsp_lock, flags);
@@ -1811,6 +1819,8 @@ dsp_cmx_send(void *arg)/* unlock */ spin_unlock_irqrestore (&dsp_lock, flags); + +kfree (mixbuffer); }/*
Quoted 5 lines · Frank Seidel
From: Frank Seidel <[email protected]>
Reduce stack size memory footprint of
mISDN_dsp.
(From 1468 bytes fordsp_cmx_sendon i386 down
to 44).
Looks safer and has the same function as before, but I think we should work on a better solution later, which use one buffer per instance and allocate it on creation time. Andreas, what do you think ?
Quoted 40 lines
Signed-off-by Frank Seidel <[email protected]>--- drivers/isdn/mISDN/dsp_cmx.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)drivers/isdn/mISDN/dsp_cmx.c +11
-1@@ -1592,13 +1592,21 @@ dsp_cmx_send(void *arg)struct dsp_conf_member *member;struct dsp *dsp;int mustmix, members; -s32 mixbuffer[MAX_POLL +100 ], *c; +s32 *mixbuffer; +s32 *c;u8 *p, *q;int r, rr;int jittercheck =0 , delay, i;u_long flags;u16 length, count; + mixbuffer =kmalloc (sizeof (*mixbuffer) * (MAX_POLL +100 ),GFP_KERNEL ); +if (!mixbuffer) { +printk (KERN_ERR "mISDN_dsp: cannot allocate buffer(%s)\n" , + __func__); +return ; + } +/* lock */ spin_lock_irqsave (&dsp_lock, flags);@@ -1811,6 +1819,8 @@ dsp_cmx_send(void *arg)/* unlock */ spin_unlock_irqrestore (&dsp_lock, flags); + +kfree (mixbuffer); }/*
Signature · 1 line
Karsten Keil