linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Mackall <mpm@selenic.com>
To: Vladimir Kondratiev <vladimir.kondratiev@intel.com>
Cc: linux-kernel@vger.kernel.org,
	Marcelo Tosatti <marcelo@conectiva.com.br>,
	Alexander Viro <viro@math.psu.edu>
Subject: Re: PATCH: seq_file interface to provide large data chunks
Date: Fri, 11 Jul 2003 10:13:52 -0500	[thread overview]
Message-ID: <20030711151352.GM27280@waste.org> (raw)
In-Reply-To: <3F0D217B.4040900@intel.com>

On Thu, Jul 10, 2003 at 11:19:07AM +0300, Vladimir Kondratiev wrote:
> seq_file interface, as it exist in last official kernel, never provides 
> more then one page for each 'read' call. Old read_proc_t did loop to 
> fill more than one page.
> 
> Following patch against 2.4.21 fixes seq_file to provide more than one 
> page if user requests it.
> Many programs do read(large_buffer) once, instead of looping while 
> read()>0. They work wrong with seq_file. Also, one may expect read() to 
> provide whole information atomically (OK, relatively to other process 
> context stuff).
> This patch loops over while some space remains in user provided buffer.
> 
> I am not subscribed to lkml, thus please cc: me (Vladimir Kondratiev 
> <vladimir.kondratiev@intel.com>) explicitly.
> 
> +++ linux/fs/seq_file.c    2003-07-10 10:47:53.000000000 +0300
> @@ -55,6 +55,7 @@
>         return -EPIPE;
> 
>     down(&m->sem);
> +Again:
>     /* grab buffer if we didn't have one */
>     if (!m->buf) {
>         m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
> @@ -123,11 +124,14 @@
>         goto Efault;
>     copied += n;
>     m->count -= n;
> +    size -= n;
> +    buf += n;
>     if (m->count)
>         m->from = n;
>     else
>         pos++;
>     m->index = pos;
> +    goto Again;
> Done:
>     if (!copied)
>         copied = err;

This patch looks rather tab damaged.

I think it's problematic in that it can hold the semaphore for an
unbounded amount of time.

I'd suggest dropping and acquiring the semaphore each time through the
loop, but then you get into a situation where a second process can
cause the returned results to no longer be coherent. Since we'd no
longer have a way to get single results, this'd be bad.

-- 
Matt Mackall : http://www.selenic.com : of or relating to the moon

      parent reply	other threads:[~2003-07-11 14:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-10  8:19 PATCH: seq_file interface to provide large data chunks Vladimir Kondratiev
2003-07-10 11:09 ` Alan Cox
2003-07-10 12:12   ` Vladimir Kondratiev
2003-07-15 11:57   ` Vladimir Kondratiev
2003-07-11 15:13 ` Matt Mackall [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=20030711151352.GM27280@waste.org \
    --to=mpm@selenic.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    --cc=viro@math.psu.edu \
    --cc=vladimir.kondratiev@intel.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: 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;
as well as URLs for NNTP newsgroup(s).