Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp818039rwb; Mon, 26 Sep 2022 06:18:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7zUJmIJ2tg6EK1wRT7JV7VxAQgX6Vn3pAkmUMPnyWgoioF8RtRNNgxx0vDpAQ6H81zsuaY X-Received: by 2002:a05:6402:4305:b0:451:7b78:f2e0 with SMTP id m5-20020a056402430500b004517b78f2e0mr22899153edc.342.1664198305924; Mon, 26 Sep 2022 06:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198305; cv=none; d=google.com; s=arc-20160816; b=cizsKcUSYYGn+1hYqGNLs8sitExVLmzCBRx/I8fzqOYR9QZy58cXxeNYeVfnNOH+Hd nvVz54526ld6Fa5q3VDFv/OEVMWnArF2nJZzMs4Dm2PCmEVdnMBuaW/0Q6MaGdx0Pp7N y81bkxQQ5k8kJrC0uZ549bWIyl1DRIacvZu0sJk0jxjrCsOQePpDkTJb9yfqOOHwDxcY s42denpLCyLoVHFpDrI5/Kgqb5hBx/3TWOAIdsSCrOpEqE2YgK68WEVC/neo4wdQILSs yp+g352yeIEkN0js/jxeER1/+oZodMSgUNNnTk7DXu+wPvtXhxeSUhcZhgpNmfQZrQhe ubvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=L+ZbOYIFXSEJqplhVaiNThrZYYLuxY7C7urbtDbV/sM=; b=PYACiZdBXZIQOi7l5GDWGR3oGiHV/bxRYix+ixQ52uZqvitHIk8LXt9unUNjXsRzyj 30L/BkqLvWSDgTGVmC80e7K7V3thMueiDwc6mqT0SMaW1PQIy+xf3KclWfZ2KpoomEx7 QTGArbIlShUX3xA89SEp9nNfpYWPmE9w5Iyf/tJkxCbvt7k49rPq7m4Xf+DZdc12r7l9 4EATq4U/ECl2uOCVitUEvXi2Z70vzTY5z3UbNdLkHdidJRBsDhYgu0Awl1UElLZR9baY D3xlLzZQiv2zaRWjBGQK8gRCcvaOCEsW9mZFSbmqL045H6Xy+1bat/3Qt1SQSmPvchBp AiJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VXk+ea4x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc3-20020a1709078a0300b00781599eb7e4si580071ejc.753.2022.09.26.06.18.00; Mon, 26 Sep 2022 06:18:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VXk+ea4x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237713AbiIZLRw (ORCPT + 99 others); Mon, 26 Sep 2022 07:17:52 -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-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 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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