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 4D002C433F5 for ; Sat, 16 Oct 2021 15:50:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AB73260F36 for ; Sat, 16 Oct 2021 15:50:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AB73260F36 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 31B976B0071; Sat, 16 Oct 2021 11:50:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2CB37900002; Sat, 16 Oct 2021 11:50:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B9CE6B0073; Sat, 16 Oct 2021 11:50:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id 0C6066B0071 for ; Sat, 16 Oct 2021 11:50:29 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B64BD181FC55A for ; Sat, 16 Oct 2021 15:50:28 +0000 (UTC) X-FDA: 78702737736.04.855C4FE Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by imf13.hostedemail.com (Postfix) with ESMTP id 9F94910345BD for ; Sat, 16 Oct 2021 15:50:26 +0000 (UTC) Received: by mail-qk1-f175.google.com with SMTP id h20so6907791qko.13 for ; Sat, 16 Oct 2021 08:50:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Bw563Bs4fZY3E+yY1+6t20LCbMgESV05gje66USyQNM=; b=T7eS4Xb9jUKT5zmNoPZtNHeE02GXz4kpumLlvJjIa9N3q7zg8HzwOQOicDm2IkMfzv Oyy7W7Fq4O8sAtsrjkYUORKpCjWzNu6fCnXTcdQKl6mw2EWcy2j8yR0NlnJPbZjeONj3 sOE1zXyUm6niwCSHfF1glty9syPW1qcgpK5/ZG41T443Nb0AraSPsn8Rjux0b9ScD8XW BIfmkqYWwaZVtXLPJ+oyLSu1XkQXh15J6kvdoRtPwczcz7kzKJanAdtpOVUeob25/2Rm 2iUEe96nFB6QV6MLvm2LLBL2bfIdAk4lJu3o4NYGKiPNyn8n2vFRwb/BY8tYVss31Mhx tvVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Bw563Bs4fZY3E+yY1+6t20LCbMgESV05gje66USyQNM=; b=RDpKQkgsZxmU8GPii5IBOMJAvADw/nvQePjMbnUOyS7gXjKjwp1Ppj3bVyzjDfBspX G4g+bDM20L+s9pKkWRlP2r6qUKT0AGo83W71cAZf/WqzVcnsm0xvWUARPbIh9gyf47Ui /T9mB5shZWDo3gh6TaXuzoOQ/gj2jhjNnJWH0vccnanPf8ajI0rI+6W4UjU5G+zZ0xuz OMhyC806BaFB82/Fq5jn7OLhF5tIxqBQS13bxeWoB04iuoyluidj+EJX+up914/SgkDY VnUzP/gK4NiWRvgY7qdBsHDqBBUtB028p4YSsji1xPAOoAVGn95mk5g3g1zhM9UY4Ojq 3yEA== X-Gm-Message-State: AOAM531j1ZTuFL7Z60kEafbAbNT+Ii5a8K/ga1q6Y6K/IrdJxcd/ETwc 1V3vGxHQA/kqsh1Oe21aS1YdOA== X-Google-Smtp-Source: ABdhPJwf0Mx0PLCm1tWaAQSHh9Q5al6qdw5omwQETfboFSny0j9q0E0EXSL3JwmoiIopmenGI/5o0w== X-Received: by 2002:a37:6458:: with SMTP id y85mr14763556qkb.492.1634399427623; Sat, 16 Oct 2021 08:50:27 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id s22sm829372qko.135.2021.10.16.08.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Oct 2021 08:50:27 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1mblx4-00FhsP-EP; Sat, 16 Oct 2021 12:50:26 -0300 Date: Sat, 16 Oct 2021 12:50:26 -0300 From: Jason Gunthorpe To: Adam Turowski Cc: linux-mm@kvack.org Subject: Re: How to mmap any address space using huge pages? Message-ID: <20211016155026.GB3686969@ziepe.ca> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9F94910345BD X-Stat-Signature: 98djpo3h7oqetn1uym1mwba46gug87k1 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b=T7eS4Xb9; dmarc=none; spf=pass (imf13.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.222.175 as permitted sender) smtp.mailfrom=jgg@ziepe.ca X-HE-Tag: 1634399426-136089 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Oct 16, 2021 at 11:46:59AM +0200, Adam Turowski wrote: > 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)? AFAIK it can't be done today. Certainly non-struct page memory cannot be installed in a PUD If you create a ZONE_DEVICE struct page using memremap_pages() then they can be inserted using vmf_insert_pfn_pud() - however that requires arch support for pud_devmap() which only x86 does right now. Jason