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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C34EC07E9D for ; Mon, 26 Sep 2022 11:17:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234817AbiIZLRx (ORCPT ); Mon, 26 Sep 2022 07:17:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237664AbiIZLQp (ORCPT ); Mon, 26 Sep 2022 07:16:45 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31ADB65654 for ; Mon, 26 Sep 2022 03:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664188539; 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=VXk+ea4x2AkI54yEzrRWyJog0cgrLgys3fny4SF5CScQR4wJF6rbiJ0rOIUMB0Sv9YBaFE 23rA9Mw/gt79maz1ZzOz/tlxWS3XXlPYdoZ68oXpmhXxAyaAHWHZwFR55VLVJ55j6gSMO/ 0DbOJk/GPgdiOtki40fxST6+YF6BpHM= 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-466--IySPEJ7PpOWmf9vv6GJ9Q-1; Mon, 26 Sep 2022 06:35:38 -0400 X-MC-Unique: -IySPEJ7PpOWmf9vv6GJ9Q-1 Received: by mail-wr1-f71.google.com with SMTP id d30-20020adfa41e000000b00228c0e80c49so1029421wra.21 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=aKKejEnE2B4xBtnE0a67pvJxE1Q+WlS1jH4mytZ9kZ7mptluQrQAnkJDWdhw5v3qFC FXk0lYdcN2ZqT0gnL+3hQQXvndcUU2FFPlW30DaB6SK5LdbdKM19optU9ffJURCmK3u2 E//myw4IZW/KGs/qQbCWPfA8IWYyrjV1DI4wPEUNDbCCWShwIX4nSd6IlnI6shYh+jMc BEpla0osphUD/NdEkdWaF+35+VzDF/Pssj73woRle3shYOWvBrCxivjzQSKNkV+phSx+ s+r4vJqfgqzC82rXPxOUbY8wffphLLKkXMQllgnqRpJP9qp+iaBzfnUpa0uf6Z67PUI6 /BdA== X-Gm-Message-State: ACrzQf2tLpLL0ZyiZw+BlnCuoBcmT8rOdgYnAfjRwpKWwN7+rge7925k vhwtex+I9ErleiU6moc81hhuHB4xhgbP/qyQRovnTUBXLWp/qbf2JxhioQvzKcXBCNx+TpEQ+I2 JflhK3aZSKYcrnes847IgqXJa X-Received: by 2002:a05:6000:1564:b0:226:dece:5630 with SMTP id 4-20020a056000156400b00226dece5630mr13540746wrz.294.1664188537469; 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 Content-Language: en-US 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> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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