diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-03-12 16:23:44 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-03-12 16:23:44 -0300 |
commit | 9e0da75b38a18187f11535f7b1ee6cfc2eb78a17 (patch) | |
tree | c587e0d49a92f331c7483a512cf5db3452859356 /linux/drivers | |
parent | a5b5a69be467cef37fea682521632a40f67204a9 (diff) | |
download | mediapointer-dvb-s2-9e0da75b38a18187f11535f7b1ee6cfc2eb78a17.tar.gz mediapointer-dvb-s2-9e0da75b38a18187f11535f7b1ee6cfc2eb78a17.tar.bz2 |
reduce stack usage of v4l1_compat_sync
From: Marcin Slusarz <marcin.slusarz@gmail.com>
poll_one allocated on stack struct poll_wqueues which is pretty big
structure (>500 bytes on x86_64). v4l1_compat_sync invokes poll_one
in a loop, so allocate struct poll_wqueues in v4l1_compat_sync (with
kmalloc) and pass it to poll_one.
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers')
-rw-r--r-- | linux/drivers/media/video/v4l1-compat.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/linux/drivers/media/video/v4l1-compat.c b/linux/drivers/media/video/v4l1-compat.c index 90d5f9b38..9fe2f491d 100644 --- a/linux/drivers/media/video/v4l1-compat.c +++ b/linux/drivers/media/video/v4l1-compat.c @@ -200,21 +200,13 @@ pixelformat_to_palette(unsigned int pixelformat) /* ----------------------------------------------------------------- */ -static int poll_one(struct file *file) +static int poll_one(struct file *file, struct poll_wqueues *pwq) { int retval = 1; poll_table *table; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,48) - poll_table wait_table; - poll_initwait(&wait_table); - table = &wait_table; -#else - struct poll_wqueues pwq; /*TODO: allocate dynamically*/ - - poll_initwait(&pwq); - table = &pwq.pt; -#endif + poll_initwait(pwq); + table = &pwq->pt; for (;;) { int mask; set_current_state(TASK_INTERRUPTIBLE); @@ -229,11 +221,7 @@ static int poll_one(struct file *file) schedule(); } set_current_state(TASK_RUNNING); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,48) - poll_freewait(&wait_table); -#else - poll_freewait(&pwq); -#endif + poll_freewait(pwq); return retval; } @@ -1080,6 +1068,7 @@ static noinline int v4l1_compat_sync( int err; enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; struct v4l2_buffer buf; + struct poll_wqueues *pwq; memset(&buf, 0, sizeof(buf)); buf.index = *i; @@ -1103,10 +1092,11 @@ static noinline int v4l1_compat_sync( goto done; } + pwq = kmalloc(sizeof(*pwq), GFP_KERNEL); /* Loop as long as the buffer is queued, but not done */ while ((buf.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE)) == V4L2_BUF_FLAG_QUEUED) { - err = poll_one(file); + err = poll_one(file, pwq); if (err < 0 || /* error or sleep was interrupted */ err == 0) /* timeout? Shouldn't occur. */ break; @@ -1114,6 +1104,7 @@ static noinline int v4l1_compat_sync( if (err < 0) dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err); } + kfree(pwq); if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */ goto done; do { |