public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: M vd S <mvds.00@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: O_NONBLOCK is NOOP on block devices
Date: Wed, 10 Mar 2010 01:50:37 +0100	[thread overview]
Message-ID: <4B96ECDD.1070006@gmail.com> (raw)
In-Reply-To: <4B9060DE.4080104@gmail.com>


> mmap(2) / madvise(2) / mincore(2) may be a way around things (although 
> non-atomic), but I haven't tested it yet. It might also solve the 
> problem that started this thread, at least for the reading part of it. 
> Writing a small read() like function that operates through mmap() 
> doesn't seem too complicated. As for writing, you could use msync() 
> with MS_ASYNC to initiate a write. I'm not sure how to find out if a 
> write has indeed taken place, but at least initiating a non-blocking 
> write is possible. munmap() might then still block.
>

For the record I would like to share my very positive experience with 
the approach described. Thanks to 64 bit addressing you can mmap() an 
entire block device, and madvise() and mincore() work like you would 
expect them to. I haven't tried writing.

I also briefly tried aio_* and the libaio interface. The former is not 
really asynchronous - all requests are put in one separate thread where 
they will be executed in order, i.e. blocking, so you don't get any 
advantage from NCQ or data that was cached by the disk or the kernel. 
The latter apparently ends in an io_submit() which will block until all 
queued reads are finished, but I might have missed something there.

Imagine the orderly world in which O_NONBLOCK would make syscalls 
actually non-blocking...

Cheers,
M.


  parent reply	other threads:[~2010-03-10  0:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4B904D98.50602@gmail.com>
2010-03-05  1:39 ` O_NONBLOCK is NOOP on block devices M vd S
2010-03-05 16:03   ` Jeff Moyer
2010-03-05 19:43     ` Mike Hayward
2010-03-10  0:50   ` M vd S [this message]
2010-03-10 13:21     ` Jeff Moyer
2010-03-10 17:09       ` M vd S
     [not found]         ` <201003102350.o2ANousd007794@alien.loup.net>
     [not found]           ` <4B983E88.5080901@gmail.com>
2010-03-11  7:41             ` Mike Hayward
2010-03-03  8:26 Mike Hayward
2010-03-03 11:50 ` Alan Cox
2010-03-03 19:49   ` Mike Hayward
2010-03-03 21:25     ` Alan Cox

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=4B96ECDD.1070006@gmail.com \
    --to=mvds.00@gmail.com \
    --cc=linux-kernel@vger.kernel.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