From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Hugh Dickins <hugh@veritas.com>, linux-fsdevel@vger.kernel.org
Cc: Keith Packard <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: Tue, 5 Aug 2008 14:28:20 +1000 [thread overview]
Message-ID: <200808051428.20602.nickpiggin@yahoo.com.au> (raw)
In-Reply-To: <Pine.LNX.4.64.0808041720500.25617@blonde.site>
On Tuesday 05 August 2008 03:09, Hugh Dickins wrote:
> On Mon, 4 Aug 2008, Keith Packard wrote:
> > On Mon, 2008-08-04 at 20:43 +1000, Nick Piggin wrote:
> > > read_mapping_page might help there.
> >
> > That does look a lot more like what I want, as it returns an unlocked
> > page. And, makes my code look cleaner to boot:
> >
> > inode = obj->filp->f_path.dentry->d_inode;
> > mapping = inode->i_mapping;
> > for (i = 0; i < page_count; i++) {
> > page = read_mapping_page(mapping, i, NULL);
> > if (IS_ERR(page)) {
> > ret = PTR_ERR(page);
> > DRM_ERROR("read_mapping_page failed: %d\n", ret);
> > i915_gem_object_free_page_list(obj);
> > return ret;
> > }
> > obj_priv->page_list[i] = page;
> > }
> >
> > Does this look like it conforms to the vfs api? It appears to work when
> > using shmem at least.
>
> 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.
Yes, readpage is optional... A check will be required.
I don't exactly know if this would be deemed the best way to do it,
but it seems *relatively* filesystem agnostic (with the readpage
test being the exception), and it seems like it is to address_space
mappings what get_user_pages is to virtual memory mappings. And
there is no shortage of drivers using get_user_pages.
At any rate, it seems a bit nicer than using shmem_getpage directly.
cc'ing linux-fsdevel.
> 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
next prev parent reply other threads:[~2008-08-05 4:28 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
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 [this message]
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=200808051428.20602.nickpiggin@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=eric@anholt.net \
--cc=hch@infradead.org \
--cc=hugh@veritas.com \
--cc=keithp@keithp.com \
--cc=linux-fsdevel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®