Re: [PATCH] add compat wrapper for get_user_pages_fast

Marcelo Tosatti
2008-09-18T22:31:56Z

On Thu, Sep 18, 2008 at 06:33:04PM +0200, Jan Kiszka wrote:
> Not sure if this is correct, but here is at least a compile fix.

Looks good.

> Note that the original mmem_map locking scope was partly far broader on
> older kernels than with Marcelo's patch and this fix now. Could anyone
> comment on the correctness?

I think all cases have been covered (vma manipulation, find_vma
callers).

>
> ---------
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> kernel/external-module-compat-comm.h | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> Index: b/kernel/external-module-compat-comm.h
> ===================================================================
> --- a/kernel/external-module-compat-comm.h
> +++ b/kernel/external-module-compat-comm.h
> @@ -531,3 +531,20 @@ struct pci_dev;
> struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn);
>
> #endif
> +
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
> +
> +static inline int get_user_pages_fast(unsigned long start, int nr_pages,
> + int write, struct page **pages)
> +{
> + int npages;
> +
> + down_read(&current->mm->mmap_sem);
> + npages = get_user_pages(current, current->mm, start, nr_pages, write,
> + 0, pages, NULL);
> + up_read(&current->mm->mmap_sem);
> +
> + return npages;
> +}
> +
> +#endif