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 4A737C433F5 for ; Mon, 18 Oct 2021 10:14:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DE20360E54 for ; Mon, 18 Oct 2021 10:14:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DE20360E54 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6E5056B006C; Mon, 18 Oct 2021 06:14:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 694746B0071; Mon, 18 Oct 2021 06:14:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 55BEA6B0072; Mon, 18 Oct 2021 06:14:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 42FCC6B006C for ; Mon, 18 Oct 2021 06:14:54 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D19CF30162 for ; Mon, 18 Oct 2021 10:14:53 +0000 (UTC) X-FDA: 78709149666.21.CD645D7 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by imf21.hostedemail.com (Postfix) with ESMTP id 190B6D0425EA for ; Mon, 18 Oct 2021 10:14:51 +0000 (UTC) Received: by mail-lj1-f175.google.com with SMTP id n7so8037145ljp.5 for ; Mon, 18 Oct 2021 03:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=m+MBIGf3E+NGpJ+0MFOccNjhYMQ94jduG2OSz/oW/5w=; b=EJvbwRkIslopMw7VZiS6ooGiRLxmYZ9jDFac7LQ6NDI50lVpEjgHTpALsErA2sZTle pzb8YJ4P6CQ0ihaokNv2qQMUsKgfVHjC9R5E/VjTt8kIX+HxyzG8VDCTGtj1I9iSZJd4 7b7TmJRIwzYm0MrVui0JkWCSz/vTLhAu/U63Xtm3tB0DPFAjG6/GYq350WgknQG9/SVV jhnEJ+vENqufmzXuTgUAft3lnq3dN2Tx8sGqv+k5VOl6Y2i9vybFLIvHtq3CjHYI+c7u Nmfjwx0dq9FCflt+T9pBcfeifK5MDUIN1xkmpnrNLYte2a+b3HxlR1bX7AWvCW7E+4i9 hXtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=m+MBIGf3E+NGpJ+0MFOccNjhYMQ94jduG2OSz/oW/5w=; b=siYGtkgST/2II32pWbivQFlvVnKkmCQDRAYX4bjBpbrcMpbCW44yXkOYVP9bbZp812 vxNuLXEAhyplshHNJuQ5aPSN45v61L6NcCZ3F9NXhMHL9f7x/jZJSTnP3VPaTzujR991 tj4Ao9OGveaknSkUHrtd9KgBRCzcpZUgYpjHeCukuQ/ZCb/YOCOXwDUD7Mici/6zNUQb NiOaoCHJ1fSGF4ckmb6zez2Gz+042F7AqA7r9zYgBnfSr2tLEg53zeuU/+yjv/ux1svq MmBEy/PHNJAp2pK/VqZB3tARWvldukiiQiA3b18UIJd95f18AL7j+gStAUQ97Vcgb9lp +2cg== X-Gm-Message-State: AOAM530XLfn7lr/xl+QtjD2qg/1Nob69C53PkpXrY5dc6eC6GghkKYtU bQhhZKu/5i6Rm5uJbx3oetjhNFdvZ59gMVN1QMM= X-Google-Smtp-Source: ABdhPJyJcAQFPKww+g3LbmGl4ha5G8CYh2UrOfR83lkdPfxzaOWZtRb1+OMjdZS36urax484YByv9ToF7w8f0gR7OAY= X-Received: by 2002:a2e:b690:: with SMTP id l16mr24765041ljo.112.1634552091909; Mon, 18 Oct 2021 03:14:51 -0700 (PDT) MIME-Version: 1.0 References: <20211016155026.GB3686969@ziepe.ca> In-Reply-To: <20211016155026.GB3686969@ziepe.ca> From: Adam Turowski Date: Mon, 18 Oct 2021 12:14:41 +0200 Message-ID: Subject: Re: How to mmap any address space using huge pages? To: Jason Gunthorpe Cc: linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 190B6D0425EA X-Stat-Signature: jefhugapwhujkc9zdpuqmb6ia9bwbrm7 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=EJvbwRkI; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of adam.s.turowski@gmail.com designates 209.85.208.175 as permitted sender) smtp.mailfrom=adam.s.turowski@gmail.com X-Rspamd-Server: rspam02 X-HE-Tag: 1634552091-168769 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. > OK, I can live with "bad pud" warnings for now. Would it be a bad idea to make the zap_pud_range function to look like vunmap_pud_range function by adding a pud_clear_huge(pud) call? -- Regards, Adam Turowski