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 E91E5C07E9D for ; Mon, 26 Sep 2022 10:35:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4155C8E003D; Mon, 26 Sep 2022 06:35:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C50B8E0039; Mon, 26 Sep 2022 06:35:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 264EF8E003D; Mon, 26 Sep 2022 06:35:43 -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 188AF8E0039 for ; Mon, 26 Sep 2022 06:35:43 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CB5AB1C5ED8 for ; Mon, 26 Sep 2022 10:35:42 +0000 (UTC) X-FDA: 79953880524.28.388C60F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 633BD40002 for ; Mon, 26 Sep 2022 10:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664188541; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L+ZbOYIFXSEJqplhVaiNThrZYYLuxY7C7urbtDbV/sM=; b=UrK+I5MqUww53s1cwH1rcSeTFAmu+5MAdXE87h/7p5KMHiMVYb8mOQLVHi0EGG1HjwbsDh 0dQNYtHBwftyqybHNcL14646JC9nucHv+gTxh1lTM7rALfZcejlrtinclDBhuJgdGexbEi EfNkOr3pIsGD8+Zg8wv9/5JU8cQ9qT4= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-252-FJGVpWtXNE6qOwY4T8jFpQ-1; Mon, 26 Sep 2022 06:35:38 -0400 X-MC-Unique: FJGVpWtXNE6qOwY4T8jFpQ-1 Received: by mail-wr1-f71.google.com with SMTP id v7-20020adfa1c7000000b0022ae7d7313eso1019775wrv.19 for ; Mon, 26 Sep 2022 03:35:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=L+ZbOYIFXSEJqplhVaiNThrZYYLuxY7C7urbtDbV/sM=; b=EPNPGpiBwd/7N8N/Py7ELy0LemSIo6a+AMzWWgKPI7PQzw4uGt86JZHXU7Hd6FW/je 7/USviCCQezuo0VAPbc8tKXglFcfdmcgee/CYwsDvu+UEhH9bwVPos+HrgaDGu5O0TJd 6Q1SCftT8hqVSRJbWj/s6aQJq/XEbRqTPLaYmkfDreBUmu5GsNpP1SVteE3dgl4uapCE gzopd+t88xw698iu/GpAds8WPzTFcqzB9NY15UooA3aHXzuIhguTfR7ffCCaQyr3NGhZ qkhSmQsMah1LPoVHyf+k+MPSWgOEJoi+93LeO1Pn5HQoRu/JcTmx9+wKHXdLx/iVMBke eK0A== X-Gm-Message-State: ACrzQf1evNSdF2odpVGnP2S8jx6K7l21o/WamzqC4cEynsYHmCYq+95K REkeA/RZDmMvLh3KEC8rtTMS+6tyz4TZThK63KT1U9kIUerlorAETwaWPhH+8YuDphD1Lh+AEGc rwEtYlR55OdA= X-Received: by 2002:a05:6000:1564:b0:226:dece:5630 with SMTP id 4-20020a056000156400b00226dece5630mr13540790wrz.294.1664188537510; Mon, 26 Sep 2022 03:35:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5u1Q2JTjA/FqGvI24o/KaCkInpRVUGg48R8VAI4FAuWRKXHrHhWxqHaWiVkWoqmb7Fe69iUg== X-Received: by 2002:a05:6000:1564:b0:226:dece:5630 with SMTP id 4-20020a056000156400b00226dece5630mr13540729wrz.294.1664188537097; Mon, 26 Sep 2022 03:35:37 -0700 (PDT) Received: from ?IPV6:2003:cb:c703:4b00:e090:7fa6:b7d6:d4a7? (p200300cbc7034b00e0907fa6b7d6d4a7.dip0.t-ipconnect.de. [2003:cb:c703:4b00:e090:7fa6:b7d6:d4a7]) by smtp.gmail.com with ESMTPSA id r64-20020a1c4443000000b003b4935f04a4sm13132198wma.5.2022.09.26.03.35.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Sep 2022 03:35:36 -0700 (PDT) Message-ID: Date: Mon, 26 Sep 2022 12:35:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd To: "Kirill A . Shutemov" , Paolo Bonzini , Sean Christopherson Cc: Chao Peng , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song , wei.w.wang@intel.com References: <20220915142913.2213336-1-chao.p.peng@linux.intel.com> <20220915142913.2213336-2-chao.p.peng@linux.intel.com> <20220923005808.vfltoecttoatgw5o@box.shutemov.name> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220923005808.vfltoecttoatgw5o@box.shutemov.name> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664188542; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=L+ZbOYIFXSEJqplhVaiNThrZYYLuxY7C7urbtDbV/sM=; b=lsP3L3DILiV2/WFwSzJTSunCkhP2xfXrkM6/cWMyi/ivr6Td+YuQ1TL1HNAmH8+KWpTIbc 43PdkkWYaZnHFSRf2gyY70wv4uP2QCeCD2BaaHNv4GoUqvr9XSASkCl6Of5SB8XMlHd+PY pn1CARd/Y+/IxisMnvp1c5EWYi0MkcA= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UrK+I5Mq; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664188542; a=rsa-sha256; cv=none; b=YbXSRrYyZYA+jS2pTdwVYT0OaYQuL9+wwWPINvlO5DuiGug9nUo5FjQvCpMX3xRZjLhmWd ioj+s7z5D8a5hXC6WkXSOPXtVhWacSI3RI9XNR9nmLSO3pkb5xZrpCetzBTNnJTQmieAaU LXzWtJ3uX3Oaej5YfIFn2WYProypEHg= X-Rspam-User: Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UrK+I5Mq; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 633BD40002 X-Stat-Signature: 5uzngk6jeg8w9yq7og8r4e97h1rn1mce X-HE-Tag: 1664188542-917218 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 23.09.22 02:58, Kirill A . Shutemov wrote: > On Mon, Sep 19, 2022 at 11:12:46AM +0200, David Hildenbrand wrote: >>> diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h >>> index 6325d1d0e90f..9d066be3d7e8 100644 >>> --- a/include/uapi/linux/magic.h >>> +++ b/include/uapi/linux/magic.h >>> @@ -101,5 +101,6 @@ >>> #define DMA_BUF_MAGIC 0x444d4142 /* "DMAB" */ >>> #define DEVMEM_MAGIC 0x454d444d /* "DMEM" */ >>> #define SECRETMEM_MAGIC 0x5345434d /* "SECM" */ >>> +#define INACCESSIBLE_MAGIC 0x494e4143 /* "INAC" */ >> >> >> [...] >> >>> + >>> +int inaccessible_get_pfn(struct file *file, pgoff_t offset, pfn_t *pfn, >>> + int *order) >>> +{ >>> + struct inaccessible_data *data = file->f_mapping->private_data; >>> + struct file *memfd = data->memfd; >>> + struct page *page; >>> + int ret; >>> + >>> + ret = shmem_getpage(file_inode(memfd), offset, &page, SGP_WRITE); >>> + if (ret) >>> + return ret; >>> + >>> + *pfn = page_to_pfn_t(page); >>> + *order = thp_order(compound_head(page)); >>> + SetPageUptodate(page); >>> + unlock_page(page); >>> + >>> + return 0; >>> +} >>> +EXPORT_SYMBOL_GPL(inaccessible_get_pfn); >>> + >>> +void inaccessible_put_pfn(struct file *file, pfn_t pfn) >>> +{ >>> + struct page *page = pfn_t_to_page(pfn); >>> + >>> + if (WARN_ON_ONCE(!page)) >>> + return; >>> + >>> + put_page(page); >>> +} >>> +EXPORT_SYMBOL_GPL(inaccessible_put_pfn); >> >> Sorry, I missed your reply regarding get/put interface. >> >> https://lore.kernel.org/linux-mm/20220810092532.GD862421@chaop.bj.intel.com/ >> >> "We have a design assumption that somedays this can even support non-page >> based backing stores." >> >> As long as there is no such user in sight (especially how to get the memfd >> from even allocating such memory which will require bigger changes), I >> prefer to keep it simple here and work on pages/folios. No need to >> over-complicate it for now. > > Sean, Paolo , what is your take on this? Do you have conrete use case of > pageless backend for the mechanism in sight? Maybe DAX? The problem I'm having with this is how to actually get such memory into the memory backend (that triggers notifiers) and what the semantics are at all with memory that is not managed by the buddy. memfd with fixed PFNs doesn't make too much sense. When using DAX, what happens with the shared <->private conversion? Which "type" is supposed to use dax, which not? In other word, I'm missing too many details on the bigger picture of how this would work at all to see why it makes sense right now to prepare for that. -- Thanks, David / dhildenb