Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1645453rwb; Tue, 27 Sep 2022 16:39:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6P4gduG9NBrImWU+BZBt83dAWFBH1ciUSWaIisuLSl+xrYMidEna/YrasTezSIM3fz495N X-Received: by 2002:a17:90a:e7d2:b0:202:c6c9:4731 with SMTP id kb18-20020a17090ae7d200b00202c6c94731mr7302812pjb.114.1664321993706; Tue, 27 Sep 2022 16:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664321993; cv=none; d=google.com; s=arc-20160816; b=JDPTbyIFhLIAWCHizch48+yxaJhPN4UEUVkgW3UuyhTtExthctbuNRLrDAZyU74SvC 7iG5l/3MFWSQliAWpyYAsixs+hdMY1KW9jO2U2ObgitM2gioqcLsHYts5aHgkzMXqvP5 M/Mv9RovgzOSBiqRTgUTIpi5fZVyxOnlaB8Y0OlTNyC/fCITcMjZQc6Q1uyDUCOS65sQ kiJX/otSYkldjxgyP7dblssa9rEdfkQ9TocdGZ3RvtVmq1gPXKREPrUSRXRh/wsw3MMT fKSjUpKCItu0EhIMLAHaik5yBjOQQFtRw/BIZllBKh5Z7tkEJPti9bFMUYnGumGy573l ZelA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4MnMVs6E8JaSDSsn99y8Cflsak9Vn4oCEKVAnOpimrc=; b=Uwvkol1wc5+YO4OHfzXk8mlS2OxSaqWcaAUOLEc59W4BlxR08+fBX1trSgDMFmQoqU p1/fk+BJ6Ufocw6hdist/ppqLmRODGoqtSutFVH76z49v6Qz0S0Kik3GT9xU/scAwQkY KuSuV48NGMzHcy+tfZyW1E43oO2zk569m8AohOvuOW+G5Qog89yf/2uH1E6CdSgttvER nHFTmAQOqw8yk1dWWM+HzqwTqcrmHUA2xQdDIa86v6yocBV2bXaBOdp341uJyWmNB23D TgYZ+407+rZm3RTllj8AJxmuqI0KJHNcKm6Smx7uFBl3JHXXP8C6CR8wk9f5QFwEkI2y Fuuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=KTBy7fQL; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n21-20020a638f15000000b00438bc9eedd0si3516079pgd.492.2022.09.27.16.39.42; Tue, 27 Sep 2022 16:39:53 -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=@google.com header.s=20210112 header.b=KTBy7fQL; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232020AbiI0XXe (ORCPT + 99 others); Tue, 27 Sep 2022 19:23:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231669AbiI0XXc (ORCPT ); Tue, 27 Sep 2022 19:23:32 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C119B1DA7E for ; Tue, 27 Sep 2022 16:23:29 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 3so10742140pga.1 for ; Tue, 27 Sep 2022 16:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=4MnMVs6E8JaSDSsn99y8Cflsak9Vn4oCEKVAnOpimrc=; b=KTBy7fQLQX03opurQqZ2U9ctULmybQ5FJUoo4PZb+gpAETjrkid149E9fk/0W8/73E ZrwvTRfgroj/9bgiZZ8XJyKrd78XrYX2iQYAUldEdxqL5OZpVAi1zS9yu8prYMHVa77l 4zjeo6ZBuAJWWGf1zHyMcSzUGInYNji/wPL8fWTGb5gG2xdIaqbbpro066Nv0icVdUH8 qi08NfiTgaHr/ClJbZ6TR3Yy/OpgSs603ryzzPCdNeTU5ylFZxeFY2UaHzVWoEaEC5jr gHQ/fgp9BIfxbbHrCGK8KR3V4hCHTuvinL4qrNVOIDHv67EUocIGa2CUS0dDgpDBgy9Q 85BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=4MnMVs6E8JaSDSsn99y8Cflsak9Vn4oCEKVAnOpimrc=; b=fb9qMZHbYXMo/KzrMeKfASzSpmgc64Pjz4U/mmeFQUPV8VeHS3GNAQf3Aec32igB3q omn9y4+UX6+ud9aZ1v3TiS5yvVCpgxYKjQnP7AtpIkv1/oWybwwpuofWMc/OHZcO0Yk1 RMXVer6BEsL/BOeW0ttiA3DeYSZosJUqWwyPnCvmM7hUYFGDGBznJrYwJ5P6LeI2mzJV SmEtsX6yiIxznDNBHApwgi++gfPKFAeyFt9GZQx8/8rGi+hOvEYx9AO5HTklys1Bh/Bf Etsqu77vybXTw34V6pK+tcU2jQy+RbQhvT2SMi2nmo1oNXQNyuVuMiNGX1ZwgSmrvSm9 0r7Q== X-Gm-Message-State: ACrzQf1dcSQWyCG7A+evM/F8qzZlocKEPf/aQnpGb4+4BJgg1IprIvjP 2TlsVz7MV95wUFPP2uDfcJTf0w== X-Received: by 2002:a05:6a00:124f:b0:542:6c43:5be8 with SMTP id u15-20020a056a00124f00b005426c435be8mr31885111pfi.5.1664321009101; Tue, 27 Sep 2022 16:23:29 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id j1-20020a17090a318100b002007b60e288sm58733pjb.23.2022.09.27.16.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 16:23:28 -0700 (PDT) Date: Tue, 27 Sep 2022 23:23:24 +0000 From: Sean Christopherson To: David Hildenbrand Cc: "Kirill A. Shutemov" , "Kirill A . Shutemov" , Paolo Bonzini , 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 Subject: Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd Message-ID: References: <20220915142913.2213336-1-chao.p.peng@linux.intel.com> <20220915142913.2213336-2-chao.p.peng@linux.intel.com> <20220923005808.vfltoecttoatgw5o@box.shutemov.name> <20220926144854.dyiacztlpx4fkjs5@box.shutemov.name> <0a99aa24-599c-cc60-b23b-b77887af3702@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0a99aa24-599c-cc60-b23b-b77887af3702@redhat.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 Mon, Sep 26, 2022, David Hildenbrand wrote: > On 26.09.22 16:48, Kirill A. Shutemov wrote: > > On Mon, Sep 26, 2022 at 12:35:34PM +0200, David Hildenbrand wrote: > > > 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. > > > > IIUC, KVM doesn't really care about pages or folios. They need PFN to > > populate SEPT. Returning page/folio would make KVM do additional steps to > > extract PFN and one more place to have a bug. > > Fair enough. Smells KVM specific, though. TL;DR: I'm good with either approach, though providing a "struct page" might avoid refactoring the API in the nearish future. Playing devil's advocate for a second, the counter argument is that KVM is the only user for the foreseeable future. That said, it might make sense to return a "struct page" from the core API and force KVM to do page_to_pfn(). KVM already does that for HVA-based memory, so it's not exactly new code. More importantly, KVM may actually need/want the "struct page" in the not-too-distant future to support mapping non-refcounted "struct page" memory into the guest. The ChromeOS folks have a use case involving virtio-gpu blobs where KVM can get handed a "struct page" that _isn't_ refcounted[*]. Once the lack of mmu_notifier integration is fixed, the remaining issue is that KVM doesn't currently have a way to determine whether or not it holds a reference to the page. Instead, KVM assumes that if the page is "normal", it's refcounted, e.g. see kvm_release_pfn_clean(). KVM's current workaround for this is to refuse to map these pages into the guest, i.e. KVM simply forces its assumption that normal pages are refcounted to be true. To remove that workaround, the likely solution will be to pass around a tuple of page+pfn, where "page" is non-NULL if the pfn is a refcounted "struct page". At that point, getting handed a "struct page" from the core API would be a good thing as KVM wouldn't need to probe the PFN to determine whether or not it's a refcounted page. Note, I still want the order to be provided by the API so that KVM doesn't need to run through a bunch of helpers to try and figure out the allowed mapping size. [*] https://lore.kernel.org/all/CAD=HUj736L5oxkzeL2JoPV8g1S6Rugy_TquW=PRt73YmFzP6Jw@mail.gmail.com