mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neeraj Kumar <neeraj.kumar01@ymail.com>
To: Robert Hancock <hancockrwd@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Doing a zero-copy move of data from a kernel buffer to hard disk
Date: Mon, 11 Oct 2010 18:10:24 -0700 (PDT)	[thread overview]
Message-ID: <177185.92462.qm@web113411.mail.gq1.yahoo.com> (raw)
In-Reply-To: <4C9955A5.9080604@gmail.com>



>On 09/20/2010 02:12 PM, Neeraj Kumar wrote:
>> I am trying to move data from a buffer in kernel space into the hard
>> disk without having to incur any additional copies from kernel buffer to
> >user buffers or any other kernel buffers. Any ideas/suggestions would be
> >most helpful.
>>
>>The use case is basically a demux driver which collects data into a
>> demux buffer in kernel space and this buffer has to be emptied
>>periodically by copying the contents into a FUSE-based partition on the
> disk. As the buffer gets full, a user process is signalled which then
>> determines the sector numbers on the disk the contents need to be copied
>> to.
>>
>> I was hoping to mmap the above demux kernel buffer into user address
>> space and issue a write system call to the raw partition device. But
>> from what I can see, the this data is being cached by the kernel on its
>> way to the Hard Disk driver. And so I am assuming that involves
>> additional copies by the linux kernel.
>>
>> At this point I am wondering if there is any other mechansim to do this
>> without involving additional copies by the kernel. I realize this is an
>> unsual usage scenario for non-embedded environments, but I would
>> appreciate any feedback on possible options.
>>
>> BTW - I have tried using O_DIRECT when opening the raw partition, but
>> the subsequent write call fails if the buffer being passed is the
>> mmapped buffer.

>O_DIRECT would be the right way to do it - I think you'd need to figure 
>out why that write is failing. Keep in mind you need to observe the 
>alignment restrictions of O_DIRECT (man 2 open).


I was able to figure out that O_DIRECT can not work with memory mapped 
pages. In the kernel, get_user_pages() returns error if user provided pages are 
mapped kernel pages.

Thanks
Neeraj



      

  reply	other threads:[~2010-10-12  1:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-20 20:12 Neeraj Kumar
2010-09-22  1:02 ` Robert Hancock
2010-10-12  1:10   ` Neeraj Kumar [this message]
2010-09-22  8:54 ` Miklos Szeredi
2010-10-12  0:58   ` Neeraj Kumar

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=177185.92462.qm@web113411.mail.gq1.yahoo.com \
    --to=neeraj.kumar01@ymail.com \
    --cc=hancockrwd@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

all inboxes | Powered by JetHome®