The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Martin Drab <drab@kepler.fjfi.cvut.cz>
Cc: hugh@veritas.com,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"Bryan O'Sullivan" <bos@serpentine.com>
Subject: Re: Question about memory mapping mechanism
Date: Thu, 08 Mar 2007 16:27:53 -0800	[thread overview]
Message-ID: <45F0AA09.8070503@goop.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0703081345010.21317@kepler.fjfi.cvut.cz>

Martin Drab wrote:
> Hi,
>
> I'm writing a driver for a sampling device that is constantly delivering a 
> relatively high amount of data (about 16 MB/s) and I need to deliver the 
> data to the user-space ASAP. To prevent data loss I create a queue of 
> buffers (consisting of few pages each) which are more or less directly 
> filled by the device and then mapped to the user-space via mmap().
>
> The thing is that I'd like to prevent kernel to swap these pages out, 
> because then I may loose some data when they are not available in time 
> for the next round.
>
> My original idea (that used to work in the past) was to allocate the 
> buffers using __get_free_pages(), then pin the pages down by setting their 
> PG_reserved bit in the page flags before using them. And then set the 
> VM_RESERVED flag of the appropriate VMA when mmap() is called for these 
> pages that are then mapped using nopage() mechanism.
>
> But this way no longer seems to work correctly, it kind of works, but I'm 
> getting following messages for each mmapped page upon munmap() call:
>
> --------------------------------------
> [19172.939248] Bad page state in process 'dtrtest'
> [19172.939249] page:ffff81000160a978 flags:0x001a000000000404 mapping:0000000000000000 mapcount:0 count:0
> [19172.939251] Trying to fix it up, but a reboot is needed
> [19172.939253] Backtrace:
> [19172.939256]
> [19172.939257] Call Trace:
> [19172.939273]  [<ffffffff802adc37>] bad_page+0x57/0x90
> [19172.939280]  [<ffffffff8020b92f>] free_hot_cold_page+0x7f/0x180
> [19172.939287]  [<ffffffff80207a90>] unmap_vmas+0x450/0x750
> [19172.939308]  [<ffffffff80212867>] unmap_region+0xb7/0x160
> [19172.939318]  [<ffffffff80211918>] do_munmap+0x238/0x2f0
> [19172.939325]  [<ffffffff802656c5>] __down_write_nested+0x35/0xf0
> [19172.939334]  [<ffffffff80215ffd>] sys_munmap+0x4d/0x80
> [19172.939341]  [<ffffffff8025f11e>] system_call+0x7e/0x83
> -------------------------------
>
> Aparently due to the PG_reserved bit set.
>
> So my question is: What is currently a proper way to do all this cleanly?
>   


Have you looked at the Infiniband stuff?  I know the folks working on
the ipath driver eventually got this kind of thing working in a sane way.

    J

  parent reply	other threads:[~2007-03-09  0:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-08 13:16 Question about memory mapping mechanism Martin Drab
2007-03-08 14:20 ` Carsten Otte
     [not found] ` <5c77e7070703080617r63cbccfevd2c6d678f16c2b03@mail.gmail.com>
2007-03-08 21:36   ` Martin Drab
2007-03-09  0:07     ` Martin Drab
2007-03-09  1:31       ` Martin Drab
2007-03-13 20:49         ` Hugh Dickins
2007-05-21 18:39           ` Martin Drab
2007-05-29 17:58             ` Hugh Dickins
2007-03-08 23:21 ` Martin Drab
2007-03-09  0:27 ` Jeremy Fitzhardinge [this message]
2007-03-09  0:38   ` Martin Drab
     [not found] <fa.8Fy6n0Le4Y2mDfeEy936/5bbJHA@ifi.uio.no>
2007-03-09  0:35 ` Robert Hancock
2007-03-09  0:52   ` Martin Drab

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=45F0AA09.8070503@goop.org \
    --to=jeremy@goop.org \
    --cc=bos@serpentine.com \
    --cc=drab@kepler.fjfi.cvut.cz \
    --cc=hugh@veritas.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