linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [QUESTION] mmap of  device file with huge pages
@ 2016-08-09  9:58 Yehuda Yitschak
  2016-08-09 17:39 ` Dave Hansen
  0 siblings, 1 reply; 4+ messages in thread
From: Yehuda Yitschak @ 2016-08-09  9:58 UTC (permalink / raw)
  To: linux-mm@kvack.org; +Cc: Shadi Ammouri

[-- Attachment #1: Type: text/plain, Size: 854 bytes --]

Hello everyone

I am trying mmap  kernel buffers associated with a device file (like /dev/mem) using huge pages.
I couldn't find any mechanism to do this.

On the kernel side I allocate a contiguous 2M buffer using alloc_pages.

A regular mmap with MAP_HUGETLB flag will only accept anonymous mappings or hugetlbfs files but not device files.
So, I think I need to make sure the mapping uses huge pages in my device file's mmap hook.
Usually these kind of mmap fops use remap_pfn_range but I couldn't find a way to make remap_pfn_range use huge pages.

I also tried to make Transparent huge pages recognize the mapping done with remap_pfn_range and collapse them to a huge page but that didn't work. Not sure why

I would appreciate any advice on this issue

Thanks !

-------------------
Yehuda Yitschak
Marvell Semiconductor Ltd.


[-- Attachment #2: Type: text/html, Size: 3227 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [QUESTION] mmap of device file with huge pages
  2016-08-09  9:58 [QUESTION] mmap of device file with huge pages Yehuda Yitschak
@ 2016-08-09 17:39 ` Dave Hansen
  2016-08-10  7:36   ` Yehuda Yitschak
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Hansen @ 2016-08-09 17:39 UTC (permalink / raw)
  To: Yehuda Yitschak, linux-mm@kvack.org; +Cc: Shadi Ammouri

On 08/09/2016 02:58 AM, Yehuda Yitschak wrote:
> I would appreciate any advice on this issue

This is kinda a FAQ at this point.  But, the thing I generally suggest
is that you allocate hugetlbfs memory or anonymous transparent huge
pages in your applciation via the _normal_ mechanisms, and then hand a
pointer to that in to your driver.

It's backwards from how you're doing it now, but it makes things easier
down the road.

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [QUESTION] mmap of device file with huge pages
  2016-08-09 17:39 ` Dave Hansen
@ 2016-08-10  7:36   ` Yehuda Yitschak
  2016-08-10 16:20     ` Dave Hansen
  0 siblings, 1 reply; 4+ messages in thread
From: Yehuda Yitschak @ 2016-08-10  7:36 UTC (permalink / raw)
  To: Dave Hansen, linux-mm@kvack.org; +Cc: Shadi Ammouri



> -----Original Message-----
> From: Dave Hansen [mailto:dave.hansen@intel.com]
> Sent: Tuesday, August 09, 2016 20:40
> To: Yehuda Yitschak; linux-mm@kvack.org
> Cc: Shadi Ammouri
> Subject: Re: [QUESTION] mmap of device file with huge pages
> 
> On 08/09/2016 02:58 AM, Yehuda Yitschak wrote:
> > I would appreciate any advice on this issue
> 
> This is kinda a FAQ at this point.  

Sorry for posting a FAQ but I found nothing on the web.
There's tons of general material about mmap, huge-pages and device files but nothing on this specific use case.
I posted this question since I suspected I might need a ugly hack for this scenario.
Is there any standard solution to this issue ? 

> But, the thing I generally suggest is that you
> allocate hugetlbfs memory or anonymous transparent huge pages in your
> applciation via the _normal_ mechanisms, and then hand a pointer to that in
> to your driver.

Thanks. I can try that.
Once I hand the pointer to the driver, is there a standard API to map user-space memory to kernel space.

Thanks 

Yehuda 

> 
> It's backwards from how you're doing it now, but it makes things easier down
> the road.

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [QUESTION] mmap of device file with huge pages
  2016-08-10  7:36   ` Yehuda Yitschak
@ 2016-08-10 16:20     ` Dave Hansen
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Hansen @ 2016-08-10 16:20 UTC (permalink / raw)
  To: Yehuda Yitschak, linux-mm@kvack.org; +Cc: Shadi Ammouri

On 08/10/2016 12:36 AM, Yehuda Yitschak wrote:
>>> But, the thing I generally suggest is that you
>>> allocate hugetlbfs memory or anonymous transparent huge pages in
>>> your applciation via the _normal_ mechanisms, and then hand a
>>> pointer to that in to your driver.
> Thanks. I can try that. Once I hand the pointer to the driver, is
> there a standard API to map user-space memory to kernel space.

Yes.  It's probably worth reading:

http://www.oreilly.com/openbook/linuxdrive3/book/ch15.pdf

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-10 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-09  9:58 [QUESTION] mmap of device file with huge pages Yehuda Yitschak
2016-08-09 17:39 ` Dave Hansen
2016-08-10  7:36   ` Yehuda Yitschak
2016-08-10 16:20     ` Dave Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).