提交 76e41e48 编写于 作者: M Marcin Slusarz 提交者: Mauro Carvalho Chehab

V4L/DVB (7365): reduce stack usage of v4l1_compat_sync

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: NMarcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 b524f7b0
...@@ -199,14 +199,13 @@ pixelformat_to_palette(unsigned int pixelformat) ...@@ -199,14 +199,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; int retval = 1;
poll_table *table; poll_table *table;
struct poll_wqueues pwq; /*TODO: allocate dynamically*/
poll_initwait(&pwq); poll_initwait(pwq);
table = &pwq.pt; table = &pwq->pt;
for (;;) { for (;;) {
int mask; int mask;
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
...@@ -221,7 +220,7 @@ static int poll_one(struct file *file) ...@@ -221,7 +220,7 @@ static int poll_one(struct file *file)
schedule(); schedule();
} }
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
poll_freewait(&pwq); poll_freewait(pwq);
return retval; return retval;
} }
...@@ -1068,6 +1067,7 @@ static noinline int v4l1_compat_sync( ...@@ -1068,6 +1067,7 @@ static noinline int v4l1_compat_sync(
int err; int err;
enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE;
struct v4l2_buffer buf; struct v4l2_buffer buf;
struct poll_wqueues *pwq;
memset(&buf, 0, sizeof(buf)); memset(&buf, 0, sizeof(buf));
buf.index = *i; buf.index = *i;
...@@ -1091,10 +1091,11 @@ static noinline int v4l1_compat_sync( ...@@ -1091,10 +1091,11 @@ static noinline int v4l1_compat_sync(
goto done; goto done;
} }
pwq = kmalloc(sizeof(*pwq), GFP_KERNEL);
/* Loop as long as the buffer is queued, but not done */ /* Loop as long as the buffer is queued, but not done */
while ((buf.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE)) while ((buf.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE))
== V4L2_BUF_FLAG_QUEUED) { == V4L2_BUF_FLAG_QUEUED) {
err = poll_one(file); err = poll_one(file, pwq);
if (err < 0 || /* error or sleep was interrupted */ if (err < 0 || /* error or sleep was interrupted */
err == 0) /* timeout? Shouldn't occur. */ err == 0) /* timeout? Shouldn't occur. */
break; break;
...@@ -1102,6 +1103,7 @@ static noinline int v4l1_compat_sync( ...@@ -1102,6 +1103,7 @@ static noinline int v4l1_compat_sync(
if (err < 0) if (err < 0)
dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err); dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err);
} }
kfree(pwq);
if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */ if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */
goto done; goto done;
do { do {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册