Re: [PATCH] Export shmem_file_setup and shmem_getpage for DRM-GEM

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Keith Packard <keithp@...>
Cc: Nick Piggin <nickpiggin@...>, Christoph Hellwig <hch@...>, Eric Anholt <eric@...>, <linux-kernel@...>
Date: Monday, August 4, 2008 - 1:09 pm

On Mon, 4 Aug 2008, Keith Packard wrote:

Yes, that's a good suggestion from Nick, should work with shmem/tmpfs
(with *proviso below) and others, and big improvement to your generality.

Whether such usage conforms to VFS API I'm not so sure: as I understand
it, it's really for internal use by a filesystem - if it's going to be
used beyond that, we ought to add a check that the filesystem it's used
upon really has a ->readpage method (and I'd rather we add such a check
than you do it at your end, in case we change the implementation later
to use something other than a ->readpage method - Nick, you'll be
nauseated to hear I was looking to see if ->fault with a pseudo-vma
could do it).  But if the layering police are happy with this, I am.

The *proviso is that for tmpfs itself this actually isn't as convenient
as directly using shmem_getpage: because this way passes a page in to
shmem_getpage, when maybe the page wanted is already here but currently
marked as swapcache rather than filecache.  It's an awkward extension
that allows tmpfs to support ->readpage at all.  But that route is in
use and well-tested, and only an inefficiency when swapping, so should
not cause you any problems.

(I have been agonizing over the way __read_cache_page, like your
original i915_gem_object_get_page_list, uses find_get_page: whereas
shmem_getpage uses find_lock_page.  I remember the latter is important,
but don't quite remember all the why.  I'm believing that it's really
only the ->fault usage where it becomes vital: things get confused, on
2.4 more than 2.6, if a swapcache tmpfs page is mapped into userspace.)

You don't examine page->mapping at all: good, there's a race by which
it could go to NULL after you acquired the page by read_mapping_page:
not by file truncation, but by swapping out at the wrong instant.
Don't worry, you have the right page, just don't rely on page->mapping.

(Sorry if I'm rather talking aloud to myself here.)

Hugh
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] PCI: Add pci_read_base() API, Eric Anholt, (Fri Aug 1, 2:58 am)
Re: [PATCH] Export shmem_file_setup and shmem_getpage for DR..., Hugh Dickins, (Mon Aug 4, 1:09 pm)
Re: [PATCH] Export shmem_file_setup and shmem_getpage for DR..., Christoph Hellwig, (Sun Aug 10, 9:30 pm)
Re: [PATCH] Export shmem_file_setup and shmem_getpage for DR..., Stephane Marchesin, (Wed Aug 6, 12:20 pm)
Re: [PATCH] Export shmem_file_setup and shmem_getpage for DR..., Christoph Hellwig, (Sun Aug 10, 9:34 pm)
Re: [PATCH] Export shmem_file_setup and shmem_getpage for DR..., Stephane Marchesin, (Wed Aug 6, 10:16 pm)
Re: [PATCH] Export shmem_file_setup and shmem_getpage for DR..., Stephane Marchesin, (Wed Aug 6, 1:32 pm)
Re: [PATCH] Export shmem_file_setup and shmem_getpage for DR..., Stephane Marchesin, (Wed Aug 6, 2:09 pm)
Re: [PATCH] Export shmem_file_setup and shmem_getpage for DR..., Christoph Hellwig, (Sun Aug 10, 9:23 pm)
Re: [PATCH] Export shmem_file_setup for DRM-GEM, Keith Packard, (Sun Aug 10, 11:03 pm)