Could, yes, but should? I wouldn't presume to answer with any authority.
Well, I guess put the check on ->readpage into your code for now, and
by the time GEM gets into Linus's tree, we should have -EINVAL checks
on NULL filler() in __read_cache_page() and read_cache_page_async(),
so remove check at your end before final submission.
(You could leave it there, and strictly we ought to update GEM if we
make any change to our implementation; but it is the kind of detail
that gets overlooked - witness the way I failed to grasp the readahead
side-effects of adding ->readpage into tmpfs until recently. I'm just
afraid we'd break you unwittingly: better not, though easily fixed.)
I'm not sending the patch right now, waiting to see if this direction
wins general favour.
I think you should drop the mark_page_accessed(): that's done in
read_cache_page_async() as part of the initial read_mapping_page().
But do it again when releasing if you think there's a good chance
that object will be wanted again shortly. set_page_dirty() if
modified by GPU, yes, that would still be needed.
For how long are these objects' pages pinned in memory like this?
I ask because Rik & Lee have patches in -mm, trying to avoid long
scans of LRUs cluttered with unevictable pages. I've no idea
whether you're adding a lot or a little to that problem.
Hugh
--