public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Ronen Shitrit <rshitrit@marvell.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: DIrectIO using kernel buffers
Date: Tue, 17 Oct 2006 15:25:19 +0200	[thread overview]
Message-ID: <20061017132519.GE7854@kernel.dk> (raw)
In-Reply-To: <B9FFC3F97441D04093A504CEA31B7C41E915E1@msilexch01.marvell.com>

On Mon, Oct 16 2006, Ronen Shitrit wrote:
> Hi
> 
> I'm using kernel 2.6.12.
> I'm trying to improve the usb gadget file storage implementation by
> making it accessing the file storage with O_DIRECT,
> In general what I'm trying to do is use DirectIO with buffer which was
> allocated by kmalloc.
> 
> When trying to do so I get kernel panic, after some debug, I found that
> I can't call get_user_pages on pages allocated by the kernel (kmalloc),
> Is it correct??
> Any way, I implemented some basic function get_kernel_pages to fill the
> page array with the pages pointer of the kernel buffer,
> Then I got lots of errors on illegal buffer freeing, I did some more
> debug and I found that the direct-io is using the get_page and put_page
> in order to increment the counter of the page and to make sure no one
> will release them while the direct-io is using them, after the direct-io
> is doing put_page it check if the page_count is 0, if so it release it
> (see page_cache_release in direct-io.c), by doing this the direct-io is
> trying to release the pages which I allocated by kmalloc and I get
> errors.
> So what I get is that the direct-io increments the count and then
> decrements it and the count get to zero,
> So I checked the count of the pages which I got from kmalloc and I found
> that only the first page count is 0 (i.e. one process is using it) and
> the rest were initialized by -1 (i.e. no process is using this buffer),
> Is this a bug??
> Any suggestion on how to use DirectIO with kernel buffers??

get_user_pages(), as the name infers, deals with user memory not memory
allocated with kmalloc(). Rewrite your code to generate the page vec
manually allocating individual pages at the time, it's silly to allocate
contigious memory and then split that up afterwards.

-- 
Jens Axboe


      reply	other threads:[~2006-10-17 13:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-16 15:11 DIrectIO using kernel buffers Ronen Shitrit
2006-10-17 13:25 ` Jens Axboe [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=20061017132519.GE7854@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rshitrit@marvell.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