public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Packard <keithp@keithp.com>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: keithp@keithp.com, Christoph Hellwig <hch@infradead.org>,
	Eric Anholt <eric@anholt.net>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Export shmem_file_setup and shmem_getpage for DRM-GEM
Date: Mon, 04 Aug 2008 03:26:30 -0700	[thread overview]
Message-ID: <1217845590.24714.45.camel@koto.keithp.com> (raw)
In-Reply-To: <200808041902.23970.nickpiggin@yahoo.com.au>

[-- Attachment #1: Type: text/plain, Size: 2680 bytes --]

On Mon, 2008-08-04 at 19:02 +1000, Nick Piggin wrote:

> This is how I'd suggested it work as well. I think a little bit
> more effort should be spent looking at making this work.

What I may be able to do is create a file, then hand it to my driver and
close the fd. That would avoid any ulimit or low-fd issues.

> Mapping the file into an address space might be a way to make it
> work (using get_user_pages to get the struct page). splice might
> also work. read_mapping_page or similar could also be something to
> look at. But using shmem_getpage seems wrong because it circumvents
> the vfs API.

It seems fairly ugly to map the object to user space just to get page
pointers; the expense of constructing that mapping will be entirely
wasted most of the time.

Would it be imprudent to use pagecache_write_begin/pagecache_write_end
here? For shmem, that appears to point at functions which will do what I
need. Of course, it will cause extra page-outs as each page will be
marked dirty, even if the GPU never writes them. 

While shmem offers good semantics for graphics objects, it doesn't seem
like it is unique in any way, and it seems like it should be possible to
do this operation on any file system.

> If you genuinely have problems that can't be fit into existing
> APIs without significant modification, and that is specific just to
> your app, then we could always look at making special cases for you.
> But it would be nice if we generically solve problems you have with
> processes manipulating thousands of files.

There are some unique aspects to this operation which don't really have
parallels in other environments.

I'm doing memory management for a co-processor which uses the same pages
as the CPU. So, I need to allocate many pages that are just handed to
the GPU and never used by the CPU at all. Most rendering buffers are of
this form -- if you ever need to access them from the CPU, you've done
something terribly wrong.

Then there are textures which are constructed by the CPU (usually) and
handed over to the GPU for the entire lifetime of the application. These
are numerous enough that we need to be able to page them to disk; the
kernel driver will fault them back in when the GPU needs them again.

On the other hand, there are command and vertex buffers which are
constructed in user space and passed to the GPU for execution. These
operate just like any bulk-data transfer, and, in fact, I'm using the
pwrite API to transmit this data. For these buffers, the entire key is
to make sure you respect the various caches to keep them from getting
trashed.

-- 
keith.packard@intel.com

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2008-08-04 10:26 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-01  6:58 [PATCH] PCI: Add pci_read_base() API Eric Anholt
2008-08-01  6:58 ` [PATCH] Export shmem_file_setup and shmem_getpage for DRM-GEM Eric Anholt
2008-08-01  6:58   ` [PATCH] drm: Add GEM ("graphics execution manager") to i915 driver Eric Anholt
2008-08-01 15:44     ` Randy Dunlap
2008-08-01 18:11       ` Keith Packard
2008-08-06  1:11       ` Eric Anholt
2008-08-01  7:10   ` [PATCH] Export shmem_file_setup and shmem_getpage for DRM-GEM Eric Anholt
2008-08-01 10:57   ` Hugh Dickins
2008-08-01 18:06     ` Keith Packard
2008-08-01 20:50   ` Christoph Hellwig
2008-08-01 23:01     ` Keith Packard
2008-08-03 12:49       ` John Stoffel
2008-08-03 17:52         ` Keith Packard
2008-08-03 23:35           ` files/process scaling problem? (was: [PATCH] Export shmem_file_setup and shmem_getpage for DRM-GEM) Ingo Oeser
2008-08-04  0:19             ` Keith Packard
2008-08-04  8:19               ` Alan Cox
2008-08-04 13:51                 ` Arjan van de Ven
2008-08-04 14:11                   ` Alan Cox
2008-08-04 16:38                     ` Arjan van de Ven
2008-08-04 16:58                     ` Keith Packard
2008-08-04 21:46                       ` Ingo Oeser
2008-08-04 22:20                         ` Dave Airlie
2008-08-05  0:34                         ` Keith Packard
2008-08-11  1:23       ` [PATCH] Export shmem_file_setup and shmem_getpage for DRM-GEM Christoph Hellwig
2008-08-11  3:03         ` [PATCH] Export shmem_file_setup " Keith Packard
2008-08-04  1:54     ` [PATCH] Export shmem_file_setup and shmem_getpage " Keith Packard
2008-08-04  9:02       ` Nick Piggin
2008-08-04 10:26         ` Keith Packard [this message]
2008-08-04 10:43           ` Nick Piggin
2008-08-04 11:45             ` Keith Packard
2008-08-04 17:09               ` Hugh Dickins
2008-08-04 17:25                 ` Keith Packard
2008-08-04 18:39                   ` Hugh Dickins
2008-08-04 19:20                     ` Keith Packard
2008-08-04 19:55                       ` Hugh Dickins
2008-08-04 21:37                         ` Keith Packard
2008-08-05  2:25                         ` John Stoffel
2008-08-05  4:28                           ` Keith Packard
2008-08-06 16:20                             ` Stephane Marchesin
2008-08-06 17:24                               ` Arjan van de Ven
2008-08-06 17:32                                 ` Stephane Marchesin
2008-08-06 17:56                                   ` Keith Packard
2008-08-06 18:09                                     ` Stephane Marchesin
2008-08-06 21:22                                       ` Keith Packard
2008-08-07  2:16                                 ` Stephane Marchesin
2008-08-07  2:57                                   ` Keith Packard
2008-08-11  1:34                                 ` Christoph Hellwig
2008-08-05  4:28                 ` Nick Piggin
2008-08-11  1:30                 ` Christoph Hellwig
2008-08-04 21:58         ` Keith Packard
2008-08-04 22:22           ` Dave Airlie
2008-08-05  4:43           ` Nick Piggin
2008-08-05  5:19             ` Keith Packard
2008-08-07  0:45             ` Jesse Barnes
2008-08-19  1:17             ` Dave Airlie
2008-08-19 10:00               ` Nick Piggin
2008-08-19 16:46                 ` Keith Packard
2008-08-19 18:50                   ` Jesse Barnes
2008-08-21 13:42                     ` Jerome Glisse
2008-08-21 16:15                       ` Jesse Barnes

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=1217845590.24714.45.camel@koto.keithp.com \
    --to=keithp@keithp.com \
    --cc=eric@anholt.net \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    /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