Re: [PATCH] mm: extend prefault helpers to fault in more than PAGE_SIZE

From: Geert Uytterhoeven
Date: Fri Apr 13 2012 - 15:12:20 EST


On Thu, Mar 1, 2012 at 20:22, Daniel Vetter <daniel.vetter@xxxxxxxx> wrote:
> +/* Multipage variants of the above prefault helpers, useful if more than
> + * PAGE_SIZE of date needs to be prefaulted. These are separate from the above
> + * functions (which only handle up to PAGE_SIZE) to avoid clobbering the
> + * filemap.c hotpaths. */
> +static inline int fault_in_multipages_writeable(char __user *uaddr, int size)
> +{
> + Â Â Â int ret;
> + Â Â Â const char __user *end = uaddr + size - 1;

Please drop the const.

> +
> + Â Â Â 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;
> + Â Â Â }
> +
> + Â Â Â /* Check whether the range spilled into the next page. */
> + Â Â Â if (((unsigned long)uaddr & PAGE_MASK) ==
> + Â Â Â Â Â Â Â Â Â Â Â ((unsigned long)end & PAGE_MASK))
> + Â Â Â Â Â Â Â ret = __put_user(0, end);

include/linux/pagemap.h:483:3: error: read-only location '*end' used
as 'asm' output

Now in -next:

http://kisskb.ellerman.id.au/kisskb/buildresult/6100650/
http://kisskb.ellerman.id.au/kisskb/buildresult/6100673/
http://kisskb.ellerman.id.au/kisskb/buildresult/6100860/

Gr{oetje,eeting}s,

            Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
             Â Â -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/