[openib-general] [PATCH 7/7] IB/ipath - performance improvements via mmap of queues

ralphc at pathscale.com ralphc at pathscale.com
Mon Aug 14 10:41:58 PDT 2006


>  > +/*
>  > + * ipath_vma_nopage - handle a VMA page fault.
>  > + */
>  > +static struct page *ipath_vma_nopage(struct vm_area_struct *vma,
>  > +				     unsigned long address, int *type)
>  > +{
>  > +	struct ipath_mmap_info *ip = vma->vm_private_data;
>  > +	unsigned long offset = address - vma->vm_start;
>  > +	struct page *page = NOPAGE_SIGBUS;
>  > +	void *pageptr;
>  > +
>  > +	if (offset >= ip->size)
>  > +		goto out; /* out of range */
>  > +
>  > +	/*
>  > +	 * Convert the vmalloc address into a struct page.
>  > +	 */
>  > +	pageptr = (void *)(offset + (vma->vm_pgoff << PAGE_SHIFT));
>  > +	page = vmalloc_to_page(pageptr);
>  > +	if (!page)
>  > +		goto out;
>  > +
>  > +	/* Increment the reference count. */
>  > +	get_page(page);
>  > +	if (type)
>  > +		*type = VM_FAULT_MINOR;
>  > +out:
>  > +	return page;
>  > +}
>  > +
>  > +static struct vm_operations_struct ipath_vm_ops = {
>  > +	.open =     ipath_vma_open,
>  > +	.close =    ipath_vma_close,
>  > +	.nopage =   ipath_vma_nopage,
>  > +};
>
> It seems that all this would be much simpler with vmalloc_user() and
> remap_vmalloc_range().  And it would fix the information leak you
> introduce here: I don't see anywhere that you clear the memory you
> vmalloc and remap to userspace, so you're potentially exposing the
> cached contents of /etc/passwd or something like that.
>
>  - R.

I was unaware of these functions. Looks like they were just
recently added (7/23/2006).
I will update the patch to use these.





More information about the general mailing list