From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CE18C433EF for ; Thu, 21 Oct 2021 07:18:05 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7320760F9F for ; Thu, 21 Oct 2021 07:18:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7320760F9F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=etri.re.kr Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1mdSKx-0007hH-Fy for kernelnewbies@archiver.kernel.org; Thu, 21 Oct 2021 03:18:03 -0400 Received: from mscreen.etri.re.kr ([129.254.9.16]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (Exim 4.94.2) (envelope-from ) id 1mdSJ5-0005PA-6Y for kernelnewbies@kernelnewbies.org; Thu, 21 Oct 2021 03:16:07 -0400 Received: from unknown (HELO send001-relay.gov-dooray.com) (211.180.235.152) by 129.254.9.16 with ESMTP; 21 Oct 2021 16:16:01 +0900 X-Original-SENDERIP: 211.180.235.152 X-Original-MAILFROM: ckim@etri.re.kr X-Original-RCPTTO: kernelnewbies@kernelnewbies.org Received: from [10.162.225.106] (HELO smtp001-imp.gov-dooray.com) ([10.162.225.106]) by send001-relay.gov-dooray.com with SMTP id 75f50481617113b1; Thu, 21 Oct 2021 16:16:01 +0900 DKIM-Signature: a=rsa-sha256; b=xv9rblDeroCr3jESSME0oA3xzGmEDT6BhwStrSflLyagapN4R9mr5InQefWE7XRCxWpwMmxUIC ZBgp3aWFiYur7vSpNiCNXWdqkeDQyQfFdpz8N/42uHyXVsMGSr87Zdgm9IqzAJPK5xSlxJnpNVsQ uWDk9VK8O5S21QAW2eBhwM1o1kJN0SE4r3QWO67HEll+VkvVHfniGPxMud8NPgH87NFPz/h/RKKb duH9/zDxS1gc0GiC5NQuys59Bm5t0Pv6PXWOew2RPw/C0LZPg2KEpqCwZ0k2dp7VEseOsqlXMObV JaSMJcGSslReyuYgz/QKTLQ/vr6hsEzsc2+ir+Lg==; c=relaxed/relaxed; s=selector; d=dooray.com; v=1; bh=djR1CGi1dapaeHuvfLMM0Z8ODQBwL/Dwn4AJUOS8vjw=; h=From:To:Subject:Message-ID; Received: from [129.254.132.39] (HELO CHANKIMPC) ([129.254.132.39]) by smtp001-imp.gov-dooray.com with SMTP id 878485d1617113b1; Thu, 21 Oct 2021 16:16:01 +0900 From: "Chan Kim" To: "'Adam Turowski'" , References: In-Reply-To: Subject: RE: How to mmap any address space using huge pages? Date: Thu, 21 Oct 2021 16:16:00 +0900 Message-ID: <043701d7c64b$80615bf0$812413d0$@etri.re.kr> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQDqiLFkdrhDeEk6SxMJI5kEqQEkJK23hKLg Content-Language: ko X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============2932712563169600781==" Errors-To: kernelnewbies-bounces+kernelnewbies=archiver.kernel.org@kernelnewbies.org This is a multipart message in MIME format. --===============2932712563169600781== Content-Type: multipart/alternative; boundary="----=_NextPart_000_0438_01D7C696.F0497920" Content-Language: ko This is a multipart message in MIME format. ------=_NextPart_000_0438_01D7C696.F0497920 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Adam Did you tell the OS to reserve huge pages? (in ubuntu, add vm.nr_hugepages =3D N in /etc/sysctl.conf or Add hugepages=3D16, hugepagesz=3D256M in bootcommd) Just in case you didn=E2=80=99t set it. Thanks, Chan Kim =20 From: Adam Turowski =20 Sent: Friday, October 15, 2021 10:08 PM To: kernelnewbies@kernelnewbies.org Subject: How to mmap any address space using huge pages? =20 Hello all, I have a device and I need to mmap it into a user space using 1GB huge = pages. AFAIK I cannot use HugeTLB nor THP because they're backed by the = memory. The remap_pfn_range doesn't use huge pages neither. So I used a = huge_fault handler to set up the pud descriptor myself (arm64 here, so = no transparent puds) and that works. The problem is that the kernel = warns about a bad pud when the vma mapping is removed, the zap_pud_range = function doesn't accept block puds. The vunmap_pud_range function works = with block puds and checks for their presence and calls the = pud_clear_huge function. If I add this function call to the = zap_pud_range function, the warnings are gone. =20 Am I missing something? What is the proper way to mmap (and munmap) any = address space using huge pages (esp. 1GB pages)? =20 Thanks =20 -- Regards, Adam Turowski =20 ------=_NextPart_000_0438_01D7C696.F0497920 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi, Adam

Did you tell the OS to reserve huge = pages?

(in ubuntu, add vm.nr_hugepages =3D N in = /etc/sysctl.conf or

Add hugepages=3D16, hugepagesz=3D256M in = bootcommd)

Just in case you didn=E2=80=99t set = it.

Thanks,

Chan Kim

 

From:<= /b> Adam = Turowski <adam.s.turowski@gmail.com>
Sent: Friday, = October 15, 2021 10:08 PM
To: = kernelnewbies@kernelnewbies.org
Subject: How to mmap any = address space using huge pages?

 

Hello all,

I have a device and I need to mmap it into a user space = using 1GB huge pages. AFAIK I cannot use HugeTLB nor THP because they're = backed by the memory. The remap_pfn_range doesn't use huge pages = neither. So I used a huge_fault handler to set up the pud descriptor = myself (arm64 here, so no transparent puds) and that works. The problem = is that the kernel warns about a bad pud when the vma mapping is = removed, the zap_pud_range function doesn't accept block puds. The = vunmap_pud_range function works with block puds and checks for their = presence and calls the pud_clear_huge function. If I add this function = call to the zap_pud_range function, the warnings are = gone.

 

Am I missing something? What is the = proper way to mmap (and munmap) any address space using huge pages (esp. = 1GB pages)?

 

Thanks

 

--

Regards,

Adam = Turowski

 

------=_NextPart_000_0438_01D7C696.F0497920-- --===============2932712563169600781== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============2932712563169600781==--