From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by kanga.kvack.org (Postfix) with ESMTP id 968CF6B0005 for ; Tue, 9 Aug 2016 05:58:37 -0400 (EDT) Received: by mail-pa0-f72.google.com with SMTP id ez1so16003938pab.1 for ; Tue, 09 Aug 2016 02:58:37 -0700 (PDT) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com. [67.231.148.174]) by mx.google.com with ESMTPS id b132si41988840pfb.196.2016.08.09.02.58.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Aug 2016 02:58:36 -0700 (PDT) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u799nQ1S011289 for ; Tue, 9 Aug 2016 02:58:36 -0700 Received: from il-exch02.marvell.com ([199.203.130.102]) by mx0a-0016f401.pphosted.com with ESMTP id 24nd8q3q59-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 09 Aug 2016 02:58:36 -0700 From: Yehuda Yitschak Subject: [QUESTION] mmap of device file with huge pages Date: Tue, 9 Aug 2016 09:58:32 +0000 Message-ID: <85d8c7bb8bcc4a30865a4512dd174cf8@IL-EXCH02.marvell.com> Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_85d8c7bb8bcc4a30865a4512dd174cf8ILEXCH02marvellcom_" MIME-Version: 1.0 Sender: owner-linux-mm@kvack.org List-ID: To: "linux-mm@kvack.org" Cc: Shadi Ammouri --_000_85d8c7bb8bcc4a30865a4512dd174cf8ILEXCH02marvellcom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello everyone I am trying mmap kernel buffers associated with a device file (like /dev/m= em) 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 fi= le's mmap hook. Usually these kind of mmap fops use remap_pfn_range but I couldn't find a w= ay 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. --_000_85d8c7bb8bcc4a30865a4512dd174cf8ILEXCH02marvellcom_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hello everyone

 

I am trying mmap  kernel buffers associated wit= h 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 accep= t anonymous mappings or hugetlbfs files but not device files.

So, I think I need to make sure the mapping uses hug= e 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 recogniz= e the mapping done with remap_pfn_range and collapse them to a huge page bu= t that didn’t work. Not sure why

 

I would appreciate any advice on this issue

 

Thanks !

 

-------------------

Yehuda Yitschak

Marvell Semiconductor Ltd.

 

--_000_85d8c7bb8bcc4a30865a4512dd174cf8ILEXCH02marvellcom_-- -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id 907466B0253 for ; Tue, 9 Aug 2016 13:39:47 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id h186so35320659pfg.2 for ; Tue, 09 Aug 2016 10:39:47 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTP id xg5si43626618pac.220.2016.08.09.10.39.39 for ; Tue, 09 Aug 2016 10:39:45 -0700 (PDT) Subject: Re: [QUESTION] mmap of device file with huge pages References: <85d8c7bb8bcc4a30865a4512dd174cf8@IL-EXCH02.marvell.com> From: Dave Hansen Message-ID: <57AA155B.70009@intel.com> Date: Tue, 9 Aug 2016 10:39:39 -0700 MIME-Version: 1.0 In-Reply-To: <85d8c7bb8bcc4a30865a4512dd174cf8@IL-EXCH02.marvell.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f69.google.com (mail-wm0-f69.google.com [74.125.82.69]) by kanga.kvack.org (Postfix) with ESMTP id 7E6626B0005 for ; Wed, 10 Aug 2016 03:36:35 -0400 (EDT) Received: by mail-wm0-f69.google.com with SMTP id u81so48760995wmu.3 for ; Wed, 10 Aug 2016 00:36:35 -0700 (PDT) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com. [67.231.156.173]) by mx.google.com with ESMTPS id be6si16123940wjb.31.2016.08.10.00.36.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Aug 2016 00:36:34 -0700 (PDT) From: Yehuda Yitschak Subject: RE: [QUESTION] mmap of device file with huge pages Date: Wed, 10 Aug 2016 07:36:29 +0000 Message-ID: References: <85d8c7bb8bcc4a30865a4512dd174cf8@IL-EXCH02.marvell.com> <57AA155B.70009@intel.com> In-Reply-To: <57AA155B.70009@intel.com> Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: owner-linux-mm@kvack.org List-ID: 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 >=20 > On 08/09/2016 02:58 AM, Yehuda Yitschak wrote: > > I would appreciate any advice on this issue >=20 > This is kinda a FAQ at this point. =20 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 bu= t 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 ?=20 > 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=20 Yehuda=20 >=20 > It's backwards from how you're doing it now, but it makes things easier d= own > 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by kanga.kvack.org (Postfix) with ESMTP id 547206B0005 for ; Wed, 10 Aug 2016 12:20:01 -0400 (EDT) Received: by mail-pa0-f69.google.com with SMTP id ag5so80231010pad.2 for ; Wed, 10 Aug 2016 09:20:01 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com. [134.134.136.20]) by mx.google.com with ESMTP id m2si49177328paw.225.2016.08.10.09.20.00 for ; Wed, 10 Aug 2016 09:20:00 -0700 (PDT) Subject: Re: [QUESTION] mmap of device file with huge pages References: <85d8c7bb8bcc4a30865a4512dd174cf8@IL-EXCH02.marvell.com> <57AA155B.70009@intel.com> From: Dave Hansen Message-ID: <57AB5430.5000305@intel.com> Date: Wed, 10 Aug 2016 09:20:00 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: 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: email@kvack.org