From: Stevie-O <oliver@klozoff.com>
To: linux-kernel@vger.kernel.org
Subject: Aliasing physical memory using virtual memory (from a driver's perspective)
Date: Wed, 17 Sep 2003 19:36:36 -0400 [thread overview]
Message-ID: <3F68F004.7020107@klozoff.com> (raw)
I'm working on a driver for a PCI card that outputs a LOT of data. Think tens
of megabytes per second.
Each separate DMA transfer is for about 640KB of data. Since the standard PC
architecture was designed too cheaply to have a set of DMA remapping registers,
it's highly unlikely that even in That Other OS will one find 160 consecutive
free pages. Thus, the card has a built-in scatter-gather mechanism.
The driver needs to do some processing on each 640KB chunk before passing it
onto userspace (there are reasons why this processing can't happen in userspace,
that's all anyone should need to know). There's a sort-of-a-shortcut that is
currently done that processes 9 pages worth at once. Since the 9 pages need to
be contiguous, the driver (sadly) kmalloc()s the scatter-gather buffer in 9-page
chunks; if I understand the slab stuff correctly, this actually winds up
allocating 16 *consecutive* pages for each sub-buffer. 16 consecutive pages is
still kinda hard to come by, however, so the driver allocates a very large
pile at startup.
The card uses physical memory, but if I understand things correctly (which I
probably don't), the driver/kernel runs on virtual memory.
My thinking is this: I want to use __get_free_pages(1) 80 times to get the 160
pages, then passed those 80 pieces to the card (it's known the card can handle
requests with that many pieces). Then I want to create a *virtually* contiguous
160-page mapping, so the postprocessing code in the driver can view the 80
2-page sub-buffers as one big consecutive 160-page buffer. Doing this would (a)
make for more efficient use of memory, and (b) leave the larger piles of
contiguous pages to the drivers of cards that actually require them.
Is this possible?
--
- Stevie-O
Real Programmers use COPY CON PROGRAM.EXE
reply other threads:[~2003-09-17 23:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=3F68F004.7020107@klozoff.com \
--to=oliver@klozoff.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 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.