All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huang Shijie <shijie8@gmail.com>
To: Minchan Kim <minchan.kim@gmail.com>
Cc: linux-mm@kvack.org
Subject: Re: Does get_user_pages_fast lock the user pages in memory in my case?
Date: Mon, 20 Apr 2009 13:05:33 +0800	[thread overview]
Message-ID: <49EC029D.1060807@gmail.com> (raw)
In-Reply-To: <20090420135323.08015e32.minchan.kim@barrios-desktop>

Minchan Kim a??e??:
> On Mon, 20 Apr 2009 11:28:00 +0800
> Huang Shijie <shijie8@gmail.com> wrote:
>
> I will summarize your method. 
> Is right ?
>
>
> kernel(driver)					application 
>
> 						posix_memalign(buffer)
> 						ioctl(buffer)
>
> ioctl handler
> get_user_pages(pages);
> /* This pages are mapped at user's vma' 
> address space */
> vaddr = vmap(pages);
> /* This pages are mapped at vmalloc space */
> .
> .
> <after sometime, 
> It may change to other process context>
> .
> .
> interrupt handler in your driver 
> memcpy(vaddr, src, len); 
> notify_user();
>
> 						processing(buffer);
>
> It's rather awkward use case of get_user_pages. 
>
> If you want to share one big buffer between kernel and user, 
> You can vmalloc and remap_pfn_range.
>   
The v4l2 method IO_METHOD_MMAP does use the vmaloc() method you told above ,
our driver also support this method,we user vmalloc /remap_vmalloc_range().

But the v4l2 method IO_METHOD_USERPTR must use the method I told above.
> You can refer cpia_mmap in drivers/media/video/cpia.c
>  
>
>
>   
>> Minchan Kim a??e??:
>>     
>>> On Mon, 20 Apr 2009 10:15:55 +0800
>>> Huang Shijie <shijie8@gmail.com> wrote:
>>>
>>>   
>>>       
>>>> Minchan Kim a??e??:
>>>>     
>>>>         
>>>>> On Fri, 17 Apr 2009 15:01:01 +0800
>>>>> Huang Shijie <shijie8@gmail.com> wrote:
>>>>>
>>>>>   
>>>>>       
>>>>>           
>>>>>>    I'm writting a driver for a video card with the V4L2 interface .
>>>>>>    V4L2 interface supports the USER-POINTER method for the video frame 
>>>>>> handling.
>>>>>>
>>>>>>    VLC player supports the USER-POINTER method,while MPALYER does not.
>>>>>>
>>>>>>    In the USER-POINTER method, VLC will call the posix_memalign() to 
>>>>>> allocate
>>>>>> 203 pages in certain PAL mode (that is 720*576*2) for a single frame.
>>>>>>    In my driver , I call the get_user_pages_fast() to obtain the pages 
>>>>>> array,and then call
>>>>>> the vmap() to map the pages to VMALLOC space for the memcpy().The code 
>>>>>> shows below:
>>>>>>    ....................
>>>>>>    get_user_pages_fast();
>>>>>>    ...
>>>>>>    f->data = vmap();
>>>>>>    .......................
>>>>>>     
>>>>>>         
>>>>>>             
>>>>> What I understand is that you get the pages of posix_memalign by get_user_pages_fast 
>>>>> and then that pages are mapped at kernel vmalloc space by vmap. 
>>>>>
>>>>> Is it for removing copy overhead from kernel to user ?
>>>>>
>>>>>   
>>>>>       
>>>>>           
>>>> I need a large range of virtual contigous memory to store my video 
>>>> frame(about 203 pages). When I received a full frame ,I will queue the 
>>>> buffer in
>>>> a VIDIOC queue,which will be remove by the VIDIOC_DQBUF.'
>>>>     
>>>>         
>>> I can't understand your point. 
>>> Sorry for that. 
>>>
>>> Could you explain more detail relation (user buffer which is allocated by posix_memalign) and (kernel buffer which is mapped by vmap) ?
>>>
>>>   
>>>       
>> :) sorry for my poor english.
>> [1] VLC uses the posix_memalign to allocate a big buffer for a single 
>> frame(203 pages).
>> [2] vmap sets up the mapping of virtual contigous address for gup()'s 
>> pages array(the pages are not consecutive).
>>    memcpy() needs a contiguous address to copy in kernel mode.
>> [3] my driver do some specail operations  to  received data, then 
>> memcopy the data to the buffer get in step [2].
>> [4] when the buffer is full ,I will give the the user process (VLC).
>>
>> That's all.
>>     
>
>
>   

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2009-04-20  5:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-17  7:01 Does get_user_pages_fast lock the user pages in memory in my case? Huang Shijie
2009-04-18  6:18 ` KOSAKI Motohiro
2009-04-20  2:22   ` Huang Shijie
2009-04-19 23:45 ` Minchan Kim
2009-04-20  2:15   ` Huang Shijie
2009-04-20  2:42     ` Minchan Kim
2009-04-20  3:28       ` Huang Shijie
2009-04-20  3:42         ` KOSAKI Motohiro
2009-04-20  4:53         ` Minchan Kim
2009-04-20  5:05           ` KOSAKI Motohiro
2009-04-20  5:05           ` Huang Shijie [this message]
2009-04-20  5:19             ` KOSAKI Motohiro
2009-04-20  5:37               ` Huang Shijie
2009-04-20  7:59                 ` KOSAKI Motohiro
2009-04-20  8:23                   ` Huang Shijie
2009-04-20  9:24                     ` KOSAKI Motohiro
2009-04-20  9:47                       ` Huang Shijie
2009-04-21  1:43                         ` KOSAKI Motohiro
2009-04-21 19:47                         ` Christoph Lameter
2009-04-20  5:24             ` Minchan Kim
2009-04-20  5:42               ` Huang Shijie
2009-04-20  3:57       ` Huang Shijie
2009-04-22  6:08       ` Huang Shijie
2009-04-22  9:46         ` Minchan Kim
2009-04-20  3:18     ` KOSAKI Motohiro

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=49EC029D.1060807@gmail.com \
    --to=shijie8@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=minchan.kim@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.