All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Greear <greearb@candelatech.com>
To: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: Reading NFS file without copying to user-space?
Date: Fri, 04 Sep 2009 14:12:02 -0700	[thread overview]
Message-ID: <4AA182A2.5060507@candelatech.com> (raw)
In-Reply-To: <74C14419-4D21-4EC2-B01A-EAC04B354F06@fys.uio.no>

On 09/04/2009 01:58 PM, Trond Myklebust wrote:
> On Sep 4, 2009, at 16:49, Ben Greear <greearb@candelatech.com> wrote:
>
>> I'm using O_DIRECT (so that the server is continually stressed even if
>> the file would have otherwise been cached locally on the client).
>>
>> This still causes a copy of the contents to user-space when I do a
>> read() call though, as far as I can tell. Since I'm normally not looking
>> at this data at all, the memory copy from kernel to user is wasted
>> effort in my case.
>
> You're missing the point. O_DIRECT does not copy data from the kernel
> into userspace. The data is placed directly into the user buffer from
> the socket.

I may be going about things all wrong...

>
> The only faster alternative would be to directly discard the data in the
> socket, and we offer no option to do that.

I'm opening an fd like this:


          uint32 flgs = O_RDONLY | O_DIRECT | O_LARGEFILE;
          fd = open(fname, flgs);

Then read from the fd it:
          int retval = read(fd, rcv_buffer_ptr, my_read_len);

rcv_buffer_ptr is just a 1MB (or so) array of bytes.


Maybe I need to use aio_read with O_DIRECT to get the benefits you speak of?

Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


  reply	other threads:[~2009-09-04 21:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-04 19:48 Reading NFS file without copying to user-space? Ben Greear
2009-09-04 20:35 ` Trond Myklebust
     [not found]   ` <1252096543.2402.4.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-09-04 20:49     ` Ben Greear
2009-09-04 20:58       ` Trond Myklebust
2009-09-04 21:12         ` Ben Greear [this message]
2009-09-04 22:00           ` Trond Myklebust
2009-09-04 21:57         ` Ben Greear
2009-09-04 22:15           ` Trond Myklebust
     [not found]             ` <1252102506.5274.7.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-09-04 22:30               ` Ben Greear
2009-09-04 22:49                 ` Trond Myklebust
2009-09-04 23:03                   ` Ben Greear

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=4AA182A2.5060507@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@fys.uio.no \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.