LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Marcin Slusarz <marcin.slusarz@gmail.com> To: LKML <linux-kernel@vger.kernel.org> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>, v4l-dvb-maintainer@linuxtv.org, video4linux-list@redhat.com, Jean Delvare <khali@linux-fr.org> Subject: [PATCH 3/3] v4l: reduce stack usage of v4l1_compat_sync Date: Sun, 9 Mar 2008 17:55:55 +0100 [thread overview] Message-ID: <1205081755-18455-1-git-send-email-marcin.slusarz@gmail.com> (raw) In-Reply-To: <1205081266-18368-1-git-send-email-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> Cc: Mauro Carvalho Chehab <mchehab@infradead.org> --- drivers/media/video/v4l1-compat.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c index aa73472..9f73d52 100644 --- a/drivers/media/video/v4l1-compat.c +++ b/drivers/media/video/v4l1-compat.c @@ -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; poll_table *table; - struct poll_wqueues pwq; /*TODO: allocate dynamically*/ - poll_initwait(&pwq); - table = &pwq.pt; + poll_initwait(pwq); + table = &pwq->pt; for (;;) { int mask; set_current_state(TASK_INTERRUPTIBLE); @@ -221,7 +220,7 @@ static int poll_one(struct file *file) schedule(); } set_current_state(TASK_RUNNING); - poll_freewait(&pwq); + poll_freewait(pwq); return retval; } @@ -1043,6 +1042,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; @@ -1066,10 +1066,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; @@ -1077,6 +1078,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 { -- 1.5.3.7
prev parent reply other threads:[~2008-03-09 16:56 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-03-09 16:47 [PATCH 0/3] v4l: reduce stack usage Marcin Slusarz 2008-03-09 16:47 ` [PATCH 1/3] v4l: fix coding style violations in v4l1-compat.c Marcin Slusarz 2008-03-10 17:57 ` Mauro Carvalho Chehab 2008-03-09 16:53 ` [PATCH 2/3] v4l: reduce stack usage of v4l_compat_translate_ioctl Marcin Slusarz 2008-03-09 16:55 ` Marcin Slusarz [this message]
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=1205081755-18455-1-git-send-email-marcin.slusarz@gmail.com \ --to=marcin.slusarz@gmail.com \ --cc=khali@linux-fr.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mchehab@infradead.org \ --cc=v4l-dvb-maintainer@linuxtv.org \ --cc=video4linux-list@redhat.com \ /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: linkBe 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; as well as URLs for NNTP newsgroup(s).