mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Licquia <licquia@progeny.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] 2.6.13: POSIX violation in pipes on ia64 for kernels > 2.6.10
Date: Thu, 13 Oct 2005 15:37:26 -0500	[thread overview]
Message-ID: <1129235846.4573.36.camel@laptop1> (raw)
In-Reply-To: <Pine.LNX.4.64.0510131250070.23590@g5.osdl.org>

On Thu, 2005-10-13 at 12:54 -0700, Linus Torvalds wrote:
> It also sounds like your patch is broken: allowing partial short writes is 
> in explicit violation of the POSIX specs, and breaks the only thing that 
> PIPE_BUF _really_ guarantees, namely that writes smaller than that size 
> must be atomic.

That guarantee is still there, because short writes take place on the
last buffer in use.  We either have a full PAGE_SIZE or more bytes in
the next available buffer(s), or we're on the last buffer, and the
max_write code kicks in and we control writes in PIPE_BUF increments.

I wrote a short test program to make sure writes < PIPE_BUF length are
still atomic (by reading PIPE_BUF/2 bytes from a full pipe and then
trying to write PIPE_BUF * (3/4) bytes to it), and the behavior seems to
be correct (ret = -1, errno = EAGAIN).

> The _only_ guarantees wrt PIPE_BUF is literally that a write smaller than 
> or equal to the PIPE_BUF will always either complete fully or not at all, 
> and that a reader will see the write as an atomic packet (ie two writers 
> will never have their write buffers interleaved within such a single 
> "write()" system call).
> 
> How empty the pipe has to be for a write to be able to do so is outside 
> the spec, and any code (including LSB tests) that depends on it is broken.

Hmm.  My reading was different, but on reflection you seem to be more
accurate.  I suppose I will have to bring this to the attention to the
LSB.

I will give one more reason to consider the patch.  Whatever the spec
said, the kernel's behavior has changed, and only for certain
architectures.  On ia64 (at least), the amount one must read from a pipe
in order to unblock it cannot be determined except via extreme means
(parsing a kernel config, doing test pipe I/O to try and deduce
PAGE_SIZE, etc.)  There may be benefit in restoring the previous
behavior, which my patch does without sacrificing the benefits of the
new pipe code.

Of course, that's up to you to decide.  Thanks for your time.


      reply	other threads:[~2005-10-13 20:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-13 19:44 Jeff Licquia
2005-10-13 19:54 ` Linus Torvalds
2005-10-13 20:37   ` Jeff Licquia [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=1129235846.4573.36.camel@laptop1 \
    --to=licquia@progeny.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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

all inboxes | Powered by JetHome®