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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B12FBEB64D9 for ; Tue, 27 Jun 2023 16:00:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BFA0210E311; Tue, 27 Jun 2023 16:00:44 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9243910E30B for ; Tue, 27 Jun 2023 16:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687881642; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pj+zOzmUOF0cqvoi71YUgGQfKZGwkYWd7D7VJ4Uthv0=; b=gHMh2i2DJ0dLqYgPkYXiiPECHtWhnvm6fUfAXjrrssVTwbBCQTDf7a57IrJ7E8x293e8S1 yV4vMlRfnAYpJUl0N867KMVXIo9eu5lneCxdNN8z+MRdxO3BIu9bjfZIO0fX8CQGT+sIqc bhH9/szKdcaK5a/D0Q5KGldWMdkEpFQ= Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-81-XSLSrQ-JNeuuAS1xRHWsiQ-1; Tue, 27 Jun 2023 12:00:41 -0400 X-MC-Unique: XSLSrQ-JNeuuAS1xRHWsiQ-1 Received: by mail-vk1-f197.google.com with SMTP id 71dfb90a1353d-47dccba4cbcso35159e0c.0 for ; Tue, 27 Jun 2023 09:00:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687881640; x=1690473640; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pj+zOzmUOF0cqvoi71YUgGQfKZGwkYWd7D7VJ4Uthv0=; b=lIpxZ5PIBnhQ1R6Bp0L3qzQ9+xpprWfIAWQRxnae5gXhWLiCBxsNyQ8x+RCN2r8EWm Lj7UVEO1tOClvMqRsFbd6jHqepmBr0le+tOerMGtwYfmevLc5D458Jl67ZywGv31laAd WOhcIRSgmboK2ViV1e2s8/P2bHReC/AVKlSBtBnSjmnb7SHZ4G8RfjEiMJz1G2tjsgJh WlyWEvZAmGJMukwW+Osvq9v6NLX2wRWr4nPOQ4RE435FVaWRGL1HfNFl/2Xs+Wo58qVA YpTXHjGhiZb+l2hdb6o7CSHFvXrpYzpoomHg4n2XnypKj4QCbV/nYD5Kn7fwv33cZZbS ppZA== X-Gm-Message-State: AC+VfDzHULd2jrL3HkPVejwa+eMw7e57lzvVahe4IRl0Nxv+CKKXgx+B 8XKXiqjA1pvIE4dpUXo0eeXpQaTtFPzody2uE6IfZLe1oXMt1QNQw53SMhddjQ0MoHWkkXRNj6h HIeXOUSUzcV+R1k8WLDTHkWmzivcO X-Received: by 2002:a05:6102:ed0:b0:440:b01a:5c1a with SMTP id m16-20020a0561020ed000b00440b01a5c1amr11686245vst.2.1687881640351; Tue, 27 Jun 2023 09:00:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7xVFFwcrphaqlcGPfMPVlXHfKmzWiSqArAVdBUA8Cx9G2oeekuo3uEn/YLT+Qi8i+897tJMQ== X-Received: by 2002:a05:6102:ed0:b0:440:b01a:5c1a with SMTP id m16-20020a0561020ed000b00440b01a5c1amr11686193vst.2.1687881640022; Tue, 27 Jun 2023 09:00:40 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id n10-20020a0cec4a000000b0060530c942f4sm4686678qvq.46.2023.06.27.09.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 09:00:39 -0700 (PDT) Date: Tue, 27 Jun 2023 12:00:38 -0400 From: Peter Xu To: Jason Gunthorpe Subject: Re: [PATCH v1 0/2] udmabuf: Add back support for mapping hugetlb pages Message-ID: References: <20230622072710.3707315-1-vivek.kasireddy@intel.com> <6e429fbc-e0e6-53c0-c545-2e2cbbe757de@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Houghton , Jerome Marchand , "Kim, Dongwon" , David Hildenbrand , "Chang, Junxiao" , Muchun Song , "Kasireddy, Vivek" , "dri-devel@lists.freedesktop.org" , "linux-mm@kvack.org" , "Hocko, Michal" , Gerd Hoffmann , John Hubbard , Andrew Morton , "Kirill A . Shutemov" , Mike Kravetz Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Tue, Jun 27, 2023 at 12:52:34PM -0300, Jason Gunthorpe wrote: > On Mon, Jun 26, 2023 at 03:04:21PM -0400, Peter Xu wrote: > > On Mon, Jun 26, 2023 at 03:18:48PM -0300, Jason Gunthorpe wrote: > > > On Mon, Jun 26, 2023 at 08:14:27PM +0200, David Hildenbrand wrote: > > > > > > > So we might have to implement the same page migration as gup does on > > > > FOLL_LONGTERM here ... maybe there are more such cases/drivers that actually > > > > require that handling when simply taking pages out of the memfd, believing > > > > they can hold on to them forever. > > > > > > In general I would like to see an interface to FOLL_LONGTERM pin pages > > > from a memfd. I would quite happily use that in iommufd as well. > > > > > > It solves some problems we have there with fork/exec/etc if the pages > > > are not linked to a mm_struct. > > > > Afaiu any fd based approach should mean it'll never work with private > > memories, while mm-based should be able to work on any kind. > > Is there a significant use case to open a memfd and then use > MAP_PRIVATE? Why would anyone want to do that instead of just using > normal mmap anonymous memory? I remember David Hildenbrand somewhere mentioned the use case where one wants to snapshot a VM RAM into a file, then start multiple instances by loading that VM RAM with MAP_PRIVATE, so it clones a bunch of snapshoted VM running with a single RAM file shared as a template. Not a generic use case, I guess. My question applies not only memfd but also in general - qemu by default doesn't use memfd afaict, so it boils down to e.g. whether you'll target the iommufd project to work in that case, where qemu uses anonymous memory. Privately mapped file memory is only one of those kinds. -- Peter Xu 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1134EB64DD for ; Tue, 27 Jun 2023 16:01:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 963A08D0003; Tue, 27 Jun 2023 12:01:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9138E8D0001; Tue, 27 Jun 2023 12:01:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B4FE8D0003; Tue, 27 Jun 2023 12:01:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6D0E88D0001 for ; Tue, 27 Jun 2023 12:01:50 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 57BC2140A7F for ; Tue, 27 Jun 2023 16:01:43 +0000 (UTC) X-FDA: 80948993286.02.6157EE0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 3AB29400A5 for ; Tue, 27 Jun 2023 16:00:43 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=h+Gq7Dnq; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687881644; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pj+zOzmUOF0cqvoi71YUgGQfKZGwkYWd7D7VJ4Uthv0=; b=VFRRQYdzUaoDt4BOXZ1PRUfjtQWIxSoX3L3FUV0eDflnAZSNgoJ6RUJZ0OjFzJZ1/AQmfe 2ad7aaDH+Y4x87IWUOqh0vrVbHoBq3Kf5bkBHg3wJsR0/+DPZHuVr1Bk61Nl57v/I4vBqv E4pGbqSF1iPEV156dt9aHsrgRlTzReU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=h+Gq7Dnq; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687881644; a=rsa-sha256; cv=none; b=tG0B4NOWiceYbAnCfQzu5fKhacliTX3c4wG79L7omVn/KecQc99I1PI6OJ9cVL4Yn0yOIi c48UThNjEXqNjsrS5f+euzbqKYESEagGovrZMPGTImyr98CzGIPvCzNpJPjKYgDgtNnNTM V+ZlpGdcqUIDSVyeB7rPRxY0jkFsbAA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687881643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pj+zOzmUOF0cqvoi71YUgGQfKZGwkYWd7D7VJ4Uthv0=; b=h+Gq7Dnq23acIY8nA3z2H+44SEGsuNUfrakzmftRL68a0VtzOyRjlcWoo1+xFS35FSIaQ+ MmBY2JgbRvAs1O0g0tuYaBpHy3uZKamUzjYGhoiYWLkYAbnLaBnFTI6Vp8T4UAKZGZ9SVD K6sAyTfCIXF1iE4zZG1QpMODF3KjPgA= Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-101-cEAs5Wa3MPqIguaElEHQig-1; Tue, 27 Jun 2023 12:00:41 -0400 X-MC-Unique: cEAs5Wa3MPqIguaElEHQig-1 Received: by mail-ua1-f72.google.com with SMTP id a1e0cc1a2514c-7944afceb23so17450241.0 for ; Tue, 27 Jun 2023 09:00:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687881640; x=1690473640; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pj+zOzmUOF0cqvoi71YUgGQfKZGwkYWd7D7VJ4Uthv0=; b=CzEGdBA3BPKzrOBVm79BOp6/buKcWgff/Y9JC+Z6aeaYOrBxz5938fYXZqq75b3KbK ixFeJ44U5kdWfjb0UTehsBYO5cMWORLTSI6vyEWuJUR3xuEpU95k4ryt4bIAKKRqmooJ Rx+ezqNS5s9oi5jdSiLNtfIsGNQBi+Ty5QkwI+Mj12QO85taF0KX6Cqxnpog2W1OEi/s fwGn8hpMXY6uNFCaYlBMoUhWhVLHCzk/qFhENVZQyiVNduzSkm35rL7YPX1dxPiwz8Fp IKFaP8Ok0m4ex8jEX/ydE/PUBFyFPSaMSiGe958CnTO0+21UYyTiRsLQcTlMX/fypXc6 +m/g== X-Gm-Message-State: AC+VfDySRgo+dGN5gOe1Mvz+XSsSoB97YQ49TCKsIrVzVM0P4h76C4fu aWmrM6ItCkaaPCAW9St65gMRoMqZaslcUU6set55UfffapYlH4NP3YTjkA2Uoo/qeXZTupdL5w0 HHg/BkMvuH0Q= X-Received: by 2002:a05:6102:ed0:b0:440:b01a:5c1a with SMTP id m16-20020a0561020ed000b00440b01a5c1amr11686237vst.2.1687881640295; Tue, 27 Jun 2023 09:00:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7xVFFwcrphaqlcGPfMPVlXHfKmzWiSqArAVdBUA8Cx9G2oeekuo3uEn/YLT+Qi8i+897tJMQ== X-Received: by 2002:a05:6102:ed0:b0:440:b01a:5c1a with SMTP id m16-20020a0561020ed000b00440b01a5c1amr11686193vst.2.1687881640022; Tue, 27 Jun 2023 09:00:40 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id n10-20020a0cec4a000000b0060530c942f4sm4686678qvq.46.2023.06.27.09.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 09:00:39 -0700 (PDT) Date: Tue, 27 Jun 2023 12:00:38 -0400 From: Peter Xu To: Jason Gunthorpe Cc: David Hildenbrand , "Kasireddy, Vivek" , "dri-devel@lists.freedesktop.org" , "linux-mm@kvack.org" , Mike Kravetz , Gerd Hoffmann , "Kim, Dongwon" , Andrew Morton , James Houghton , Jerome Marchand , "Chang, Junxiao" , "Kirill A . Shutemov" , "Hocko, Michal" , Muchun Song , John Hubbard Subject: Re: [PATCH v1 0/2] udmabuf: Add back support for mapping hugetlb pages Message-ID: References: <20230622072710.3707315-1-vivek.kasireddy@intel.com> <6e429fbc-e0e6-53c0-c545-2e2cbbe757de@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Stat-Signature: atcc3yakywe4k4y3j36urjy44k8499bg X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3AB29400A5 X-HE-Tag: 1687881643-148211 X-HE-Meta: U2FsdGVkX18rkkRt0q/xwCC5X9HkWGPa46PHxZDOe/bRE0KODzOqRPQmI7PLjiB000MLs0xTfnmjifabzpnGyxAFbrf/J9KIXDFi8NKDZlvix61PTIY1M9IpBU6KVagQeUigwITlFPYtzN1oLgI6rwPFNcb2l69a9nMKXRks88n0BOuS66/7KnOb/Vbw+SWEzGC/lwbST2AuUw7Nkj26EmanC6xcH2Pkfof8110jRE4FVTEOQcKSdrT5q8dYf89aoIdRH/CFK4bKmd9zzw7NRRJV7V1ShRMl2yJe2l7act/Cs69utRqN4aUmp2uFPIxtkh9OsDS2Z1FTUfzJTIw9TGzyHbhntU2/wMyUu6v9Iw2LGnUHRq3aUkdLKzRMNA7q7nEvCY9O8VPieWmsQ2h8oCBrmZ0J31+moJmksEA4vZ7vsjpsU2fvoHSRGh12NmiPulDcAzgpBY0XfwRzGZAB9VyiwiMGSoMq02+JGI6hMtIdRqxq/q1/HoDNDyQNErw+XtlEBksXj4RMQqs+VmVRawCwa88jEoimlk8QSHZybTDwqlB85xDYwWagmRkVC7TXFCZq+cyGspQeKuWW7YlHNoMkg7fJW1ZuJYofX7WesrDRILMnpoHVGY4iU3mUw+NtXkbTFw4flerzu0UJWmK2OsGuKII//WmbwuWqXfG9BAJEj+UCTjC4PqbG3C9DZn/Lg1yR+42JqMlVFCqnFZJM/YC590+4CuFZn5972RwpQ4DBoRAPoBRmHFVDfd2PcYRrMzhRswGDjSdHjRjB7QOZlyhEVFfiVlID+uMH2R6U2Y+dMftBgVQJUvoLhqEHvaJi0rNMP5yZkuYOfQS/uPA6eiD1MBElO/RHVOyfrQQ/VMGBfZuMRhXHXyHIrK3u1EHwXMMxTB/d0DDxjOFxG8K9Yf5opwLLYP8YMh2uCJf42iBhFs67eDNpsbZY9pOfRF899djB1USD3Sjr7+7L3KY 5XqgO8kP 1ZWZOO7KGDJ6GNafAh5UW2Ob7Fd0ol51kjtEx7W6/GIk+VIXFKwAUBw1ibrh51cLfGWad8+ceAmOZ3FG25PcXjWTtDpb8fdumwKMHkEnNkPAK9DOU/byaj4FPs6vUIuNM9ceZtKtWDtNk5wSoF9nBdUe87MGRr84X8Pr6A2UB/QqqGXdRH33CPx5Z809KMNrkFSSqmqWQz1eZs07Cg1uwIpQ55/0Z/Ed7j7nuva/T3OVYs1HlqyMK6NsTsiT6EWCh6shr++eUcPSPY3iUMRhoU2HKaUeh4jyxvDxDm5cs3aZiPJHcN0VUevlCMS+MSTmoNDivdwrS3xlRsFHRjYfdf2Fmi0mxPjWtMT/SkQNCbkTN4d+xfcif7z2GkJ9tWMWKh4hDoCq5Mj9Z0Ve3QX9oXsaQUg== 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 Tue, Jun 27, 2023 at 12:52:34PM -0300, Jason Gunthorpe wrote: > On Mon, Jun 26, 2023 at 03:04:21PM -0400, Peter Xu wrote: > > On Mon, Jun 26, 2023 at 03:18:48PM -0300, Jason Gunthorpe wrote: > > > On Mon, Jun 26, 2023 at 08:14:27PM +0200, David Hildenbrand wrote: > > > > > > > So we might have to implement the same page migration as gup does on > > > > FOLL_LONGTERM here ... maybe there are more such cases/drivers that actually > > > > require that handling when simply taking pages out of the memfd, believing > > > > they can hold on to them forever. > > > > > > In general I would like to see an interface to FOLL_LONGTERM pin pages > > > from a memfd. I would quite happily use that in iommufd as well. > > > > > > It solves some problems we have there with fork/exec/etc if the pages > > > are not linked to a mm_struct. > > > > Afaiu any fd based approach should mean it'll never work with private > > memories, while mm-based should be able to work on any kind. > > Is there a significant use case to open a memfd and then use > MAP_PRIVATE? Why would anyone want to do that instead of just using > normal mmap anonymous memory? I remember David Hildenbrand somewhere mentioned the use case where one wants to snapshot a VM RAM into a file, then start multiple instances by loading that VM RAM with MAP_PRIVATE, so it clones a bunch of snapshoted VM running with a single RAM file shared as a template. Not a generic use case, I guess. My question applies not only memfd but also in general - qemu by default doesn't use memfd afaict, so it boils down to e.g. whether you'll target the iommufd project to work in that case, where qemu uses anonymous memory. Privately mapped file memory is only one of those kinds. -- Peter Xu