From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx <intel-gfx@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>, stable@kernel.org
Subject: Re: [PATCH 2/2] drm/i915: properly prefault for pread/pwrite
Date: Wed, 28 Sep 2011 12:24:04 +0100 [thread overview]
Message-ID: <f80fcd$212d29@fmsmga001.fm.intel.com> (raw)
In-Reply-To: <1317203844-2930-2-git-send-email-daniel.vetter@ffwll.ch>
On Wed, 28 Sep 2011 11:57:24 +0200, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> The helper functions used are designed for pagecache io and splice,
> i.e. they prefault at most PAGE_SIZE bytes spanning at most 2 pages.
>
> pread/pwrite want to write/read much more to avoid dropping the
> struct_mutex lock in between. So write our helper function to prefault.
> We're the only user of these pagemap.h helpers that want this behaviour,
> so keep these new helpers private.
>
> Based on a patch by Chris Wilson. In addition to his approach this
> alos tries to prefault the last page in case the user address range
> crosses a page boundary at the end (and hence might sit on n+1 pages
> for at most n*PAGE_SIZE of date).
>
> As a nice side-effect this rather reliably papers over the current
> code's inability to handle non-struct page-backed user memory in the
> slow paths. Because the real fix is grossly invasive, I think this
> patch is the right thing for backporting.
>
> Cc: stable@kernel.org
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38115
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
> drivers/gpu/drm/i915/i915_gem.c | 59 ++++++++++++++++++++++++++++++++++++--
> 1 files changed, 55 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 5f0f46e..42dc922 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -503,6 +503,32 @@ out:
> return ret;
> }
>
> +static inline int __prefault_writeable(char __user *uaddr, int size)
> +{
> + int ret;
> + char __user *end = uaddr + size - 1;
> +
> + if (unlikely(size == 0))
> + return 0;
> +
> + /*
> + * Writing zeroes into userspace here is OK, because we know that if
> + * the zero gets there, we'll be overwriting it.
> + */
> + while (uaddr <= end) {
> + ret = __put_user(0, uaddr);
> + if (ret != 0)
> + return ret;
> + uaddr += PAGE_SIZE;
> + }
> + if (ret == 0) {
> + if (((unsigned long)uaddr & PAGE_MASK) !=
> + ((unsigned long)end & PAGE_MASK))
This is a little ugly. Perhaps,
#define page_align(addr) ((unsigned long)addr & PAGE_MASK)
if (page_align(uaddr) != page_align(end))
Otherwise, both are
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
next prev parent reply other threads:[~2011-09-28 11:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-28 9:57 [PATCH 1/2] io-mapping: ensure io_mapping_map_atomic _is_ atomic Daniel Vetter
2011-09-28 9:57 ` [PATCH 2/2] drm/i915: properly prefault for pread/pwrite Daniel Vetter
2011-09-28 11:24 ` Chris Wilson [this message]
2011-10-23 10:18 ` Daniel Vetter
2011-10-23 10:19 ` Daniel Vetter
2011-10-23 19:23 ` Keith Packard
2011-10-23 22:11 ` Daniel Vetter
2011-11-03 21:06 ` Keith Packard
2011-11-03 22:10 ` Daniel Vetter
2011-11-17 20:52 ` Keith Packard
2011-11-18 9:12 ` Daniel Vetter
2011-11-18 17:42 ` Keith Packard
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='f80fcd$212d29@fmsmga001.fm.intel.com' \
--to=chris@chris-wilson.co.uk \
--cc=daniel.vetter@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
--cc=stable@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